This is an archive of the discontinued LLVM Phabricator instance.

[docs][clang-format] warn on \code block indentation error
ClosedPublic

Authored by FederAndInk on Oct 26 2021, 1:25 PM.

Details

Summary

There is an indentation issue in Format.h causing the html to not render correctly
It's a \code block in the documentation of SpacesInLineComment

So I fixed it, and added some warnings in clang/docs/tools/dump_format_style.py:

  • fix intentation of SpacesInLineComment
  • warn on indentation error
  • also warn on \code \endcode mismatch
  • generate precise warnings
  • fix some minor and style issues:
    • avoid confusion with the built-in type function
    • fix wrong print on os.sys.stderr (instead of sys.stderr)
    • use with as pattern for files

here is a look at the generated warnings:

> ./dump_format_style.py
../../include/clang/Format/Format.h:3448: warning: code block should be indented:
  3448 | /// before:                                   after:
  3449 | /// Minimum: 1
  3450 | /// //if (b) {                                // if (b) {
  3451 | /// //  return true;                          //   return true;
  3452 | /// //}                                       // }
../../include/clang/Format/Format.h:3454: warning: code block should be indented:
  3454 | /// Maximum: 0
  3455 | /// /// List:                                 ///List:
  3456 | /// ///  - Foo                                /// - Foo
  3457 | /// ///    - Bar                              ///   - Bar

Diff Detail

Event Timeline

FederAndInk requested review of this revision.Oct 26 2021, 1:25 PM
FederAndInk created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2021, 1:25 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
FederAndInk retitled this revision from [docs][clang-format] warn on code indentation error to [docs][clang-format] warn on \code block indentation error.Oct 26 2021, 1:28 PM
MyDeveloperDay added a project: Restricted Project.Oct 26 2021, 2:20 PM
MyDeveloperDay accepted this revision.Oct 26 2021, 2:29 PM

It seems like you are fixing more than just the bug you highlight, i.e looks you might be fixing some autopep8 or pylint issues too.

As this isn't a tool we ship, I don't have too many concerns, but others may have other views. But it looks good to me.

This revision is now accepted and ready to land.Oct 26 2021, 2:29 PM

It seems like you are fixing more than just the bug you highlight, i.e looks you might be fixing some autopep8 or pylint issues too.

Yes, I also fixed some minor issues, my bad for not adding it into the summary right away, I'll edit that.

FederAndInk edited the summary of this revision. (Show Details)Oct 26 2021, 2:44 PM

Thanks for fixing my mistake. :)

Thanks for fixing my mistake. :)

You're welcome ;)

Thanks for your reviews.

Should we add other reviewers?

Also, I don't have commit rights, can one of you commit it on my behalf?

My name: Ludovic Jozeau
My email: federandink@gmail.com

Many thanks

Thanks for fixing my mistake. :)

You're welcome ;)

Thanks for your reviews.

Should we add other reviewers?

Also, I don't have commit rights, can one of you commit it on my behalf?

My name: Ludovic Jozeau
My email: federandink@gmail.com

Many thanks

You certainly add more reviewers, but I don't think there is a need for that. I will push it for you this weekend, if MyDeveloperDay doesn't beat me to it.