[2/2] utils: checkstyle.py: Drop period at end of Doxygen one liners
diff mbox series

Message ID 20240416102004.10617-3-laurent.pinchart@ideasonboard.com
State Accepted
Commit 7d79e9425e258413a523cc2fd124a6ec16839d2a
Headers show
Series
  • utils: checkstyle.py: Extend Doxygen formatter
Related show

Commit Message

Laurent Pinchart April 16, 2024, 10:20 a.m. UTC
The libcamera documentation style calls for no period at the end of the
Doxygen one-liner commands (\brief, \param and \return). Extend the
DoxygenFormatter class to drop the period.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/checkstyle.py | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kieran Bingham April 16, 2024, 11:55 a.m. UTC | #1
Quoting Laurent Pinchart (2024-04-16 11:20:04)
> The libcamera documentation style calls for no period at the end of the
> Doxygen one-liner commands (\brief, \param and \return). Extend the
> DoxygenFormatter class to drop the period.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  utils/checkstyle.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index 2ab7e50fb0b6..88078a6171b7 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -753,6 +753,7 @@ class CLangFormatter(Formatter):
>  class DoxygenFormatter(Formatter):
>      patterns = ('*.c', '*.cpp')
>  
> +    oneliner_regex = re.compile(r'^ +\* +\\(brief|param|return)\b.*\.$')

Interesting, That was easier than I expected.

>      return_regex = re.compile(r' +\* +\\return +[a-z]')
>  
>      @classmethod
> @@ -768,6 +769,7 @@ class DoxygenFormatter(Formatter):
>                  lines.append(line)
>                  continue
>  
> +            line = cls.oneliner_regex.sub(lambda m: m.group(0)[:-1], line)


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>              line = cls.return_regex.sub(lambda m: m.group(0)[:-1] + m.group(0)[-1].upper(), line)
>  
>              if line.find('*/') != -1:
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart April 19, 2024, 9:35 a.m. UTC | #2
On Tue, Apr 16, 2024 at 12:55:41PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2024-04-16 11:20:04)
> > The libcamera documentation style calls for no period at the end of the
> > Doxygen one-liner commands (\brief, \param and \return). Extend the
> > DoxygenFormatter class to drop the period.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  utils/checkstyle.py | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> > index 2ab7e50fb0b6..88078a6171b7 100755
> > --- a/utils/checkstyle.py
> > +++ b/utils/checkstyle.py
> > @@ -753,6 +753,7 @@ class CLangFormatter(Formatter):
> >  class DoxygenFormatter(Formatter):
> >      patterns = ('*.c', '*.cpp')
> >  
> > +    oneliner_regex = re.compile(r'^ +\* +\\(brief|param|return)\b.*\.$')
> 
> Interesting, That was easier than I expected.

It's not fool-proof, it doesn't catch doxygen commands that span
multiple lines, but I'll worry about that later if needed.

> >      return_regex = re.compile(r' +\* +\\return +[a-z]')
> >  
> >      @classmethod
> > @@ -768,6 +769,7 @@ class DoxygenFormatter(Formatter):
> >                  lines.append(line)
> >                  continue
> >  
> > +            line = cls.oneliner_regex.sub(lambda m: m.group(0)[:-1], line)
> 
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> >              line = cls.return_regex.sub(lambda m: m.group(0)[:-1] + m.group(0)[-1].upper(), line)
> >  
> >              if line.find('*/') != -1:

Patch
diff mbox series

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 2ab7e50fb0b6..88078a6171b7 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -753,6 +753,7 @@  class CLangFormatter(Formatter):
 class DoxygenFormatter(Formatter):
     patterns = ('*.c', '*.cpp')
 
+    oneliner_regex = re.compile(r'^ +\* +\\(brief|param|return)\b.*\.$')
     return_regex = re.compile(r' +\* +\\return +[a-z]')
 
     @classmethod
@@ -768,6 +769,7 @@  class DoxygenFormatter(Formatter):
                 lines.append(line)
                 continue
 
+            line = cls.oneliner_regex.sub(lambda m: m.group(0)[:-1], line)
             line = cls.return_regex.sub(lambda m: m.group(0)[:-1] + m.group(0)[-1].upper(), line)
 
             if line.find('*/') != -1: