Commit 9489b913 authored by Marcel Amirault's avatar Marcel Amirault Committed by Dylan Griffith

Fix compilation of deprecations doc, and test it in CI

parent a998bacb
...@@ -75,3 +75,16 @@ ui-docs-links lint: ...@@ -75,3 +75,16 @@ ui-docs-links lint:
needs: [] needs: []
script: script:
- bundle exec haml-lint -i DocumentationLinks - bundle exec haml-lint -i DocumentationLinks
deprecations-doc check:
variables:
SETUP_DB: "false"
extends:
- .default-retry
- .rails-cache
- .default-before_script
- .docs:rules:deprecations
stage: test
needs: []
script:
- bundle exec rake gitlab:docs:check_deprecations
...@@ -147,6 +147,13 @@ ...@@ -147,6 +147,13 @@
- ".markdownlint.yml" - ".markdownlint.yml"
- "scripts/lint-doc.sh" - "scripts/lint-doc.sh"
.docs-deprecations-patterns: &docs-deprecations-patterns
- "doc/deprecations/index.md"
- "data/deprecations/*.yml"
- "data/deprecations/templates/_deprecation_template.md.erb"
- "lib/tasks/gitlab/docs/compile_deprecations.rake"
- "tooling/deprecations/docs.rb"
.bundler-patterns: &bundler-patterns .bundler-patterns: &bundler-patterns
- '{Gemfile.lock,*/Gemfile.lock,*/*/Gemfile.lock}' - '{Gemfile.lock,*/Gemfile.lock,*/*/Gemfile.lock}'
...@@ -453,6 +460,12 @@ ...@@ -453,6 +460,12 @@
changes: *docs-patterns changes: *docs-patterns
when: on_success when: on_success
.docs:rules:deprecations:
rules:
- <<: *if-default-refs
changes: *docs-deprecations-patterns
when: on_success
################## ##################
# GraphQL rules # # GraphQL rules #
################## ##################
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
stage: none stage: none
group: none group: none
info: "See the Technical Writers assigned to Development Guidelines: https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines" info: "See the Technical Writers assigned to Development Guidelines: https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines"
description: "View features that are currently deprecated"
--- ---
# Deprecated features by planned removal milestone # Deprecated feature removal schedule
<!-- <!--
This page is automatically generated from the YAML files in `/data/deprecations` by the rake task This page is automatically generated from the YAML files in `/data/deprecations` by the rake task
...@@ -16,15 +15,16 @@ Do not edit this page directly. ...@@ -16,15 +15,16 @@ Do not edit this page directly.
To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template, To add a deprecation, use the example.yml file in `/data/deprecations/templates` as a template,
then run `bin/rake gitlab:docs:compile_deprecations`. then run `bin/rake gitlab:docs:compile_deprecations`.
--> -->
<% if milestones.any? %>
<%- milestones.each do |milestone| %>
## <%= milestone %>
<%- deprecations.select{|d| d["removal_milestone"] == milestone}.each do |deprecation| %>
### <%= deprecation["name"]%>
<% if milestones.any? -%> <%= deprecation["body"] -%>
<% milestones.each do |milestone| %> <%- end -%>
### <%= milestone %> <%- end -%>
<% deprecations.select{|d| d["removal_milestone"] == milestone}.each do |deprecation| %> <%- else -%>
#### <%= deprecation["name"] %>
<%= deprecation["body"]%> Deprecated features scheduled for removal will be listed here, sorted by GitLab milestone.
<% end %>
<% end %>
<% else -%>
## There are no deprecated features for this version of GitLab
<% end -%> <% end -%>
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
# #
# Please delete this line and above before submitting your merge request. # Please delete this line and above before submitting your merge request.
- name: # The name of the feature to be deprecated - name: "Feature name" # The name of the feature to be deprecated
removal_milestone: # XX.YY format - the milestone when this feature is planned to be removed removal_milestone: "XX.YY" # the milestone when this feature is planned to be removed
body: | # Do not modify this line, instead modify the lines below. body: | # Do not modify this line, instead modify the lines below.
<!-- START OF BODY COMMENT <!-- START OF BODY COMMENT
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
stage: none stage: none
group: none group: none
info: "See the Technical Writers assigned to Development Guidelines: https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines" info: "See the Technical Writers assigned to Development Guidelines: https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments-to-development-guidelines"
description: "View features that are currently deprecated"
--- ---
# Deprecated features by planned removal milestone # Deprecated feature removal schedule
<!-- <!--
This page is automatically generated from the YAML files in `/data/deprecations` by the rake task This page is automatically generated from the YAML files in `/data/deprecations` by the rake task
...@@ -17,4 +16,4 @@ To add a deprecation, use the example.yml file in `/data/deprecations/templates` ...@@ -17,4 +16,4 @@ To add a deprecation, use the example.yml file in `/data/deprecations/templates`
then run `bin/rake gitlab:docs:compile_deprecations`. then run `bin/rake gitlab:docs:compile_deprecations`.
--> -->
## There are no deprecated features for this version of GitLab Deprecated features scheduled for removal will be listed here, sorted by GitLab milestone.
...@@ -4,28 +4,26 @@ namespace :gitlab do ...@@ -4,28 +4,26 @@ namespace :gitlab do
namespace :docs do namespace :docs do
desc "Generate deprecation list from individual files" desc "Generate deprecation list from individual files"
task :compile_deprecations do task :compile_deprecations do
require_relative '../../../../tooling/deprecations/docs/renderer' require_relative '../../../../tooling/deprecations/docs'
source_files = Rake::FileList.new("data/deprecations/**/*.yml") do |fl| File.write(Deprecations::Docs.path, Deprecations::Docs.render)
fl.exclude(/example\.yml/)
end
deprecations = source_files.map do |file| puts "Deprecations compiled to #{Deprecations::Docs.path}"
YAML.load_file(file)
end end
deprecations.sort_by! { |d| -d["removal_milestone"].to_f } desc "Check that the deprecation doc is up to date"
task :check_deprecations do
milestones = deprecations.map { |d| d["removal_milestone"].to_f }.uniq require_relative '../../../../tooling/deprecations/docs'
contents = Deprecations::Docs::Renderer contents = Deprecations::Docs.render
.render(deprecations: deprecations, milestones: milestones) doc = File.read(Deprecations::Docs.path)
File.write( if doc == contents
File.expand_path("doc/deprecations/index.md", "#{__dir__}/../../../.."), puts "Deprecations doc is up to date."
contents) else
format_output('Deprecations doc is outdated! Please update it by running `bundle exec rake gitlab:docs:compile_deprecations`.')
puts "Deprecations compiled to doc/deprecations/index.md" abort
end
end end
end end
end end
# frozen_string_literal: true
require 'erb'
module Deprecations
module Docs
module_function
def path
Rails.root.join("doc/update/deprecations.md")
end
def render
deprecations_yaml_glob = Rails.root.join("data/deprecations/**/*.yml")
source_files = Rake::FileList.new(deprecations_yaml_glob) do |fl|
fl.exclude(/example\.yml$/)
end
deprecations = source_files.flat_map do |file|
YAML.load_file(file)
end
deprecations = VersionSorter.rsort(deprecations) { |d| d["removal_milestone"] }
milestones = deprecations.map { |d| d["removal_milestone"] }.uniq
template = Rails.root.join("data/deprecations/templates/_deprecation_template.md.erb")
load_template(template)
.result_with_hash(deprecations: deprecations, milestones: milestones)
end
def load_template(filename)
ERB.new(File.read(filename), trim_mode: '-')
end
end
end
# frozen_string_literal: true
require 'erb'
module Deprecations
module Docs
module Renderer
module_function
def render(**variables)
template = File.expand_path("data/deprecations/templates/_deprecation_template.md.erb", "#{__dir__}/../../..")
load_template(template).result_with_hash(variables)
end
def load_template(filename)
ERB.new(File.read(filename), trim_mode: '-')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment