This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] NFC allow Format.h to be clang-formatted but still maintain the same doc layout in ClangFormatStyleOptions.rst
ClosedPublic

Authored by MyDeveloperDay on Nov 7 2019, 8:44 AM.

Details

Summary

Format.h is used to generate ClangFormatStyleOptions.rst, the layout of the comments is critical to the rst file. Accidentally clang-formatting Format.h can lead to the .rst changing.

This revision simply add // clang-format off/on statement around the areas who formatting needs to be maintained, mainly around the options that are related to what happens when the line breaks due to ColumnLimit (which is what is happening to the comment)

This allows Format.h to be clang-formatted without causing a change in the documentation when dump_format_style.py is rerun, which is also part of the revision.

Diff Detail

Event Timeline

MyDeveloperDay created this revision.Nov 7 2019, 8:44 AM
clang/include/clang/Format/Format.h
1309

Can this documentation be formatted in a way that avoids clang-format reformatting it? It doesn't look like it depends on long lines like the other bits in this change.

MyDeveloperDay marked an inline comment as done.Nov 8 2019, 6:35 AM
MyDeveloperDay added inline comments.
clang/include/clang/Format/Format.h
1309

It's this line..

it turns:

When ``false``, use the same indentation level as for the switch statement.
Switch statement body is always indented one level more than case labels.

into:

When ``false``, use the same indentation level as for the switch
statement. Switch statement body is always indented one level more than
case labels.

My assumption was that the author wanted the "Switch statement.." to be a new paragraph, but if we don't mind then we could lose this one

clang/include/clang/Format/Format.h
1309

The HTML is no different. If the author wanted a separate paragraph, I suspect that person would have used two line breaks. I would reformat this one and remove the clang-format switches.

MyDeveloperDay marked an inline comment as done.Nov 8 2019, 7:05 AM
MyDeveloperDay added inline comments.
clang/include/clang/Format/Format.h
1309

Sounds good, you are quite correct, the text is all on the same line anyway

remove one set of // clang-format on/off that has no visual impact to the html

NOTE: it does change the baseline .rst which is why its been added into the review.
clang/docs/ClangFormatStyleOptions.rst
1594

This generated rst is not correct. See below.

clang/include/clang/Format/Format.h
1316

\code needs to be on its own line. Otherwise you get the incorrectly generated .rst I mentioned earlier.

MyDeveloperDay marked 4 inline comments as done.
This revision is now accepted and ready to land.Nov 8 2019, 11:15 AM
This revision was automatically updated to reflect the committed changes.