Skip to content

Fix formatting generation for rustdoc code examples #35012

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

GuillaumeGomez
Copy link
Member

Now, when clicking on the Run link in the docs, the code is indented if it is put in a main function (I couldn't stand the horrible output we currently have).

r? @steveklabnik

@ollie27
Copy link
Member

ollie27 commented Jul 25, 2016

This looks like it's essentially reverting #33512 and so is bringing back #25944.

@GuillaumeGomez
Copy link
Member Author

I guess? (I didn't know it was done "correctly" before.)

@steveklabnik
Copy link
Member

/cc @rust-lang/tools

@nrc
Copy link
Member

nrc commented Jul 25, 2016

Is this just a matter of inserting \ into multi-line string lits?

@GuillaumeGomez
Copy link
Member Author

@nrc: I didn't understand your comment. Why are talking about \?

@nrc
Copy link
Member

nrc commented Jul 25, 2016

@GuillaumeGomez I might be mistaken, but my understanding was that #25944 is only an issue with multiline string lits, and that if one does

"dfasd asdfasdf \
 sdfsdf dsfsdf"

rather than

"dfasd asdfasdf
 sdfsdf dsfsdf"

Then the indentation change should not be a problem.

@GuillaumeGomez
Copy link
Member Author

Ah right. Then no, I don't see why it would break it.

@brson
Copy link
Contributor

brson commented Jul 25, 2016

sgtm

@GuillaumeGomez
Copy link
Member Author

Any news about this?

@alexcrichton
Copy link
Member

I agree with @ollie27 that this seems like it'd be regressing the fix from earlier, and as a result may not be worth it as a standalone feature.

Perhaps we could send requests to playpen which auto-format the code?

@GuillaumeGomez
Copy link
Member Author

@alexcrichton: If it's done then I'll even remove the indent/backlines when creating the URL.

@frewsxcv
Copy link
Member

frewsxcv commented Aug 8, 2016

Is it possible to separate the String of code that generates the URL from the String of code that gets doc-tested? Then the former could receive appropriate indentation without affecting the latter.

@steveklabnik
Copy link
Member

So, what's the state of this PR?

@GuillaumeGomez
Copy link
Member Author

@steveklabnik: Still waiting for @alexcrichton update on play.rust-lang.org I think?

@alexcrichton
Copy link
Member

Sorry, but what's supposed to happen?

@frewsxcv
Copy link
Member

In my opinion, I don't think we should auto format code when loading the playpen. This seems like a bug with URL generation with rustdoc.

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Aug 19, 2016

@alexcrichton: You said:

Perhaps we could send requests to playpen which auto-format the code?

So I thought something was moving in this way. Sorry if I misunderstood.

@frewsxcv: So my current PR is the "correct" way to do it I guess? :p

@alexcrichton
Copy link
Member

@GuillaumeGomez oh no I wasn't actually planning on making any changes myself, no.

@frewsxcv the problem is that this documentation:

/// ```
/// "foo \
/// bar"
/// ```

changes meaning depending on whether rustdoc snippets are auto-indented. We can auto-indent, but it changes the meaning of that string literal (the original bug)

@steveklabnik
Copy link
Member

It looks like we're not going to accept this, so I'm giving it a close. Let me know if that reading is wrong.

@GuillaumeGomez GuillaumeGomez deleted the doc_codes branch November 24, 2017 20:56
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants