-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding not-so-goo tool for converting comments to Doxygen style
- Loading branch information
1 parent
c55fb42
commit 33ef6d3
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
#Usage: ./convert_header_comments_to_doxygen.sh <path> | ||
# Note: this does not work as well as otsdaq-utilities/tools/convert_comments_to_doxygen.cpp | ||
|
||
# Check if directory is provided | ||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <directory>" | ||
exit 1 | ||
fi | ||
|
||
|
||
|
||
|
||
# Process all .h files in the given directory recursively | ||
find "$1" -type f -name "*.h" | while read -r file; do | ||
echo "Processing: $file" | ||
|
||
# Use sed to replace end-of-line // comments with ///< | ||
# - Ignores lines that start with '#' (e.g., #pragma) | ||
# - Ignores special comments like '// clang-format off' | ||
# - Ignores comments made of repeated characters (e.g., '// ========') | ||
# - Ignores `} // namespace ots` specifically | ||
# - Converts other comments to Doxygen format | ||
sed -i -E '/^[[:space:]]*#/! {/^[[:space:]]*\/\/[[:space:]]*(clang-format|TODO|FIXME|NOTE|namespace)/! {/^[[:space:]]*\/\/[[:space:]]*([=_\-~*\/]{3,})/! {/^[[:space:]]*\/\/[[:space:]]*\}[[:space:]]*\/\/[[:space:]]*namespace[[:space:]]+ots/! s#([^/])//[[:space:]]*(.*)$#\1 ///< \2#}}}' "$file" | ||
|
||
# Remove unwanted `} ///< namespace ots` conversion | ||
sed -i -E 's#} ///< namespace ots#} // namespace ots#' "$file" | ||
|
||
done | ||
|
||
echo "Conversion complete for all .h files in $1" | ||
|
||
|
||
|