This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.
ClosedPublic

Authored by curdeius on Mar 17 2022, 8:14 AM.

Diff Detail

Event Timeline

curdeius created this revision.Mar 17 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 8:14 AM
curdeius requested review of this revision.Mar 17 2022, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 8:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This is an alternative to D121890.
This patch goes a step further and adds a script to update the .rst file.
It isn't invoked during the build, one needs to run it manually (just as dump_format_style.py).

There's also a validation option, currently set to column width at 95 chars. I fixed some very long lines but did't try to fix everything (it would need changing help message which is used not only by clang-format).

curdeius updated this revision to Diff 416185.Mar 17 2022, 8:20 AM

Update file comment.

curdeius edited the summary of this revision. (Show Details)Mar 17 2022, 8:26 AM
clang/tools/clang-format/ClangFormat.cpp
105

Couldn't one split the string in python? I think an arbitrary position to split the help isn't nice. I for one have often the terminal over half the monitor spread, sometimes even the complete monitor.

MyDeveloperDay accepted this revision.Mar 18 2022, 12:16 AM

Wow! Now that’s what I’m talking about!! Awesome! Thank you so much!

This revision is now accepted and ready to land.Mar 18 2022, 12:16 AM
curdeius added inline comments.Mar 18 2022, 1:18 AM
clang/tools/clang-format/ClangFormat.cpp
105

Well, these strings are used to generate the output of clang-format --help, which is, IIUC, supposed to produce a 80-column output.
I fully agree that it would be better to have it splitted automatically depending on the output screen width, but we're not there yet unfortunately.
And .rst file is just the reflection of what --help outputs.

sstwcw added a subscriber: sstwcw.Mar 21 2022, 3:52 PM
sstwcw added inline comments.
clang/docs/tools/dump_format_help.py
29

You intentionally did not write build/bin/clang-format to accommodate people who build in other directories, right? Sorry this comment is late.

If nobody is against this patch. I'll land it soon, probably tomorrow.

clang/docs/tools/dump_format_help.py
29

I wanted to be coherent with the generate_formatted_state.py script that calls clang-format from PATH as well.
A user that builds elsewhere needs to set PATH when executing the script to use clang-format of their choice.

MyDeveloperDay added inline comments.Mar 22 2022, 8:49 AM
clang/docs/tools/dump_format_help.py
29

you definitely can't assume "build", for me my build directory is build_ninja

This revision was landed with ongoing or failed builds.Mar 23 2022, 5:18 AM
This revision was automatically updated to reflect the committed changes.
sstwcw added a comment.Apr 9 2022, 3:51 AM

It looks like you forgot to chmod +x.

It looks like you forgot to chmod +x.

Added in f67e3f6.