Infer title and heading from comment #223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some classes in Rails have a h1 heading defined in the RDoc comment.
For example:
https://github.com/rails/rails/blob/4e1fe73028f4b01c8e5179989511b21925f70b20/activesupport/lib/active_support/current_attributes.rb#L8
https://github.com/rails/rails/blob/4e1fe73028f4b01c8e5179989511b21925f70b20/actionpack/lib/action_controller/metal/strong_parameters.rb#L1159
This makes the heading more readable especially when there are a lot of
namespaces.
For SEO it helps if all classes have a h1 heading, but having to add
them by hand is cumbersome when we can generate them instead.
By looking at the comment of the class/module we can see if it has a
h1
heading when it's starting with=
or#
. If the heading ismissing we can generate a heading with the full name of the class
instead. This will prevent us from having to add the h1 for each class
in Rails.
This change is backwards compatible and works without having to make changes in Rails.
This also adds the
@options.title
("Ruby on Rails API") to thetitle
tag of every class, which also helps with SEO.I looked at the
:title:
directive, but that only works if it hasn't been set yet and can'be overridden:https://github.com/ruby/rdoc/blob/cc40a39714d894180713032ac6049e192e72f3db/lib/rdoc/options.rb#L512-L518