Skip to content

Fix ref links in main page #285

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

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

jonathanhefner
Copy link
Member

@jonathanhefner jonathanhefner commented Aug 17, 2023

The main page reuses an already-processed file. All of the ref links in that file will be rendered relative to its path rather than relative to the root. For example, ref links in railties/RDOC_MAIN.md will be relative to files/railties/, so a link to ActiveRecord::Base would use ../../ActiveRecord/Base.html instead of ActiveRecord/Base.html.

This commit changes RDoc::Generator::SDoc#index to dup the processed file and override its path value such that links on the main page use the root-relative path (but links on the file's page will still use the files/-relative path).

This change also makes it unnecessary to escape occurrences of "Rails" in the main page because, with the correct href, the postprocessor will now recognize them as unintentional ref links.

The main page reuses an already-processed file.  All of the ref links in
that file will be rendered relative to its path rather than relative to
the root.  For example, ref links in `railties/RDOC_MAIN.md` will be
relative to `files/railties/`, so a link to `ActiveRecord::Base` would
use `../../ActiveRecord/Base.html` instead of `ActiveRecord/Base.html`.

This commit changes `RDoc::Generator::SDoc#index` to dup the processed
file and override its `path` value such that links on the main page use
the root-relative path (but links on the file's page will still use the
`files/`-relative path).

This change also makes it unnecessary to escape occurrences of "Rails"
in the main page because, with the correct `href`, the postprocessor
will now recognize them as unintentional ref links.
@jonathanhefner jonathanhefner force-pushed the main-page-fix-ref-links branch from c4a1373 to d0ce1ca Compare August 17, 2023 21:32
@jonathanhefner jonathanhefner merged commit 1575e97 into rails:main Aug 17, 2023
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.

1 participant