Conversation
|
These commits modify Please ensure that if you've changed the output:
cc @obi1kenobi rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing |
|
rustbot has assigned @GuillaumeGomez. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
9c1da60 to
2f5048f
Compare
This comment has been minimized.
This comment has been minimized.
2f5048f to
fcbb219
Compare
This comment has been minimized.
This comment has been minimized.
fcbb219 to
605cfeb
Compare
This comment has been minimized.
This comment has been minimized.
605cfeb to
97e368b
Compare
This comment has been minimized.
This comment has been minimized.
97e368b to
e1cc402
Compare
| pub links: HashMap<String, Id>, | ||
| /// The full markdown docstring of this item. Empty if there is no documentation at all, | ||
| /// `vec![Doc { text: "" }]` if there is some documentation but it is empty (EG `#[doc = ""]`). | ||
| pub docs: Vec<Doc>, |
There was a problem hiding this comment.
I'm curious, when might this Vec have more than one element?
It might be useful to include an example in the doc comment, for ease of use.
There was a problem hiding this comment.
Good call. I've added an example and some description to the docs.
The full markdown docstring of this item. Empty if there is no documentation at all,
vec![Doc { text: "" }]if there is some documentation but it is empty (EG#[doc = ""]),
and multiple items if a reexport and the original both have docstrings./// Reexport docs pub use Thing1 as Thing2; /// Original docs pub struct Thing1;{ "name": "Thing2", "docs": [ { "text": "Reexport docs", "links": [] }, { "text": "Original docs", "links": [] }, ], ... }
There was a problem hiding this comment.
Ah interesting! Nice, thank you.
Is any particular order of elements guaranteed? That's the only remaining thing I'd consider adding.
There was a problem hiding this comment.
Is any particular order of elements guaranteed?
It's guaranteed to be in the same order that the HTML frontend shows it. It always puts the reexport first and the original second, but the reexports section of the rustdoc book doesn't seem to promise that.
Even if it did, I'm not sure how it would help, because there's no way to distinguish case 1 from case 2:
// case 1: doc comment on reexport
struct Original1;
/// foo
pub use Original1 as Reexport1;
// case 2: doc comment on original
/// foo
struct Original2;
pub use Original2 as Reexport2;Both of these generate "docs":[{"text":"foo","links":[]}]. To fix that, we'd need to add an explicit marker, at which point we might as well explicitly mark the two-comment case.
There was a problem hiding this comment.
Good to know, thank you. It might be good to include a "No particular order is guaranteed" line in the doc comment, to ward off questions and/or Hyrum's Law. I'm not sure if the HTML guarantee is explicitly intended or accidental / implementation-defined, and it might not be worth including either way.
This comment has been minimized.
This comment has been minimized.
This change is a pre-requisite for LaTeX support, because the markdown parser doesn't support enabling and disabling extensions in the middle of a document, and there's no way to add that. This means string concatenating a document that has LaTeX Math disabled with a document that has it enabled can't be done. As part of this change, a bug related to intra-doc links is fixed. This shows up when the reexport and the item both have intra-doc links with the same visible path, but where they resolve to different items. The bug is demonstrated in `tests/rustdoc-html/reexport/link-with-same-name-but-different-destination.rs`. The other test case changes demonstrate that this is, technically, a breaking change. When I ran a Crater test for docs that rely on this behavior, though, it seemed most authors weren't relying on it.
8f06097 to
e13bbd3
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. |
This comment has been minimized.
This comment has been minimized.
e13bbd3 to
f672f66
Compare
This change is a pre-requisite for LaTeX support, because the markdown parser doesn't support enabling and disabling extensions in the middle of a document, and there's no way to add that. This means string concatenating a document that has LaTeX Math disabled with a document that has it enabled can't be done.
As part of this change, a bug related to intra-doc links is fixed. This shows up when the reexport and the item both have intra-doc links with the same visible path, but where they resolve to different items. The bug is demonstrated in
tests/rustdoc-html/reexport/link-with-same-name-but-different-destination.rs.The other test case changes demonstrate that this is, technically, a breaking change. When I ran a Crater test for docs that rely on this behavior, though, it seemed most authors weren't relying on it.