Skip to content

Commit

Permalink
Have cut_release handle "config/default" and generate cops doc
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Nov 20, 2021
1 parent 3ecda94 commit 19369de
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
- run:
name: Check documentation syntax
command: bundle exec rake documentation_syntax_check
- run:
name: Build documentation and verify that doc files are in sync
command: bundle exec rake verify_cops_documentation

workflows:
build:
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ RuboCop::RakeTask.new(:internal_investigation)

task default: %i[
documentation_syntax_check
generate_cops_documentation
spec
internal_investigation
]
Expand Down
18 changes: 4 additions & 14 deletions tasks/cops_documentation.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,14 @@ YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
task.options = ['--no-output']
end

desc 'Generate docs of all cops departments'
task generate_cops_documentation: :yard_for_generate_documentation do
task update_cops_documentation: :yard_for_generate_documentation do
deps = ['Rails']
CopsDocumentationGenerator.new(departments: deps).call
end

desc 'Verify that documentation is up to date'
task verify_cops_documentation: :generate_cops_documentation do
# Do not print diff and yield whether exit code was zero
sh('git diff --quiet docs') do |outcome, _|
exit if outcome

# Output diff before raising error
sh('GIT_PAGER=cat git diff docs')

warn 'The docs directory is out of sync. Run `rake generate_cops_documentation` and commit the results.'
exit!
end
desc 'Generate docs of all cops departments (obsolete)'
task :generate_cops_documentation do
puts 'Updating the documentation is now done automatically!'
end

desc 'Syntax check for the documentation comments'
Expand Down
16 changes: 16 additions & 0 deletions tasks/cut_release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ namespace :cut_release do
version.split('.').take(2).join('.')
end

# Replace `<<next>>` (and variations) with version being cut.
def update_cop_versions(_old_version, new_version)
update_file('config/default.yml') do |default|
default.gsub(/['"]?<<\s*next\s*>>['"]?/i,
"'#{version_sans_patch(new_version)}'")
end
end

def new_version_changes
changelog = File.read('CHANGELOG.md')
_, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4)
new_changes
end

def update_file(path)
content = File.read(path)
File.write(path, yield(content))
end

def user_links(text)
names = text.scan(/\[@(\S+)\]\[\]/).map(&:first).uniq
names.map { |name| "[@#{name}]: https://github.com/#{name}" }
Expand All @@ -66,6 +79,9 @@ namespace :cut_release do
Bump::Bump.run(release_type, commit: false, bundle: false, tag: false)
new_version = Bump::Bump.current

update_cop_versions(old_version, new_version)
Rake::Task['update_cops_documentation'].invoke

add_header_to_changelog(new_version)
create_release_notes(new_version)
update_antora_yml(new_version)
Expand Down

0 comments on commit 19369de

Please sign in to comment.