-
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
don't let rustdoc get confused by text "fn main" in a line comment #44713
don't let rustdoc get confused by text "fn main" in a line comment #44713
Conversation
zackmdavis
commented
Sep 20, 2017
•
edited
Loading
edited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much, i love it! Just one little nit and this should be good to go!
src/librustdoc/test.rs
Outdated
line | ||
} | ||
}) | ||
.find(|code| code.contains("fn main")).is_some(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this line .any(|code| code.contains("fn main"))
instead? That's equivalent and removes one level of method chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed a great improvement. I just have a concern on this (or the previous check):
Imagine you wrote
fn main
(for some reasons...). Or if you write "fn main" in a string (for some other reasons...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, this isn't a "complete" fix, but it's still a start. A "proper" fix would involve throwing libsyntax or the like at the doctest and scanning that for a function called "main". But for now, this is much better than we have at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking about a partial fix involving a stupid parser creating basic tokens and all. But still bigger than this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that rustdoc instead gain something like allowing lib
where we have rust
(i.e., in the language part after "```") today. The more work we do for the "common case" the worse rustdoc's performance on codebases with large amounts of doc tests gets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. There's no ideal solution in here.
10d418a
to
0b2bac4
Compare
Force-push addresses @QuietMisdreavus's |
Sorry for letting this get stale! To get this put in, i won't force you to wrangle libsyntax to do Actual Parsing. I'll go ahead and accept this PR, but i want to leave #21299 open so we can track a Proper Solution for it. To that end, can you add a comment " |
This is in the matter of rust-lang#21299.
0b2bac4
to
9f68d62
Compare
(updated) |
@bors r+ Thanks so much! Sorry about the delay! |
📌 Commit 9f68d62 has been approved by |
…aks_tests, r=QuietMisdreavus don't let rustdoc get confused by text "fn main" in a line comment ~~~Resolves~~~ (edited) partially addresses #21299. ![rustdoc_fn_main](https://user-images.githubusercontent.com/1076988/30630993-9aeecc4a-9d97-11e7-8e56-2b973f23f683.png) r? @QuietMisdreavus
☀️ Test successful - status-appveyor, status-travis |