Development guide¶
This guide provides instructions for contributors who want to develop MATLAB HEDTools code or build the documentation locally.
Installation¶
Prerequisites¶
To build the documentation, you need:
Python 3.10 or later
Git (to clone the repository)
Setting up the development environment¶
Clone the repository:
git clone https://github.com/hed-standard/hed-matlab.git cd hed-matlab
Create and activate a virtual environment (recommended):
On Windows (PowerShell):
python -m venv .venv .venv\Scripts\Activate.ps1
On Linux/macOS:
python -m venv .venv source .venv/bin/activate
Install development dependencies:
The development and documentation dependencies are defined in
pyproject.toml. Install them using:pip install -e .[dev,docs]
This installs all required packages including:
Documentation tools:
Sphinx (documentation generator)
Furo theme
MyST parser (for Markdown support)
sphinxcontrib-matlabdomain (for MATLAB code documentation)
sphinx-copybutton and other extensions
Development tools:
ruff (linter and formatter)
codespell (spell checker)
black (code formatter)
mdformat (Markdown formatter)
Building the documentation¶
From the repository root, run:
sphinx-build -b html docs docs/_build/html
The generated HTML documentation will be in docs/_build/html/. Open docs/_build/html/index.html in your browser to view it.
To rebuild from scratch (clean build):
sphinx-build -b html docs docs/_build/html -E
The -E flag forces a full rebuild of all files, ignoring the cache.
Documentation structure¶
The documentation source files are organized as follows:
File/Directory |
Description |
|---|---|
|
Overview and installation instructions (main landing page content) |
|
Detailed user guide with examples |
|
This development guide |
|
API reference (auto-generated from MATLAB code) |
|
Sphinx configuration file |
|
Static assets (images, CSS, etc.) |
|
Custom Sphinx templates |
Making changes to documentation¶
Edit Markdown files: Most documentation is written in Markdown (
.mdfiles) using the MyST parser.Rebuild documentation: After making changes, rebuild the docs to see your changes:
sphinx-build -b html docs docs/_build/html
Check for errors: Review the build output for any warnings or errors.
Preview changes: Open the generated HTML in your browser to verify your changes.
Documentation style guidelines¶
Use clear, descriptive headings following the hierarchy:
#for titles,##for sections,###for subsectionsInclude code examples with proper language tags (
```matlabfor MATLAB code)Use MyST directives for admonitions:
```{admonition}blocksLink to files using workspace-relative paths:
[text](path/file.md)Add index entries for important terms using
```{index} termblocksFollow the existing style in current documentation files
MATLAB code development¶
Running tests¶
The MATLAB unit tests are located in the tests/ directory. To run all tests:
Open MATLAB
Add hedmat to your path:
addpath(genpath('hedmat')); addpath(genpath('tests'));
Run the test suite:
run_tests
This will execute all test files matching the pattern Test*.m in the tests/ directory.
Testing individual components¶
HED tools tests:
tests/test_hed_tools/Utilities tests:
tests/test_utilities/
To run tests for a specific component, navigate to the test directory and run the individual test file.
Code style guidelines¶
Use clear, descriptive function and variable names
Include comprehensive doc comments using
%%section markersFollow MATLAB naming conventions: camelCase for functions, UPPER_CASE for constants
Include examples in function documentation
Test your code with the unit test framework before submitting
Contributing workflow¶
Reporting issues¶
If you find a bug or have a feature request:
Check the GitHub issues to see if it’s already reported
If not, create a new issue with:
A clear, descriptive title
Detailed description of the problem or feature
Steps to reproduce (for bugs)
Expected vs. actual behavior
MATLAB version and operating system
Submitting changes¶
Fork the repository on GitHub
Create a feature branch:
git checkout -b feature/your-feature-name
Make your changes:
Write clear, focused commits
Follow the code style guidelines
Add or update tests as needed
Update documentation if needed
Test your changes:
Run the MATLAB test suite
Build and review the documentation
Commit your changes:
git add . git commit -m "Brief description of your changes"
Push to your fork:
git push origin feature/your-feature-name
Create a Pull Request on GitHub with:
Clear description of the changes
Reference to related issues (if any)
Any breaking changes or migration notes
Code review process¶
All contributions require review before merging
Be responsive to feedback and questions
Update your PR based on review comments
Maintain a clean commit history
Additional resources¶
HED specification: Formal HED annotation rules
HED resources: Comprehensive tutorials and documentation
Python HEDTools: The Python library that powers MATLAB HEDTools
Sphinx documentation: Sphinx documentation generator
MyST parser: Markdown parser for Sphinx
Getting help¶
If you need help with development:
Check this guide and the documentation
Review existing issues and pull requests
Ask questions by opening a GitHub issue with the “question” label
For HED-specific questions, see the HED resources