Create inline C++ documentation system #92

Closed
opened 2025-07-05 19:06:13 +00:00 by john · 1 comment
Owner

Implement a macro system for documenting Python-exposed methods in C++ that automatically populates Python docstrings. This enables maintaining documentation in one place.
Affects: All Python-exposed objects (implementation infrastructure)

Implement a macro system for documenting Python-exposed methods in C++ that automatically populates Python docstrings. This enables maintaining documentation in one place. Affects: All Python-exposed objects (implementation infrastructure)
john added the
Documentation
Major Feature
labels 2025-07-05 19:06:13 +00:00
john added the
Refactoring & Cleanup
system:python-binding
workflow:blocked
labels 2025-10-26 00:44:41 +00:00
john added the
priority:tier1-active
system:documentation
workflow:needs-documentation
labels 2025-10-26 00:49:07 +00:00
Author
Owner

Implementation Complete

The inline C++ documentation macro system is now fully implemented and operational.

What Was Delivered

Core Infrastructure:

  • Created src/McRFPy_Doc.h with complete macro definitions
  • Macros: MCRF_METHOD, MCRF_PROPERTY, MCRF_SIG, MCRF_DESC, MCRF_ARG, MCRF_RETURNS, MCRF_RAISES, MCRF_NOTE, MCRF_LINK
  • Enhanced tools/generate_dynamic_docs.py with link transformation (HTML, Markdown, web, man page formats)

Files Converted to Macro System:

  • src/PyVector.cpp - All 7 methods + 2 properties (magnitude, normalize, dot, distance_to, angle, copy, magnitude_squared, x, y)
  • src/PyDrawable.cpp - 3 methods + 4 properties (get_bounds, move, resize, click, z_index, visible, opacity)
  • src/UIBase.h - UIDRAWABLE_METHODS macro (affects all UI classes)
  • src/UIBase.h - UIDRAWABLE_GETSETTERS macro (visible, opacity)
  • src/UIFrame.cpp - click and z_index property overrides
  • src/UISprite.cpp - click and z_index property overrides
  • src/UICaption.cpp - click and z_index property overrides
  • src/UIGrid.cpp - click and z_index property overrides

Code Removed:

  • Deleted 5 obsolete documentation scripts (~3,984 lines of hardcoded Python dictionaries)
  • tools/generate_complete_api_docs.py (959 lines)
  • tools/generate_complete_markdown_docs.py (820 lines)
  • tools/generate_api_docs.py (481 lines)
  • tools/generate_api_docs_simple.py (118 lines)
  • tools/generate_api_docs_html.py (1,601 lines)

Documentation:

  • Updated CLAUDE.md with macro usage guidelines
  • Design document: docs/plans/2025-10-30-documentation-macro-system-design.md
  • Implementation plan: docs/plans/2025-10-30-documentation-macro-system.md

Verification

Vector class: 0 "..." placeholders (complete documentation)
Drawable/Frame/Sprite/Caption/Grid: All inherited properties show enhanced docs
Test suite: 16/16 property docstring tests pass
Compilation: No errors or warnings
Documentation generation: Successfully produces complete HTML and Markdown

Benefits Achieved

  1. Single source of truth - Documentation lives next to implementation
  2. Zero drift - Impossible for docs and code to disagree
  3. ~2,200 fewer lines to maintain (eliminated hardcoded dictionaries)
  4. Multi-format export - HTML, Markdown, Python docstrings from same source
  5. Link transformation - MCRF_LINK automatically formats for output type
  6. Compile-time validation - Macro syntax errors caught immediately

Follow-Up Work

Remaining classes to convert (tracked separately):

  • PyColor, PyAnimation, PyTimer, PyWindow, PyScene
  • PyGrid, PyEntity, PyFont, PyTexture
  • McRFPy_API.cpp module-level functions

The infrastructure is complete and proven. Future conversions are straightforward applications of the established pattern.

## Implementation Complete ✅ The inline C++ documentation macro system is now fully implemented and operational. ### What Was Delivered **Core Infrastructure:** - Created `src/McRFPy_Doc.h` with complete macro definitions - Macros: MCRF_METHOD, MCRF_PROPERTY, MCRF_SIG, MCRF_DESC, MCRF_ARG, MCRF_RETURNS, MCRF_RAISES, MCRF_NOTE, MCRF_LINK - Enhanced `tools/generate_dynamic_docs.py` with link transformation (HTML, Markdown, web, man page formats) **Files Converted to Macro System:** - `src/PyVector.cpp` - All 7 methods + 2 properties (magnitude, normalize, dot, distance_to, angle, copy, magnitude_squared, x, y) - `src/PyDrawable.cpp` - 3 methods + 4 properties (get_bounds, move, resize, click, z_index, visible, opacity) - `src/UIBase.h` - UIDRAWABLE_METHODS macro (affects all UI classes) - `src/UIBase.h` - UIDRAWABLE_GETSETTERS macro (visible, opacity) - `src/UIFrame.cpp` - click and z_index property overrides - `src/UISprite.cpp` - click and z_index property overrides - `src/UICaption.cpp` - click and z_index property overrides - `src/UIGrid.cpp` - click and z_index property overrides **Code Removed:** - Deleted 5 obsolete documentation scripts (~3,984 lines of hardcoded Python dictionaries) - `tools/generate_complete_api_docs.py` (959 lines) - `tools/generate_complete_markdown_docs.py` (820 lines) - `tools/generate_api_docs.py` (481 lines) - `tools/generate_api_docs_simple.py` (118 lines) - `tools/generate_api_docs_html.py` (1,601 lines) **Documentation:** - Updated `CLAUDE.md` with macro usage guidelines - Design document: `docs/plans/2025-10-30-documentation-macro-system-design.md` - Implementation plan: `docs/plans/2025-10-30-documentation-macro-system.md` ### Verification ✅ Vector class: 0 "..." placeholders (complete documentation) ✅ Drawable/Frame/Sprite/Caption/Grid: All inherited properties show enhanced docs ✅ Test suite: 16/16 property docstring tests pass ✅ Compilation: No errors or warnings ✅ Documentation generation: Successfully produces complete HTML and Markdown ### Benefits Achieved 1. **Single source of truth** - Documentation lives next to implementation 2. **Zero drift** - Impossible for docs and code to disagree 3. **~2,200 fewer lines** to maintain (eliminated hardcoded dictionaries) 4. **Multi-format export** - HTML, Markdown, Python docstrings from same source 5. **Link transformation** - MCRF_LINK automatically formats for output type 6. **Compile-time validation** - Macro syntax errors caught immediately ### Follow-Up Work Remaining classes to convert (tracked separately): - PyColor, PyAnimation, PyTimer, PyWindow, PyScene - PyGrid, PyEntity, PyFont, PyTexture - McRFPy_API.cpp module-level functions The infrastructure is complete and proven. Future conversions are straightforward applications of the established pattern.
john closed this issue 2025-10-30 19:45:55 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: john/McRogueFace#92
No description provided.