Introduction¶
In the maintenance of C/C++ (including Qt) projects, writing and updating Doxygen comments often involves a significant amount of repetitive work. When AI generates comments, it frequently overwrites existing content, ignores signature changes, or omits parameter descriptions. The DeepSeek Harness (DSH) plugin ecosystem emphasizes “everything is a plugin,” offering a solution to this engineering challenge through the integration of specialized skills.
What is this¶
dsh-doxygen is a DSH plugin (skill) maintained by user FantastyQAQ. It provides a complete workflow for Doxygen comments, covering scenarios such as file headers, functions, module groups, trailing comments, and short comments. It not only generates new comments but also detects and marks outdated comments via “signature fingerprints” when code changes occur, serving as a tool for maintaining project documentation.
Core Features¶
The plugin provides the following core capabilities:
- Function Location and Parsing: Supports locating target functions by line number or function name, parses function signatures (including parameter directions), and outputs signature fingerprints in JSON format.
- Six Template Supports: Offers six templates—file header, function, module header, module footer, trailing comment, and short comment—corresponding to editor snippet prefixes.
- Incremental Filling Strategy: Adopts a “fill rather than rewrite” mechanism. When existing comments are present, it only supplements missing fields while preserving original wording and line order.
- Signature Fingerprint Verification: Appends a 16-bit hexadecimal signature fingerprint to each function block. During scanning, it compares the current code signature with the fingerprint in the comment to flag cases where code has changed but comments have not been updated.
- Safe Operation Mode: By default, it only prints a Diff preview. Modifications are applied via
--writeonly after user confirmation, preventing accidental file overwrites. - CJK Text Friendly: The script enforces UTF-8 output to ensure Chinese comments display correctly in the Windows console.
Installation and Enablement¶
Before installation, ensure the environment meets Python dependencies.
- Install Dependencies: Requires Python 3.10+ and the installation of the C/C++ parser.
pip install tree-sitter tree-sitter-cpp
(Installation via `requirements.txt` is also supported)
- Install Plugin: Use the official DSH command to install.
dsh plugin add github:FantastyQAQ/dsh-doxygen
- Verify Installation:
python scripts/parse_function.py --file demo.cpp --list
If the function list is output, the installation was successful.
Typical Usage¶
The plugin includes two core scripts: parse_function.py (read-only parsing) and gen_doxygen.py (generation and writing).
- Parse Function Signature
First, locate the function and obtain the signature fingerprint:
python scripts/parse_function.py --file src/rtc.cpp --line 42 --body-lines 30
The output includes the function name, parameters, return type, and a 16-bit fingerprint `ac50cb812857de87`.
- Generate or Update Comments
Pass the parsing result to a model to generate documentation JSON, then render and preview:
python scripts/gen_doxygen.py --file src/rtc.cpp --line 42 --kind fun --doc doc.json --diff
After confirming it is correct, write to the file:
python scripts/gen_doxygen.py --file src/rtc.cpp --line 42 --kind fun --doc doc.json --write
- Scan Repository
Scan the entire source code directory to check comment status:
python scripts/gen_doxygen.py --scan src
The scan returns a list containing `missing`, `stale`, `partial`, and `ok` statuses.
- Other Templates
- File Header:
python scripts/gen_doxygen.py --file src/rtc.cpp --kind source --brief "RTC Driver" --diff - Module Group:
python scripts/gen_doxygen.py --file src/rtc.cpp --kind module --line 30 --group rtc_api --diff - Trailing/Short Comment:
python scripts/gen_doxygen.py --file src/rtc.h --kind rear --line 18 --diff
- File Header:
Applicable Scenarios & Notes¶
- Target Audience: C/C++ project developers, Qt developers, and teams requiring automated documentation maintenance.
- Windows Note: In Windows environments, always use the
pythoncommand (avoid usingpython3, as some environments treat it as an alias trap). - Batch Operations: Do not rewrite hundreds of files at once after scanning. Group by status (e.g.,
staleormissing) and allow users to manually select for writing.
Brief Conclusion¶
dsh-doxygen solves the pain point of code-documentation desynchronization through the signature fingerprint mechanism, providing a complete loop from parsing and generation to verification. It is a practical solution for C/C++ projects pursuing documentation quality and maintenance efficiency.