Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Update docs and code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dshevtsov committed Aug 12, 2019
1 parent 0edc999 commit c007adb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion _checks/md_check_hook.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# 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).
#
# The plugin runs in serving mode only.
#
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}`
Expand Down
1 change: 1 addition & 0 deletions lib/link_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion rakelib/check.rake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions rakelib/multirepo.rake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions rakelib/test.rake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rakelib/update.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit c007adb

Please sign in to comment.