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
How to set up and validate locally
- Install Hugo
- Go to the RuboCop docs hugo dir:
cd rubocop/docs-hugo/
- Run
hugo server
- Visit http://localhost:1313/gitlab/rubocop-docs/ and explore the new pages.
- Visit http://localhost:1313/gitlab/rubocop-docs/cops_gitlab/#gitlabdelegatepredicatemethods
- Edit the comment for rubocop/cop/gitlab/delegate_predicate_methods.rb
- Run
rails rubocop:docs
from the project root. - See the change reflected in http://localhost:1313/gitlab/rubocop-docs/cops_gitlab/#gitlabdelegatepredicatemethods
Job artifacts
- You can see the job to generate the site completed successfully, and that the artifacts include the HTML pages for the site: https://gitlab.com/gitlab-org/gitlab/-/jobs/9195357578