Skip to content

Commit

Permalink
Merge branch 'master' into em_kbconversion-restapi
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmarr authored Aug 19, 2019
2 parents d1678bb + bcfbaed commit f864579
Show file tree
Hide file tree
Showing 123 changed files with 7,478 additions and 476 deletions.
4 changes: 2 additions & 2 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
style '_checks/md_style'
ignore_front_matter true
style '_checks/styles/style-rules-dev'
ignore_front_matter true
20 changes: 13 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ require 'html-proofer'
require 'kramdown'
require 'launchy'
require 'colorator'
require 'erb'

# Require helper methods from the 'rakelib/lib' directory
Dir.glob('rakelib/lib/**/*.rb') { |file| require_relative(file) }
# Require helper methods from the 'lib' directory
Dir.glob('lib/**/*.rb') { |file| require_relative(file) }

desc "Same as 'rake', 'rake preview'"
task default: %w[preview]
Expand Down Expand Up @@ -59,11 +58,18 @@ end
desc 'Pull docs from external repositories'
task init: %w[multirepo:init]

desc 'Run checks (image optimization).'
task check: %w[check:image_optim check:mdl]
desc 'Run checks (image optimization and Markdown style linting).'
task check: %w[check:image_optim check:mdl]

desc 'Generate data for the weekly digest.'
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
sh 'whatsup_github'
if date.nil? or date.empty?
sh 'bin/whatsup_github'
elsif date.is_a? String
sh 'bin/whatsup_github', 'since', ENV['since'].to_s
else
puts 'The "since" argument must be a string/ Example: "jul 4"'
end
end
17 changes: 11 additions & 6 deletions _checks/html-check-hook.rb → _checks/html_check_hook.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# The hook runs html-proofer with options defined in the
# _config.checks.yml file
#
Expand All @@ -6,7 +8,7 @@
#
require 'html-proofer'
require 'yaml'
require_relative '../rakelib/lib/double-slash-check.rb'
require_relative '../lib/double_slash_check.rb'

Jekyll::Hooks.register :site, :post_write do |site|
# Do nothing unless 'site.check_links' is set
Expand All @@ -15,17 +17,20 @@
# Do not exit when html-proofer raises an error
begin
# Check 'url_ignore' in '_config.checks.yml'
# and add 'excludes' from Jekyll configurtiuon.
# and add 'excludes' from Jekyll configuration.
#
checks_config = YAML.load_file('_config.checks.yml')
url_ignore = checks_config.dig('html-proofer', :url_ignore)
jekyll_excludes = site.config['exclude']
jekyll_excludes_as_regex = jekyll_excludes.map { |item| Regexp.new Regexp.escape(item) }
jekyll_excludes_as_regex =
jekyll_excludes.map do |item|
Regexp.new Regexp.escape(item)
end

if url_ignore
url_ignore.push(jekyll_excludes_as_regex).flatten!.uniq!
else
checks_config['html-proofer'].merge!({ url_ignore: jekyll_excludes_as_regex })
checks_config['html-proofer'].merge!(url_ignore: jekyll_excludes_as_regex)
end

# Read configuration options for html-proofer
Expand All @@ -36,8 +41,8 @@

# Show the message when html-proofer fails.
# Expected that it fails when it finds broken links.
rescue StandardError => msg
puts msg
rescue StandardError => e
puts e
puts 'Fix the broken links before you push the changes to remote branch.'.blue
end
end
8 changes: 6 additions & 2 deletions _checks/md-check-hook.rb → _checks/md_check_hook.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# 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/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}`
puts report.yellow
puts 'The style is defined in _checks/md_style'.yellow
puts 'The style is defined in _checks/styles/style-rules-dev'.yellow
end
File renamed without changes.
38 changes: 38 additions & 0 deletions _checks/styles/style-rules-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
exclude_rule 'MD001'
exclude_rule 'MD002'
exclude_rule 'MD003'
exclude_rule 'MD004'
exclude_rule 'MD005'
exclude_rule 'MD006'
exclude_rule 'MD007'
exclude_rule 'MD009'
exclude_rule 'MD010'
exclude_rule 'MD011'
exclude_rule 'MD012'
exclude_rule 'MD013'
exclude_rule 'MD014'
exclude_rule 'MD018'
exclude_rule 'MD019'
exclude_rule 'MD020'
exclude_rule 'MD021'
exclude_rule 'MD022'
exclude_rule 'MD023'
exclude_rule 'MD024'
exclude_rule 'MD025'
exclude_rule 'MD026'
exclude_rule 'MD027'
exclude_rule 'MD028'
exclude_rule 'MD029'
exclude_rule 'MD030'
exclude_rule 'MD031'
exclude_rule 'MD032'
exclude_rule 'MD033'
exclude_rule 'MD034'
exclude_rule 'MD035'
exclude_rule 'MD036'
exclude_rule 'MD037'
exclude_rule 'MD038'
exclude_rule 'MD039'
exclude_rule 'MD040'
exclude_rule 'MD041'
exclude_rule 'MD046'
3 changes: 3 additions & 0 deletions _config.checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
html-proofer:

# Validate HTML
:check_html: true

# Do not check external links.
:disable_external: true

Expand Down
9 changes: 8 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ exclude:
- bin
- node_modules
- vendor
- .git
- .github
- .idea
- Gemfile
- Gemfile.lock
Expand All @@ -222,3 +222,10 @@ exclude:
- rakelib
- README.md
- _plugins
- tmp
- lib
- rakelib
- scripts
- redirects.json
- Docfile.yml

Loading

0 comments on commit f864579

Please sign in to comment.