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

DOC: Fix unbalanced grouping commands Doxygen warnings #3805

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhlegarreta
Copy link
Member

Fix unbalanced grouping commands Doxygen warnings.

Fixes:

Modules/Core/Common/include/itkAutoPointer.h:261: warning: unbalanced grouping commands

warnings across classes.

The warning is raised when the
Utilities/Doxygen/itkdoxygen.pl

Doxygen Perl script processes the files at issue and starts a /**@{ block that gets interrupted by an unexpected symbol (e.g. a brace) without being previously closed with the corresponding /**@}*/ ending token.

Raised for example in:
https://open.cdash.org/viewBuildError.php?type=1&buildid=8344134

PR Checklist

@github-actions github-actions bot added area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module type:Documentation Documentation improvement or change labels Dec 19, 2022
@jhlegarreta
Copy link
Member Author

jhlegarreta commented Dec 19, 2022

I checked the /**@{ /**@}*/ blocks for every file manually following #3654 (comment).

However, clang-format already warned me locally that it did not like the changes: it does not like changes in 61 files out of 79.

The pattern that we require to solve the Doxygen issues (that clang-format dislikes) looks to be "we require a blank line before closing the class with a };", as if we were to fulfill the condition in this comment:

# at next empty line add a //@}

@hjmjohnson @thewtex @dzenanz any suggestion on how we could work around this without having to recur to turning it on/off on each of these lines?

The other hypothesis is that the variable values in this condition

if($endparencount > 1 && ($semicount > 1 || $endbracecount > 1))

or the condition itself should be modified. Maybe the "//@}\n\n" ending block should be inserted at buffer_lines - 1 if we cannot work around the clang-format issue, and if that is possible.

Another possibility would be to submit only the changes that make clang-format happy, and increasingly add the rest on a case-by-case in case the required blank line can be introduced at some place other than the one where I introduced it.

@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

It feels like we should update clang format style to allow the changes proposed here. I am not sure whether that can accomplish it.

@jhlegarreta jhlegarreta marked this pull request as draft December 19, 2022 15:32
@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

I am running the build script with doxygen updated to 1.9.5, so we don't have to wait until tomorrow to see the updated output.

@jhlegarreta
Copy link
Member Author

It feels like we should update clang format style to allow the changes proposed here. I am not sure whether that can accomplish it.

Looks like there may be a way:
https://stackoverflow.com/questions/33547172/clang-format-empty-line-between-end-of-class-declaration-and-closing-of-a-names
https://stackoverflow.com/questions/70732683/how-to-add-blank-lines-between-definitions

@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

The second suggestion would require us to move to a newer clang-format (14 or later). We are currently at 8.0.0. Moving to a newer one shouldn't be a big change. The first suggestion looks like it would work now. Can you try it?

@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

Doxygen 1.9.5 produces 100+ new warnings of style: Generating docDocumentation/Doxygen/NeighborhoodIterators.dox:96: warning: Unexpected token TK_HTMLTAG found as part of a title section. All warnings here. @jhlegarreta should we keep this version?

@jhlegarreta
Copy link
Member Author

jhlegarreta commented Dec 19, 2022

Doxygen 1.9.5 produces 100+ new warnings of style: Generating docDocumentation/Doxygen/NeighborhoodIterators.dox:96: warning: Unexpected token TK_HTMLTAG found as part of a title section. All warnings here. @jhlegarreta should we keep this version?

😓 I would keep the old version for now then. I would upgrade to the newer version once we have managed to fix the current warnings (which are still present in the new version).

@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

I just reverted doxygen to 1.8.16.

@jhlegarreta
Copy link
Member Author

The first suggestion looks like it would work now. Can you try it?

Looks like our clang-format options prevent it from working as described in the thread: https://github.com/InsightSoftwareConsortium/ITK/actions/runs/3727206860/jobs/6321140027#step:4:86

@hjmjohnson Do you happen to know the clang-format option that should do the work for our current version?

@dzenanz
Copy link
Member

dzenanz commented Dec 19, 2022

Adding end of class comment does trigger the described workaround:

  /** Sets the value of the image buffer at the current index value to the
   * specified value.  */
  void
  SetPixelValue(InternalPixelType * const imageBufferPointer, const PixelType & pixelValue) const noexcept
  {
    m_NeighborhoodAccessor.Set(imageBufferPointer + m_PixelIndexValue, pixelValue);
  }

}; // end of class

This is an excerpt from ITK\Modules\Core\Common\include\itkBufferedImageNeighborhoodPixelAccessPolicy.h, near the end.

@jhlegarreta
Copy link
Member Author

#3805 (comment) OK, I was thinking about the namespace ending. I can do this, but I do not think we are willing to have this as a long-term solution.

@thewtex @blowekamp @hjmjohnson any thoughts?

@thewtex
Copy link
Member

thewtex commented Jan 4, 2023

Another approach could replace itkdoxygen.pl with a Python script 🐍

@jhlegarreta
Copy link
Member Author

jhlegarreta commented Jan 4, 2023

Another approach could replace itkdoxygen.pl with a Python script 🐍

The problem is rather clang-format disliking the insertion of a blank line before the end of class closing bracket line without the latter having an inline comment.

@thewtex
Copy link
Member

thewtex commented Jan 4, 2023

The problem is rather clang-format disliking the insertion of a blank line

Can we remove the insertion of the blank line in the Python script migration?

@jhlegarreta
Copy link
Member Author

Can we remove the insertion of the blank line in the Python script migration?

It should rather be introduced: clang-format dislikes it and it keeps trying to remove it.

I do not have the bandwidth to translate the script into Python.

Alternatives:

  • If you feel like modifying the Perl script to add such a blank line and have this tested, please go ahead ▶️.
  • If you feel like to translating the script to Python and introducing the blank line, please go ahead ▶️.
  • Otherwise, pinging @hjmjohnson to see if he can allow the blank like without changing the script.

@jhlegarreta
Copy link
Member Author

Do you think the below approach plugged right after

can be made to work?

if($line =~ /\};/ )
{
  // Take the current buffer $buffer (assuming it includes the current line `};` as well) and add a blank line
  // immediately before `};` (if the current buffer does not include the current line, then include it right after
  // the buffer end)

  (doTheAboveStuff)

  // (I think we do not care that much if }; is not the end of the class definition (i.e. even if a lot of blank lines
  // are inserted) as this is only to produce proper Doxygen code)

  (save the $buffer)
}

so that we can get the result in #3805 (comment) without needing to add // end of class and thus bypass clang's unhappyness about adding a blank line? Or maybe there is another way to achieve it

@thewtex @tbirdso maybe one of you is skilled at Perl to give that a try? Thanks.

@dzenanz
Copy link
Member

dzenanz commented Jan 30, 2023

I still think that moving to latest stable clang-format (currently 15.0.7) is the best solution.

@jhlegarreta
Copy link
Member Author

I still think that moving to latest stable clang-format (currently 15.0.7) is the best solution.

Would that fix the issue here ? Isn't the config itself, rather than the clang-format version, what might help ?

@dzenanz
Copy link
Member

dzenanz commented Jan 30, 2023

The current version ignores (does not support) the config setting we need. As per this SO answer, we need SeparateDefinitionBlocks, which was introduced with clang 14. So we need version 14+.

We already have MaxEmptyLinesToKeep: 2 in our config, and that is not enough.

@jhlegarreta
Copy link
Member Author

#3805 (comment) OK, then +100 for upgrading. @hjmjohnson ?

@hjmjohnson
Copy link
Member

@jhlegarreta I trust the judgment of those who have invested time into this PR. I will not have time to review it carefully.

@jhlegarreta
Copy link
Member Author

Fix unbalanced grouping commands Doxygen warnings.

Fixes:
```
Modules/Core/Common/include/itkAutoPointer.h:261: warning: unbalanced grouping commands
```

warnings across classes.

The warning is raised when the
Utilities/Doxygen/itkdoxygen.pl

Doxygen Perl script processes the files at issue and starts a `/**@{`
block that gets interrupted by an unexpected symbol (e.g. a brace)
without being previously closed with the corresponding `/**@}*/`
ending token.

Raised for example in:
https://open.cdash.org/viewBuildError.php?type=1&buildid=8344134
@jhlegarreta jhlegarreta force-pushed the FixUnbalancedGroupingCommandsDoxygenWarnings branch from 4293d83 to dba1d67 Compare July 20, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module type:Documentation Documentation improvement or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants