summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/docs/compile_deprecations.rake
blob: 4ac68a9f85096e1e6d9b8685e854ad2c93b00b4a (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
# frozen_string_literal: true

namespace :gitlab do
  namespace :docs do
    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 "Deprecations compiled to #{path}"
    end

    desc "Check that the deprecation doc 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 "Deprecations doc is up to date."
      else
        format_output('Deprecations doc is outdated! You (or your technical writer) can update it by running `bin/rake gitlab:docs:compile_deprecations`.')
        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 "Removals compiled to #{path}"
    end

    desc "Check that the removal doc 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 "Removals doc is up to date."
      else
        format_output('Removals doc is outdated! You (or your technical writer) can update it by running `bin/rake gitlab:docs:compile_removals`.')
        abort
      end
    end
  end
end