Skip to content

Rake task to generate rubocop docs

What does this MR do and why?

This MR adds a way to generate documentation for all our RuboCop cops automatically, which can be viewed at http://gitlab-org.gitlab.io/gitlab/rubocop-docs

It pulls in some existing code from RuboCop to generate the Markdown files and copies these to the right location so that Hugo can generate a static GitLab Pages site for them. Originally the RuboCop code, would only generate adoc files. This has been adjusted here to generate md instead, so that it's compatible with Hugo (originally it was done to work with our docs, but we changed our approach away from storing these files with the rest of our docs). The plan is to get these changes merged upsteam, since others could benefit from having a Markdown generator. If they are not merged upstream, we can then update the code to follow our RuboCop rules, instead of ignoring them.

What's left after this MR

  • Share the RuboCop changes upsteam
  • Remove the "Version Added" and "Version Changed" since it doesn't make sense for GitLab internal cops.
  • Fix the warnings generated by the rubocop:docs task and improve the related docs.

References

Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshot_from_2025-02-20_10-20-03

Screenshot_from_2025-02-20_10-19-25

Screenshot_from_2025-02-20_10-18-50

How to set up and validate locally

  1. Install Hugo
  2. Go to the RuboCop docs hugo dir: cd rubocop/docs-hugo/
  3. Run hugo server
  4. Visit http://localhost:1313/gitlab/rubocop-docs/ and explore the new pages.
  5. Visit http://localhost:1313/gitlab/rubocop-docs/cops_gitlab/#gitlabdelegatepredicatemethods
  6. Edit the comment for rubocop/cop/gitlab/delegate_predicate_methods.rb
  7. Run rails rubocop:docs from the project root.
  8. See the change reflected in http://localhost:1313/gitlab/rubocop-docs/cops_gitlab/#gitlabdelegatepredicatemethods

Job artifacts

Edited by Keeyan Nejad

Merge request reports

Loading