Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make verify docs an rspec test #99

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,3 @@ jobs:
ruby-version: head
- name: Run style checks
run: bundle exec rubocop
documentation:
runs-on: ubuntu-latest
name: CLI Documentation
steps:
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
- name: Set up Ruby
uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
with:
bundler-cache: true
ruby-version: head
- name: Check autogenerated documentation
run: ruby docs/verify_docs.rb
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ GEM
nokogiri (1.15.3)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
packs-specification (0.0.9)
packs-specification (0.0.10)
sorbet-runtime
parallel (1.23.0)
parse_packwerk (0.19.3)
Expand Down
41 changes: 0 additions & 41 deletions docs/verify_docs.rb

This file was deleted.

44 changes: 44 additions & 0 deletions spec/verify_docs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# typed: false

RSpec.describe Packs, :skip_chdir_to_tmpdir do
let(:readme) do
Pathname.new('README.md')
end

let(:actual_content) { readme.read }

let(:expected_content) do
all_docs = []
Packs::CLI.all_commands.each do |_command_name, command|
all_docs << <<~DOCUMENTATION
## #{command.description}
`bin/packs #{command.usage}`

DOCUMENTATION

if command.long_description
all_docs << command.long_description
all_docs << "\n"
end
end

new_autogenerated_content = <<~MARKDOWN.chomp
## CLI Documentation
#{all_docs.join}
## Releasing
MARKDOWN
new_content = readme.read.gsub(/## CLI Documentation.*?## Releasing/m, new_autogenerated_content)

new_content
end

describe 'CLI Documentation' do
it 'is up to date' do
if ENV['OVERWRITE']
readme.write(expected_content)
else
expect(actual_content).to eq(expected_content), 'README.md is out of date. Use OVERWRITE=1 bundle exec rspec'
end
end
end
end