Fix relative extern URL depth on source pages#153160
Fix relative extern URL depth on source pages#153160arferreira wants to merge 2 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
372a8c7 to
d71f355
Compare
|
Reminder, once the PR becomes ready for a review, use |
d71f355 to
bfeb902
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
0f28723 to
6017689
Compare
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
6017689 to
59b37bb
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
… r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to #152977. r? @notriddle
|
💔 Test for e95d0cd failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
…-root-path, r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to rust-lang#152977. r? @notriddle
…-root-path, r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to rust-lang#152977. r? @notriddle
Rollup of 7 pull requests Successful merges: - #153736 (add test that an incomplete feature emits a warning) - #153160 (Fix relative extern URL depth on source pages) - #153432 (Fix some comments about dataflow analysis.) - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`) - #153717 (unused_macro_rules switched used and unused comments) - #153748 (editorconfig: css uses tabs) - #153750 (rustc-dev-guide subtree update)
|
⌛ Testing commit 59b37bb with merge c66e4b8... Workflow: https://github.com/rust-lang/rust/actions/runs/22995536645 |
… r=notriddle Fix relative extern URL depth on source pages Source pages with `--extern-html-root-url` pointing to a relative URL like `../` were generating links with one extra `../`. So instead of `../../core/iter/index.html` you'd get `../../../core/iter/index.html`. Took a while to notice because `htmldocck.py` uses substring matching — `../../core/` is a substring of `../../../core/` so the test passed anyway. Two root causes. `remote_url_prefix` was using `cx.current.len()` for depth, but during source rendering `cx.current` is empty — `SourceCollector` doesn't do module descent. Source pages live under `src/<crate_name>/` so the real depth is 2, not 0. On top of that, `make_href` was trying to compensate by prepending `root_path` to relative remote URLs (there was a FIXME about this), which just made it worse — `../../` + `../core/iter/` = `../../../core/iter/`. Fix: added `remote_item_depth(root_path, doc_depth)` that counts `../` segments in `root_path` when present, falls back to `doc_depth` otherwise. With the right depth in `remote_url_prefix`, `make_href` no longer needs to touch remote URLs at all — so `url_parts` now returns `is_remote = true` for all `Remote` locations. Also renamed `is_absolute` → `is_remote` since the semantics were always about "don't modify this URL", not about whether it has a scheme. Added `!has` assertions to the test so the wrong URL gets caught explicitly next time. Follow-up to #152977. r? @notriddle
|
Failed in rollup: #153761 (comment) @bors r- |
|
This pull request was unapproved. This PR was contained in a rollup (#153761), which was unapproved. Auto build was cancelled due to unapproval. Cancelled workflows: |
|
@bors try jobs=dist-x86_64-linux-alt |
|
⌛ Trying commit 1369e07 with merge 052b44b… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/22998576397 |
… r=<try> Fix relative extern URL depth on source pages try-job: dist-x86_64-linux-alt
View all comments
Source pages with
--extern-html-root-urlpointing to a relative URL like../were generating links with one extra../. So instead of../../core/iter/index.htmlyou'd get../../../core/iter/index.html. Took a while to notice becausehtmldocck.pyuses substring matching —../../core/is a substring of../../../core/so the test passed anyway.Two root causes.
remote_url_prefixwas usingcx.current.len()for depth, but during source renderingcx.currentis empty —SourceCollectordoesn't do module descent. Source pages live undersrc/<crate_name>/so the real depth is 2, not 0. On top of that,make_hrefwas trying to compensate by prependingroot_pathto relative remote URLs (there was a FIXME about this), which just made it worse —../../+../core/iter/=../../../core/iter/.Fix: added
remote_item_depth(root_path, doc_depth)that counts../segments inroot_pathwhen present, falls back todoc_depthotherwise. With the right depth inremote_url_prefix,make_hrefno longer needs to touch remote URLs at all — sourl_partsnow returnsis_remote = truefor allRemotelocations. Also renamedis_absolute→is_remotesince the semantics were always about "don't modify this URL", not about whether it has a scheme.Added
!hasassertions to the test so the wrong URL gets caught explicitly next time.Follow-up to #152977.
r? @notriddle