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

wrap_comments shouldn't imply format_doc_comments #3417

Closed
RReverser opened this issue Feb 25, 2019 · 6 comments · Fixed by #3535
Closed

wrap_comments shouldn't imply format_doc_comments #3417

RReverser opened this issue Feb 25, 2019 · 6 comments · Fixed by #3535
Labels
a-comments good first issue Issues up for grabs, also good candidates for new rustfmt contributors

Comments

@RReverser
Copy link
Contributor

This is similar to #3209, but a bit worse IMO: currently setting either normalize_doc_attributes or wrap_comments to true implies format_doc_comments as well and reformats docs, even if format_doc_comments = false is explicitly set in the config.

@scampi scampi added good first issue Issues up for grabs, also good candidates for new rustfmt contributors a-comments labels Mar 4, 2019
@xiongmao86
Copy link
Contributor

What does format_doc_comments mean exactly? Isn't wrapping a doc comment some sort of formatting the doc comment?

And is setting wrap_comments to false but format_doc_comments to true meaning do formatting other than wrapping to the doc comments?

@RReverser
Copy link
Contributor Author

The description is somewhat vague, but from the included example (https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#format_doc_comments) and own experience, I've assumed it means just formatting code snippets within doc comments, and should work independently from wrapping comment text.

@xiongmao86
Copy link
Contributor

xiongmao86 commented Apr 29, 2019

Reproduce with two one snippets:

wrap_comments implies format_doc_comments:

// rustfmt-wrap_comments: true

/// Foo
///
/// # Example
/// ```
/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// fn foo() {  }
/// ```
///
fn foo() {}

/// A long commment for wrapping
/// This is a long long long long long long long long long long long long long long long long long long long long sentence.
fn bar() {}

Update:
normalize_doc_attributes doesn't imply format_doc_comments in the current rustfmt.

@scampi
Copy link
Contributor

scampi commented May 1, 2019

@RReverser You are correct and that is what it should do. Maybe we can review the description of this option too.

@xiongmao86
Copy link
Contributor

@RReverser, @scampi: Perhaps change format_doc_comment to format_code_in_doc_comment?

@RReverser
Copy link
Contributor Author

@xiongmao86 That sounds reasonable to me.

@scampi scampi changed the title format_doc_comments is invoked even when set to false wrap_comments shouldn't imply format_doc_comments May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments good first issue Issues up for grabs, also good candidates for new rustfmt contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants