From e63f3b339f68c3f12607462ced817a0c1d58111d Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 7 Jan 2019 09:52:33 -0600 Subject: [PATCH] Decreased encapsulation to make the tasks more clear --- Rakefile | 54 ++++++++++++++++++++++-------------------- rakelib/jekyll.rb | 16 ------------- rakelib/preview.rake | 14 ++++++----- rakelib/rake-helper.rb | 9 ------- 4 files changed, 36 insertions(+), 57 deletions(-) delete mode 100644 rakelib/jekyll.rb delete mode 100644 rakelib/rake-helper.rb diff --git a/Rakefile b/Rakefile index 7f52ff9953b..a7eb1c57c9b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,19 @@ -require_relative './rakelib/rake-helper.rb' +# frozen_string_literal: true -include JekyllRake -include Proofer -include Converter +# This file contains tasks with no namespace. +# All namespaced tasks are defined in the '../rakelib' directory. +# Each namespace is defined in a separate file. +# For example, 'preview:all' is defined in the '../rakelib/preview.rake' file. +# To see the list of tasks to use, run 'rake -T'. + +require 'html-proofer' +require 'kramdown' +require 'launchy' +require 'colorator' + +# Load ruby files with helper methods from the 'rakelib/' directory +require_relative 'rakelib/link-checker.rb' +require_relative 'rakelib/converter.rb' desc "Same as 'rake', 'rake preview'" task default: %w[preview] @@ -10,41 +21,32 @@ task default: %w[preview] desc "Same as 'test:report'" task test: %w[test:report] -desc "Preview the devdocs locally" +desc 'Preview the devdocs locally' task preview: %w[install clean] do - print "Generating devdocs locally ... ".magenta - if File.exists?('_config.local.yml') - print "enabled the additional configuration parameters from _config.local.yml: $ ".magenta - preview_local + puts 'Generating devdocs locally ... '.magenta + if File.exist?('_config.local.yml') + print 'enabled the additional configuration parameters from _config.local.yml: $ '.magenta + sh 'bundle exec jekyll serve --incremental --open-url --livereload --trace --config _config.yml,_config.local.yml' else - print "enabled the default configuration; generating the entire devdocs $ ".magenta - preview + Rake::Task['preview:all'].invoke end end -desc "Remove the generated content" task :clean do - print "Cleaning after the last site generation: $ ".magenta - jekyll 'clean' - puts "Clean!".green + print 'Cleaning after the last site generation: $ '.magenta + sh 'bundle exec jekyll clean' + puts 'Clean!'.green end -desc "Install gems listed in the Gemfile" task :install do - print "Install gems listed in the Gemfile: $ ".magenta + print 'Install gems listed in the Gemfile: $ '.magenta sh 'bundle install' - puts "Installed!".green + puts 'Installed!'.green end -desc "Build the entire website" +desc 'Build the entire website' task build: %w[clean] do print 'Building the site with Jekyll: $ '.magenta - jekyll 'build --verbose' + sh 'bundle exec jekyll build --verbose --trace' puts 'Built!'.green end - -desc "Checkout to the master branch" -task :to_master do - print 'Checking out the branch to master: $ '.magenta - sh 'git checkout master' -end \ No newline at end of file diff --git a/rakelib/jekyll.rb b/rakelib/jekyll.rb deleted file mode 100644 index 98481da03ef..00000000000 --- a/rakelib/jekyll.rb +++ /dev/null @@ -1,16 +0,0 @@ -module JekyllRake - ## Run Jekyll - def jekyll(options) - sh "bundle exec jekyll #{options}" - end - - ## Jekyll preview - def preview(options = '') - jekyll('serve -I -o ' + options) - end - - ## Include local config to preview - def preview_local - preview('--config _config.yml,_config.local.yml') - end -end \ No newline at end of file diff --git a/rakelib/preview.rake b/rakelib/preview.rake index 727fcd1c23f..d9a20fdafd9 100644 --- a/rakelib/preview.rake +++ b/rakelib/preview.rake @@ -1,7 +1,9 @@ +# frozen_string_literal: true + namespace :preview do - desc 'Preview the entire devdocs locally' - task all: %w[install clean] do - puts "Generating the entire devdocs locally ... ".magenta - preview - end -end \ No newline at end of file + desc 'Preview the entire devdocs locally' + task all: %w[install clean] do + print 'Enabled the default configuration: $ '.magenta + sh 'bundle exec jekyll serve --incremental --open-url --livereload --trace' + end +end diff --git a/rakelib/rake-helper.rb b/rakelib/rake-helper.rb deleted file mode 100644 index fddeff1e5c0..00000000000 --- a/rakelib/rake-helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'html-proofer' -require 'kramdown' -require 'find' -require 'launchy' -require 'colorator' - -require_relative './jekyll.rb' -require_relative './converter.rb' -require_relative './proofer.rb' \ No newline at end of file