Move doxygen processing logic from unify_includes to doxygen_space

This commit is contained in:
Nyall Dawson 2024-08-29 09:07:40 +10:00
parent cd60bb8f2d
commit a540dceae2
2 changed files with 27 additions and 12 deletions

View File

@ -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 //!

View File

@ -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#;