Welcome to mirror list, hosted at ThFree Co, Russian Federation.

compile_deprecations.rake « docs « gitlab « tasks « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f7821315f828906727ef195fe7a543ac6190ad23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true

namespace :gitlab do
  namespace :docs do
    COLOR_CODE_RESET = "\e[0m"
    COLOR_CODE_RED = "\e[31m"
    COLOR_CODE_GREEN = "\e[32m"

    desc "Generate deprecation list from individual files"
    task :compile_deprecations do
      require_relative '../../../../tooling/docs/deprecation_handling'
      path = Rails.root.join("doc/update/deprecations.md")
      File.write(path, Docs::DeprecationHandling.new('deprecation').render)
      puts "#{COLOR_CODE_GREEN}INFO: Deprecations compiled to #{path}.#{COLOR_CODE_RESET}"
    end

    desc "Check that the deprecation documentation is up to date"
    task :check_deprecations do
      require_relative '../../../../tooling/docs/deprecation_handling'
      path = Rails.root.join("doc/update/deprecations.md")

      contents = Docs::DeprecationHandling.new('deprecation').render
      doc = File.read(path)

      if doc == contents
        puts "#{COLOR_CODE_GREEN}INFO: Deprecations documentation is up to date.#{COLOR_CODE_RESET}"
      else
        warn <<~EOS
        #{COLOR_CODE_RED}ERROR: Deprecations documentation is outdated!#{COLOR_CODE_RESET}
        To update the deprecations documentation, either:

        - Run `bin/rake gitlab:docs:compile_deprecations` and commit the changes to this branch.
        - Have a technical writer resolve the issue.
        EOS
        abort
      end
    end

    desc "Generate removal list from individual files"
    task :compile_removals do
      require_relative '../../../../tooling/docs/deprecation_handling'
      path = Rails.root.join("doc/update/removals.md")
      File.write(path, Docs::DeprecationHandling.new('removal').render)
      puts "#{COLOR_CODE_GREEN}INFO: Removals compiled to #{path}.#{COLOR_CODE_RESET}"
    end

    desc "Check that the removal documentation is up to date"
    task :check_removals do
      require_relative '../../../../tooling/docs/deprecation_handling'
      path = Rails.root.join("doc/update/removals.md")
      contents = Docs::DeprecationHandling.new('removal').render
      doc = File.read(path)

      if doc == contents
        puts "#{COLOR_CODE_GREEN}INFO: Removals documentation is up to date.#{COLOR_CODE_RESET}"
      else
        warn <<~EOS
        #{COLOR_CODE_RED}ERROR: Removals documentation is outdated!#{COLOR_CODE_RESET}
        To update the removals documentation, either:

        - Run `bin/rake gitlab:docs:compile_removals` and commit the changes to this branch.
        - Have a technical writer resolve the issue.
        EOS
        abort
      end
    end
  end
end