From a540dceae2c899bf2a73766ca30846400276f35c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 29 Aug 2024 09:07:40 +1000 Subject: [PATCH] Move doxygen processing logic from unify_includes to doxygen_space --- scripts/doxygen_space.py | 28 +++++++++++++++++++++++++++- scripts/unify_includes.pl | 11 ----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/scripts/doxygen_space.py b/scripts/doxygen_space.py index d7e92fbf31d..0f235328e06 100755 --- a/scripts/doxygen_space.py +++ b/scripts/doxygen_space.py @@ -38,7 +38,33 @@ def process_file(file_path): if re.match(r'^\s*(?:#ifdef|#ifndef|#else|#endif)', line): output.append(line) - elif match := re.match(r'^(\s*)//!\s*(.*?)$', line): + i += 1 + continue + + if match := re.match(r'^(\s*)/\*[*!]\s*([^\s*].*)\s*$', line): + # Convert blocks starting with /*! format to /** standard, + # and convert + # /**Some docs + # to + # /** + # * Some docs + indent, content = match.groups() + output.append(f'{indent}/**') + line = f'{indent} * {content[0].upper()}{content[1:]}' + + if match := re.match(r'^(.*)/\*[!*](?!\*)(<*)[ \t\r\n\f]*(.*?)[ \t\r\n\f]*\*/[ \t\r\n\f]*$', line): + # Convert single line doxygen blocks: + # /*!< comment */ to //!< comment + # /** comment */ to //! comment + prefix, tag, content = match.groups() + line = f'{prefix}//!{tag} {content}' + + if match := re.match(r'^(.*)//!<\s*(.)(.*)$', line): + # Uppercase initial character in //!< comment + prefix, first, remaining = match.groups() + line = f'{prefix}//!< {first.upper()}{remaining}' + + if match := re.match(r'^(\s*)//!\s*(.*?)$', line): indentation, comment = match.groups() # found a //! comment # check next line to see if it also begins with //! diff --git a/scripts/unify_includes.pl b/scripts/unify_includes.pl index da6ed70e1e3..c3cad99465b 100755 --- a/scripts/unify_includes.pl +++ b/scripts/unify_includes.pl @@ -25,17 +25,6 @@ our @inc; END { die "header files not empty" if @inc; } -# Also fix doxygen comments -s#^(\s*)/\*[*!]\s*([^\s*].*)\s*$#$1/** \u$2\n#; - -# Convert single line doxygen blocks: -# /*!< comment */ to //!< comment -# /** comment */ to //! comment -s#\/\*[!\*](?!\*)(<*)\h*(.*?)\h*\*\/\h*$#//!$1 $2#; - -# Uppercase initial character in //!< comment -s#\/\/!<\s*(.)(.*)#//!< \u$1$2#; - # Ensure that pointer members are always initialized to nullptr # We don't run this check by default, there's a high likelihood of false positives... # s#^(\s*(?!typedef|return|delete)(?:\s*(?:const)\s*)?[a-zA-Z0-9_:]+\s*\*+\s*[a-zA-Z0-9_]+)\s*;\s*$#$1 = nullptr;\n#;