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

Fix sub-department cop doc generation #10013

Merged
merged 1 commit into from Aug 15, 2021

Conversation

pirj
Copy link
Member

@pirj pirj commented Aug 14, 2021

If you go to https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html, links to the second-level cops docs are broken. The last one is correct, https://docs.rubocop.org/rubocop-rspec/2.0/cops_rspec.html, while others have anchors, e.g. https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html#cops_capybara.adoc. This is probably due to cops_docs.adoc vs cops_docs/ name clash.

Suspect: https://docs.antora.org/antora/2.3/page/page-id/#important

Ideally, we would generate cops_rspec_capybara.adoc instead of cops_rspec/capybara.adoc.

Other RuboCop extensions don't seem to make use of sub-departments, and will be unaffected by this change.

Related PR rubocop/rubocop-rspec#1183


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • [-] Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • [-] Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • [-] Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

If you go to https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html, links to the second-level cops docs are broken. The last one is correct, https://docs.rubocop.org/rubocop-rspec/2.0/cops_rspec.html, while others have anchors, e.g. https://docs.rubocop.org/rubocop-rspec/2.0/upgrade_to_version_2.html#cops_capybara.adoc. This is probably due to `cops_docs.adoc` vs `cops_docs/` name clash.

Suspect: https://docs.antora.org/antora/2.3/page/page-id/#important

Ideally, we would generate `cops_rspec_capybara.adoc` instead of `cops_rspec/capybara.adoc.`

Other RuboCop extensions don't seem to make use of sub-departments, and will be unaffected by this change.
@pirj pirj mentioned this pull request Aug 14, 2021
3 tasks
@@ -8,7 +8,7 @@ module Documentation

# @api private
def department_to_basename(department)
"cops_#{department.downcase}"
"cops_#{department.to_s.downcase.tr('/', '_')}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is to_s needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. department is surprisingly a Symbol. downcase (not less surprisingly to me) works on Symbol, but tr doesn't.
I don't have a strong preference where to add .to_s, before or after downcase.
Also, I'll be happy to extract this transformation to a variable for better readability if you see fit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it! This is fine, thank you for your explanation.

@koic koic merged commit 087bc6c into rubocop:master Aug 15, 2021
@pirj pirj deleted the fix-subdepartment-cop-docs-generation branch August 15, 2021 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants