Resolve intra-doc links on additional documentation for re-exports in lexical scope#77519
Resolve intra-doc links on additional documentation for re-exports in lexical scope#77519bors merged 3 commits intorust-lang:masterfrom
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
DocFragmentsAdd
parent_moduletoDocFragmentRequire the
parent_moduleof the item being inlinedPreserve the hir_id for ExternCrates so rustdoc can find the parent module later
Take an optional
parent_moduleforbuild_implandmerge_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
impls, just inlined itemsIn particular, this will be
Nonewhenever 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_linksdoesn't actually need all the info from aHirId, just the parent module.
Introduce
DividerThis 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_linktake&Iteminstead of&mut ItemPreviously the borrow checker gave an error about multiple mutable
borrows, because
doxborrowed fromitem.Fix
crate::for re-exportscratemeans 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