Skip to content

Commit

Permalink
Move original docs rake tasks into docs namespace
Browse files Browse the repository at this point in the history
This means the full list of documentation-related rake tasks is:

rake docs              # Prepare documentation for publication on GitHub Pages
rake docs:clobber      # Remove generated documentation
rake docs:coverage     # Check documentation coverage
rake docs:ensure_cname # Ensure custom domain remains in place for docs on GitHub Pages
rake docs:ensure_js    # Ensure custom JavaScript files remain in place for docs on GitHub Pages
rake docs:generate     # Generate documentation

I've disabled the `Metrics/BlockLength` cop in the whole `Rakefile`,
because the cop seems less important in the context of a DSL like rake.
  • Loading branch information
floehopper committed Feb 24, 2025
1 parent 544b979 commit ba0d53b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:
- run: bundle exec rake test:performance
- run: MOCHA_GENERATE_DOCS=1 bundle install --gemfile=<< parameters.gemfile >>
- run: RUBYOPT=--disable-frozen-string-literal MOCHA_GENERATE_DOCS=1 rake yardoc docs:coverage
- run: RUBYOPT=--disable-frozen-string-literal MOCHA_GENERATE_DOCS=1 rake docs docs:coverage
lint:
docker:
- image: ruby:3.3
Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ Naming/FileName:
- lib/mocha/ruby_version.rb
- lib/mocha/macos_version.rb
- test/test_helper.rb

Metrics/BlockLength:
Exclude:
- "Rakefile"
44 changes: 22 additions & 22 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ task 'test' do
end
end

namespace 'test' do # rubocop:disable Metrics/BlockLength
namespace 'test' do
desc 'Run unit tests'
Rake::TestTask.new('units') do |t|
t.libs << 'test'
Expand Down Expand Up @@ -123,31 +123,28 @@ end
if ENV['MOCHA_GENERATE_DOCS']
require 'yard'

desc 'Remove generated documentation'
task 'clobber_yardoc' do
`rm -rf ./docs`
end

desc 'Generate documentation'
YARD::Rake::YardocTask.new('yardoc') do |task|
task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
end
namespace :docs do
desc 'Remove generated documentation'
task :clobber do
`rm -rf ./docs`
end

desc 'Ensure custom domain remains in place for docs on GitHub Pages'
task 'checkout_docs_cname' do
`git checkout docs/CNAME`
end
desc 'Generate documentation'
YARD::Rake::YardocTask.new(:generate) do |task|
task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
end

desc 'Ensure custom JavaScript files remain in place for docs on GitHub Pages'
task 'checkout_docs_js' do
`git checkout docs/js/app.js`
`git checkout docs/js/jquery.js`
end
desc 'Ensure custom domain remains in place for docs on GitHub Pages'
task :ensure_cname do
`git checkout docs/CNAME`
end

desc 'Generate documentation'
task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
desc 'Ensure custom JavaScript files remain in place for docs on GitHub Pages'
task :ensure_js do
`git checkout docs/js/app.js`
`git checkout docs/js/jquery.js`
end

namespace :docs do
desc 'Check documentation coverage'
task :coverage do
stats_output = `yard stats --list-undoc`
Expand All @@ -166,6 +163,9 @@ if ENV['MOCHA_GENERATE_DOCS']
end
end
end

desc 'Prepare documentation for publication on GitHub Pages'
task 'docs' => %w[docs:clobber docs:generate docs:ensure_cname docs:ensure_js]
end

task 'release' => ['default', 'rubygems:release']

0 comments on commit ba0d53b

Please sign in to comment.