Skip to content
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

libstd docs of re-exported macros are unformatted #26560

Closed
durka opened this issue Jun 25, 2015 · 12 comments
Closed

libstd docs of re-exported macros are unformatted #26560

durka opened this issue Jun 25, 2015 · 12 comments
Labels
C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@durka
Copy link
Contributor

durka commented Jun 25, 2015

One example is the unreachable! macro, though I think I've seen it elsewhere. The documention of the macro in libcore is fine, but the docs of the same macro in libstd have the source formatting all weird, and the actual [src] link is broken.

@durka
Copy link
Contributor Author

durka commented Jun 25, 2015

Of course you don't need the [src] link for a macro, but that's another issue!

@sfackler
Copy link
Member

The formatting issue's a dup of #20923. Not sure if the src link being broken's been filed.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 26, 2015
@durka durka mentioned this issue Oct 28, 2015
22 tasks
@durka
Copy link
Contributor Author

durka commented Dec 16, 2015

The src link at the re-exported macro is gone, so closing.

@durka durka closed this as completed Dec 16, 2015
@cbreeden
Copy link
Contributor

cbreeden commented Jan 9, 2017

I think this issue is relevant again. The solution for the dup was to refactor error reporting system, which doesn't solve the formatting issues in the docs.

@durka durka reopened this Jan 10, 2017
@durka durka changed the title some macro docs are partly broken in libstd libstd docs of re-exported macros are unformatted Jan 10, 2017
@cbreeden
Copy link
Contributor

cbreeden commented Jan 10, 2017

I suspect that a quick solution to this problem may be to remove (or replace with ' ') all \n here https://github.com/rust-lang/rust/blob/master/src/librustdoc/clean/mod.rs#L2813.

At least it would put everything onto the same line.

@durka
Copy link
Contributor Author

durka commented Jan 10, 2017

I don't think that's a great fix. I think the problem is that re-exported macros are stored into metadata in tokenized form, losing the original source formatting.

@QuietMisdreavus
Copy link
Member

It looks more like that line you found is what prints each rule. Digging further, it seems to go through a ToSource trait which eventually calls span_to_snippet, which is where I would expect the formatting to come from.

@cbreeden
Copy link
Contributor

cbreeden commented Jan 10, 2017

I'm a little surprised that the highlighting doesn't work correctly, after looking at https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/highlight.rs#L245. I don't believe there is much we can do about the formatting that comes from span_to_snippet given how macros are re-exported; though this might change once Macros 2.0 is here and so macros are given a bona fide path.

Until then I think the solution would be to manually handle the formatting given a TokenStream. Last night I was going to try to do some debugging to see why the $ formatting given in the docs above didn't trigger, but didn't get around to it.

@chordowl
Copy link
Contributor

I ran across another manifestation of this today: the reexported version of Entry in std::collections::btree_map::Entry uses where clauses for lifetime bounds, while the original version of Entry in collections::btree_map doesn't; it seems like this is not strictly limited to macros.

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: the formatting is still a bit strange; the src links work great though.

@jyn514
Copy link
Member

jyn514 commented Mar 25, 2021

I think this may be a duplicate of #36722.

@jyn514
Copy link
Member

jyn514 commented Apr 8, 2021

This is fixed on master.
image

@jyn514 jyn514 closed this as completed Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants