-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Resolve intra-doc links on additional documentation for re-exports in lexical scope #77519
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
One suggestion @Nemo157 had was to add a new |
This seems to have worked pretty well. |
It works! Just need to add test cases. |
The FIXME by the new behavior in intra-doc links will break a lot of code in practice, see e.g. https://docs.rs/async-compression/0.3.5/src/async_compression/lib.rs.html#1-240. Another alternative is to combine all consecutive attributes with the same module id into the same markdown link. I don't plan to support that sort of inter-dependence across re-exports, though. |
This comment has been minimized.
This comment has been minimized.
5f60702
to
3f84863
Compare
This is ready for review. |
- Add `parent_module` to `DocFragment` - Require the `parent_module` of the item being inlined - Preserve the hir_id for ExternCrates so rustdoc can find the parent module later - Take an optional `parent_module` for `build_impl` and `merge_attrs`. Preserve the difference between parent modules for each doc-comment. - Support arbitrarily many re-exports in from_ast. In retrospect this is probably not used and could be simplified to a single `Option<(Attrs, DefId)>`. - Don't require the parent_module for all `impl`s, just inlined items In particular, this will be `None` whenever the attribute is not on a re-export. - Only store the parent_module, not the HirId When re-exporting a re-export, the HirId is not available. Fortunately, `collect_intra_doc_links` doesn't actually need all the info from a HirId, just the parent module.
This distinguishes between documentation on the original from docs on the re-export
- Make the parent module conditional on whether the docs are on a re-export - Make `resolve_link` take `&Item` instead of `&mut Item` Previously the borrow checker gave an error about multiple mutable borrows, because `dox` borrowed from `item`. - Fix `crate::` for re-exports `crate` means something different depending on where the attribute came from. - Make it work for `#[doc]` attributes too This required combining several attributes as one so they would keep the links.
Thanks! @bors: r+ |
📌 Commit e39a860 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
Thanks! This is working well except for #77783. |
Update intra-doc link documentation to match the implementation r? `@Manishearth` cc `@camelid` `@m-ou-se` Relevant PRs: - rust-lang#74489 - rust-lang#80181 - rust-lang#76078 - rust-lang#77519 - rust-lang#73101 Relevant issues: - rust-lang#78800 - rust-lang#77200 - rust-lang#77199 / rust-lang#54191 I haven't documented things that I consider 'just bugs', like rust-lang#77732, but I have documented features that aren't implemented, like rust-lang#78800.
Fixes #77254.
Preserve the parent module of
DocFragment
sAdd
parent_module
toDocFragment
Require the
parent_module
of the item being inlinedPreserve the hir_id for ExternCrates so rustdoc can find the parent module later
Take an optional
parent_module
forbuild_impl
andmerge_attrs
.Preserve the difference between parent modules for each doc-comment.
Support a single additional re-exports in from_ast. Originally this took a vec but I ended up not using it.
Don't require the parent_module for all
impl
s, just inlined itemsIn particular, this will be
None
whenever the attribute is not on are-export.
Only store the parent_module, not the HirId
When re-exporting a re-export, the HirId is not available. Fortunately,
collect_intra_doc_links
doesn't actually need all the info from aHirId, just the parent module.
Introduce
Divider
This distinguishes between documentation on the original from docs on the re-export.
Use the new module information for intra-doc links
Make the parent module conditional on whether the docs are on a re-export
Make
resolve_link
take&Item
instead of&mut Item
Previously the borrow checker gave an error about multiple mutable
borrows, because
dox
borrowed fromitem
.Fix
crate::
for re-exportscrate
means something different depending on where the attributecame from.
Make it work for
#[doc]
attributes tooThis required combining several attributes as one so they would keep
the links.
r? @GuillaumeGomez