Development¶
This page documents the development workflow for maintaining Mathy source code, generated API documentation, MkDocs configuration, and documentation build output.
๐งญ Purpose¶
Mathy uses source-driven documentation. Python modules contain Google-style docstrings that are
parsed by mkdocstrings and rendered into the API reference during the MkDocs build process.
Development work should preserve three standards:
| Standard | Requirement |
|---|---|
| Source correctness | Python modules must parse and compile. |
| Documentation correctness | Docstrings must be Google-style and compatible with griffe. |
| Build correctness | mkdocs build must complete without documentation warnings. |
๐งฑ Repository Structure¶
The recommended project structure is:
Mathy/
โโโ mkdocs.yml
โโโ requirements.txt
โโโ data.py
โโโ scalers.py
โโโ encoders.py
โโโ imputers.py
โโโ transformers.py
โโโ features.py
โโโ clusters.py
โโโ outliers.py
โโโ regressions.py
โโโ classifications.py
โโโ forecasting.py
โโโ docs/
โ โโโ index.md
โ โโโ architecture.md
โ โโโ development.md
โ โโโ user-guide/
โ โ โโโ index.md
โ โ โโโ data-preparation.md
โ โ โโโ feature-engineering.md
โ โ โโโ modeling.md
โ โ โโโ forecasting.md
โ โโโ api/
โ โโโ index.md
โ โโโ data.md
โ โโโ scalers.md
โ โโโ encoders.md
โ โโโ imputers.md
โ โโโ transformers.md
โ โโโ features.md
โ โโโ clusters.md
โ โโโ outliers.md
โ โโโ regressions.md
โ โโโ classifications.md
โ โโโ forecasting.md
โโโ site/
The site/ directory is generated by MkDocs and should not be edited manually.
๐ Python Environment¶
Create and activate a virtual environment from the repository root.
Upgrade packaging tools.
Install project and documentation dependencies.
๐ฆ Documentation Dependencies¶
The documentation build requires MkDocs, Material for MkDocs, and mkdocstrings.
At minimum, requirements.txt should include documentation dependencies similar to:
If the source modules import scientific or machine-learning packages during documentation generation, the active environment must also include those runtime dependencies.
Common dependencies may include:
๐งพ MkDocs Configuration¶
The mkdocs.yml file controls the documentation site.
Key configuration areas include:
| Section | Purpose |
|---|---|
site_name |
Sets the documentation site name. |
theme |
Configures Material for MkDocs. |
plugins |
Enables search and mkdocstrings. |
markdown_extensions |
Enables enhanced Markdown rendering. |
nav |
Defines the documentation navigation. |
mkdocstrings options |
Controls API rendering from Python docstrings. |
The API reference uses one Markdown file per Python module.
Example:
The directive tells mkdocstrings to load the data module and render documentation from the
module, classes, methods, signatures, arguments, returns, and raises sections.
๐ Google-Style Docstring Standard¶
Mathy source documentation should use Google-style docstrings.
Recommended structure:
def method_name( self, value: object ) -> object:
"""Short imperative summary.
Purpose:
Describes what the method does, what state it uses, what state it changes, and how it
fits into the Mathy workflow.
Args:
value: Description of the argument.
Returns:
object: Description of the returned value.
Raises:
Error: Raised when validation or wrapped estimator execution fails."""
โ Griffe-Compatible Section Rules¶
mkdocstrings uses griffe to parse Python docstrings. The parser is strict about Google-style
sections.
Use this format:
Use this format:
Use this format:
Use this format:
Avoid this format in source files:
Avoid continuation lines that look like new entries without a colon.
Avoid generic return text without a type when the function has no return annotation.
Incorrect:
Correct:
๐งฏ Error-Handling Standard¶
Mathy source modules use wrapped exception logging where exception handlers already exist.
Standard pattern:
except Exception as e:
exception = Error( e )
exception.module = 'mathy'
exception.cause = 'ClassName'
exception.method = 'method_name( self, *args ) -> return_type'
Logger( ).write( exception )
raise exception
For methods with multiple parameters, use the compact *args method string:
For methods with one explicit parameter, the full stable signature may be used:
The method string must not contain:
- live dataframe values
- array contents
- user input values
- file paths
- target values
- runtime-specific object representations
๐งช Source Validation¶
After modifying a Python source file, validate it before building documentation.
Run syntax parsing:
Run compile checks across the project:
For individual imports:
python -c "import data; print('data ok')"
python -c "import scalers; print('scalers ok')"
python -c "import encoders; print('encoders ok')"
python -c "import imputers; print('imputers ok')"
python -c "import transformers; print('transformers ok')"
python -c "import features; print('features ok')"
python -c "import clusters; print('clusters ok')"
python -c "import outliers; print('outliers ok')"
python -c "import regressions; print('regressions ok')"
python -c "import classifications; print('classifications ok')"
python -c "import forecasting; print('forecasting ok')"
๐๏ธ Documentation Build¶
Build the documentation from the repository root.
A clean build should show:
Warnings should be treated as defects unless they are known upstream notices from Material for MkDocs.
๐ฅ๏ธ Local Documentation Server¶
Run the local documentation site:
Open the local site:
Use this during documentation review because it allows you to inspect navigation, API rendering, tables, code blocks, and page layout before deployment.
๐งน Cleaning Generated Output¶
MkDocs writes output to the site/ directory.
To force a clean build:
The site/ directory can be regenerated at any time.
๐ Troubleshooting MkDocs Warnings¶
Missing nav file¶
Warning:
Cause:
The mkdocs.yml navigation references a Markdown file that does not exist under docs/.
Fix:
Create the file or remove the entry from nav.
Page exists but is not in nav¶
Warning:
Cause:
A Markdown file exists under docs/, but mkdocs.yml does not include it in the navigation.
Fix:
Add the file to nav, remove the file, or intentionally accept the warning.
Griffe name parsing warning¶
Warning:
Cause:
A Google-style Args: or Attributes: section has malformed entries or wrapped lines that look
like entries.
Fix:
Use this structure:
Griffe return warning¶
Warning:
Cause:
A Returns: section lacks an explicit type and the function has no return annotation.
Fix:
Use this structure:
๐งญ Documentation Workflow¶
Use this sequence when changing source or documentation files:
1. Update Python source.
2. Confirm source parses and compiles.
3. Confirm docstrings are Google-style and griffe-compatible.
4. Update or add Markdown pages under docs/.
5. Confirm every docs page is included in mkdocs.yml nav.
6. Run mkdocs build.
7. Resolve warnings.
8. Run mkdocs serve.
9. Inspect the local site.
10. Commit the source and documentation changes.
๐งช Acceptance Checklist¶
Before considering a documentation update complete, confirm:
| Check | Required Result |
|---|---|
| Python source parses | No syntax errors. |
| Python source compiles | py_compile or compileall succeeds. |
| Imports work | API modules can be imported by mkdocstrings. |
| MkDocs builds | mkdocs build succeeds. |
| Griffe warnings resolved | No malformed Google-style docstring warnings. |
| Navigation complete | No missing or unlisted documentation page warnings. |
| API pages render | Each module page renders correctly. |
| Local site reviewed | Pages display correctly under mkdocs serve. |
๐ Deployment Preparation¶
After local documentation builds cleanly, the documentation can be deployed through GitHub Pages.
Common deployment options include:
| Option | Description |
|---|---|
mkdocs gh-deploy |
Builds and pushes the documentation site to the gh-pages branch. |
| GitHub Actions | Automatically builds and deploys documentation on push. |
| Manual Pages configuration | Uses repository settings to publish from the selected branch or workflow. |
A typical manual deployment command is:
Use this only after the local build is clean.
๐ Related Pages¶
| Page | Description |
|---|---|
| Architecture | Project structure and module architecture. |
| User Guide | Task-oriented usage documentation. |
| API Reference | Source-generated API documentation. |