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

Use a proper lexer for hiding code in doctests #84478

Closed
jyn514 opened this issue Apr 23, 2021 · 2 comments · Fixed by #84511
Closed

Use a proper lexer for hiding code in doctests #84478

jyn514 opened this issue Apr 23, 2021 · 2 comments · Fixed by #84511
Labels
A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 23, 2021

Right now, rustdoc uses line-by-line heuristics to tell if a line should be hidden. That has false positives with multi-line strings, e.g.

let s = "hello
# because why not?";

and soon, after #84445,

let s = "hello
#because why not?";

It would be nice to use a proper lexer so we can detect where strings start and end instead of having to do custom "parsing".

Originally posted by @GuillaumeGomez in #84445 (comment)

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-doctests Area: Documentation tests, run by rustdoc labels Apr 23, 2021
@SergioBenitez
Copy link
Contributor

SergioBenitez commented Apr 24, 2021

Please note that this is a breaking change. What's more, this change would make it impossible to hide a multi-line string in a doc comment:

# let s = "hello\
# there";

Please see my suggestion in #84502 (comment) which doesn't suffer from this issue.

@jyn514
Copy link
Member Author

jyn514 commented Jun 6, 2021

I don't think this is important enough to spend time on an RFC.

@jyn514 jyn514 closed this as completed Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants