From c007adb0e5a75fdfadb5bc6f6820200ec52438df Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 12 Aug 2019 12:53:50 -0500 Subject: [PATCH] Update docs and code formatting --- Rakefile | 4 ++-- _checks/md_check_hook.rb | 6 +++++- lib/link_checker.rb | 1 + rakelib/check.rake | 4 +++- rakelib/multirepo.rake | 2 ++ rakelib/test.rake | 6 +++--- rakelib/update.rake | 2 +- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 148dfd46ff1..66727fc9a24 100644 --- a/Rakefile +++ b/Rakefile @@ -58,10 +58,10 @@ end desc 'Pull docs from external repositories' task init: %w[multirepo:init] -desc 'Run checks (image optimization).' +desc 'Run checks (image optimization and Markdown style linting).' task check: %w[check:image_optim check:mdl] -desc 'Generate data for a news digest. Default period is a week since today. For other period use "since" argument: since="jul 4"' +desc 'Generate data for a news digest. Default timeframe is a week since today. For other period, use "since" argument: since="jul 4"' task :whatsnew do date = ENV['since'] print 'Generating data for the weekly digest: $ '.magenta diff --git a/_checks/md_check_hook.rb b/_checks/md_check_hook.rb index e2383323e6b..a3723067be1 100644 --- a/_checks/md_check_hook.rb +++ b/_checks/md_check_hook.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + # This Jekyll hook runs Markdown linter (https://github.com/markdownlint/markdownlint) # on .md files that git tracks as 'modified' ('git ls-files -m'). -# '_checks/styles/md_style' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md) +# '_checks/styles/style-rules-dev' sets a style (https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md) # that is a set of rules to be applied when linting (https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md). # '.mdlrc' sets linting configuration (https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md). # @@ -8,9 +10,11 @@ # Jekyll::Hooks.register :site, :post_write do |site| next unless site.config['serving'] + staged_files = `git ls-files -m`.split("\n") staged_md_files = staged_files.select { |file| File.extname(file) == '.md' } next if staged_md_files.empty? + puts 'Checking Markdown syntax...'.blue staged_md_files_as_a_string = staged_md_files.join(' ') report = `bin/mdl #{staged_md_files_as_a_string}` diff --git a/lib/link_checker.rb b/lib/link_checker.rb index cd7242ff0d4..80e2b3322ad 100644 --- a/lib/link_checker.rb +++ b/lib/link_checker.rb @@ -13,6 +13,7 @@ def self.options config = YAML.load_file('_config.checks.yml') baseurl = ENV['BUILD_NUMBER'] return config['html-proofer'] unless baseurl + url_swap = { url_swap: { %r{\A/#{baseurl}} => '' } } config['html-proofer'].merge(url_swap) end diff --git a/rakelib/check.rake b/rakelib/check.rake index 228d7d632f7..952b07bf6e5 100644 --- a/rakelib/check.rake +++ b/rakelib/check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :check do desc 'Optimize images in modified files, or by path (rake image_optim path=path/to/dir/or/file).' task :image_optim do @@ -24,6 +26,6 @@ namespace :check do puts 'Running Markdown linter ...'.magenta report = `bin/mdl #{path}` puts report.yellow - puts 'The rules are defined in _checks/styles/md_style'.magenta + puts 'The rules are defined in _checks/styles/style-rules-dev'.magenta end end diff --git a/rakelib/multirepo.rake b/rakelib/multirepo.rake index bbdad0f39a3..6f1c194b5ad 100644 --- a/rakelib/multirepo.rake +++ b/rakelib/multirepo.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :multirepo do desc 'Create a file tree for devdocs website and get all required content' task :init do diff --git a/rakelib/test.rake b/rakelib/test.rake index 6715fc7426f..89b1b4e9afe 100644 --- a/rakelib/test.rake +++ b/rakelib/test.rake @@ -1,13 +1,13 @@ # frozen_string_literal: true namespace :test do - # Run htmlproofer to check for broken links + # Run html-proofer to check for broken links desc 'Build devdocs and check for broken links' task links: %w[build links_no_build] desc 'Check the existing _site for broken links on Jenkins' task cicd: %w[style] do - puts 'Checking links with htmlproofer...'.magenta + puts 'Checking links with html-proofer...'.magenta LinkChecker.check_site end @@ -20,7 +20,7 @@ namespace :test do report = LinkChecker.md_report_path $stderr.reopen(report, 'w+') - puts 'Checking links with htmlproofer...'.magenta + puts 'Checking links with html-proofer...'.magenta LinkChecker.check_site # We're expecting link validation errors, but unless we rescue from diff --git a/rakelib/update.rake b/rakelib/update.rake index 0397344c5b9..2b52f2428c8 100644 --- a/rakelib/update.rake +++ b/rakelib/update.rake @@ -73,7 +73,7 @@ namespace :update do sh 'git status -sb' end - desc 'Update devodcs and subrepositories' + desc 'Update devdocs and subrepositories' task all: %w[devdocs subrepos] desc 'Update subrepositories only'