-
Notifications
You must be signed in to change notification settings - Fork 2
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
format hidden code #3
base: master
Are you sure you want to change the base?
Conversation
there's a bug with |
Hi there, thanks for the PR, always nice to have more people participate 😄 A few things I'd like to discuss before reviewing. To my knowledge So the current behavior (i.e. no formatting and Could there be any disadvantages in doing this formatting? Any way it can introduce AST breaking changes? Perhaps it adds unwanted indentation to the visible code if the visible code is wrapped in a hidden function? I'm a Rust n00b and not well-versed in community standards and best practices, so I'd also love to hear if other community members and potential users (so far only @lambda-fairy to my knowledge, haha) have thoughts on this. |
I don't see the example you mention where the
I don't believe there are any disadvantages. rustfmt would fail on invalid code and not change anything. internally in rustdoc test it is just stripping and replacing the |
Lol, sorry for this, you're completely right, don't know exactly what I was thinking... 😄 Ok so a question: Let's imagine there actually is an indented hidden line 😄 Which of the following three is the most "standard"? 1.```rust
fn main() {
# println!("Hello ");
println!("World!");
}
``` 2.```rust
fn main() {
# println!("Hello ");
println!("World!");
}
``` 3.```rust
fn main() {
# println!("Hello ");
println!("World!");
}
``` From what you wrote, I understand the third form is not even correct? If not then I definitely need to revert the last change I made to |
Btw. this mdBook example does indent unhidden code in a hidden function, unlike the rustdoc example, so it seems both happen in the wild. |
I found a pretty bad bug I need to fix. I assumed that rustfmt would not collapse the special comments on to an existing line, but that's not always the case. I have a failing test. |
It would make the most sense to me that lines are only hidden if the very first character is an octothorpe. I think number 1 reads the nicest as the indent is consistent for actual statements. |
This will allow hidden code to be formatted the same as not hidden.
I did not implement any configuration options so let me know if you think this opinionated default is alright.
I'm going to use this on the https://github.com/amethyst/amethyst docs.