Developer Guide
Developer Guide
Development documentation for XMD contributors.
Architecture
XMD follows a modular architecture:
xmd
โโโ lexer - Tokenization and parsing
โโโ processor - Directive processing
โโโ template - Variable substitution
โโโ executor - Command execution
โโโ store - Variable storage
โโโ cli - Command-line interface
Development Rules
- One function per file: Each function in its own file
- Folder structure:
module_name/function_name/function_name.c - Max 200 lines per file: Keep files focused and manageable
- Test-driven: Write tests before implementation
- No external dependencies: Self-contained implementation
Building
# Clone repository
git clone https://github.com/akaoio/xmd
cd xmd
# Build
mkdir build && cd build
cmake ..
make
# Run tests
make test
# Install
sudo make install
Testing
All tests must pass before merging:
# Run all tests
make test
# Run specific test
./test_xmd_processor
./test_truncate_fix
Code Style
- C17 standard
- 4-space indentation
- Doxygen comments for all functions
- Clear variable names
- Error handling for all edge cases
Adding Features
- Create design doc in
docs/notes/ - Write tests in
test/ - Implement in appropriate module
- Update documentation
- Submit PR with tests passing
Project Structure
xmd/
โโโ src/ - Source code
โ โโโ lexer/ - Tokenization
โ โโโ xmd_processor/ - Core processing
โ โโโ cli/ - CLI implementation
โโโ include/ - Header files
โโโ test/ - Test suites
โโโ docs/ - Documentation
โโโ examples/ - Example files
Key Modules
Lexer
Tokenizes XMD directives and markdown content.
Processor
Handles directive execution and control flow.
Template Engine
Variable substitution and template processing.
Command Executor
Secure command execution with sandboxing.
Contributing
- Fork the repository
- Create feature branch
- Write tests first
- Implement feature
- Ensure all tests pass
- Submit pull request
See INSTRUCTIONS.md for detailed coding standards.