# Modo🧯
### 🔥 --- ## What is Modo🧯? ###
↓
---- Modo🧯 is not a Mojo🔥 project! It is a project for Mojo🔥 projects.
Modo🧯 is a DocGen for Mojo🔥, written in
--- ## Why I built Modo🧯 ###
↓
---- No standard tool for API docs so far Need API docs for first(?) Mojo🔥 ECS: [Larecs](https://github.com/samufi/larecs) Want simple, low-tech, generic solution --- ## What it does ###
↓
---- Using `mojo doc` JSON... - creates Markdown files suitable for SSGs - converts code examples to unit tests - can run the whole chain with a single command
--- ## Demo ###
↓
---- Clone a random Mojo🔥 project ```bash # use a fresh directory mkdir demo; cd demo # clone EmberJson git clone https://github.com/bgreni/EmberJson.git # cd into it cd EmberJson ``` ---- Set up a Modo🧯 project and build API docs ```bash # initialize Modo project in Hugo format modo init hugo # build API docs for the project modo build # serve API docs with Hugo hugo serve -s docs/site/ ``` Open the displayed URL in a web browser --- ## Features ###
↓
---- ### Output formats Several fully supported rendering target
Plain Markdown
[Hugo](https://gohugo.io) popular open-source SSG
[mdBook](https://github.com/rust-lang/mdBook) known from the
Rust book
Your wishes? ---- ### Cross-references Very simple syntax, resembling Mojo imports
```python """ Relative ref to [.Struct.method] in the current module. """ ```
Relative ref to [Struct.method]() in the current module.
```python """ Absolute ref to module [pkg.mod]. """ ```
Absolute ref to module [mod]().
```python """ Ref with [pkg.mod custom text]. """ ```
Ref with [custom text]().
---- ### Re-exports Re-structure docs the way users see your package
- mypkg - mod - Struct - subpkg - submod - Trait
####
```python """ Package mypkg... """ from .mod import Struct from .subpkg.submod import Trait ```
```python [4-6] """ Package mypkg... Exports: - mod.Struct - subpkg.submod.Trait """ from .mod import Struct from .subpkg.submod import Trait ```
####
Modo🧯
- mypkg - Struct - Trait
---- ### Doc-tests Convert code examples into unit tests
````python """ Doc-test example. ```mojo {doctest="sum"} var a = 1 + 2 ``` ```mojo {doctest="sum" hide=true} if a != 3: raise Error("failed") ``` """ ````
####
Doc-test example. ```python var a = 1 + 2 ```
`..._test.mojo` ```python fn test_sum() raises: var a = 1 + 2 if a != 3: raise Error("failed") ```
---- ### Scripts Configure pre- and post-processing bash scripts ```yaml # Bash scripts to run before build as well as test. pre-run: - | echo Running 'mojo doc'... magic run mojo doc -o docs/src/mypkg.json src/mypkg echo Done. ``` ```yaml # Bash scripts to run after test. # Also runs after build if 'tests' is given. post-test: - | echo Running 'mojo test'... magic run mojo test -I src docs/test echo Done. ``` ---- ### Templates Customize Markdown output via templates ```template Mojo struct # `{{.Name}}` {{template "signature_struct" .}} {{template "summary" . -}} {{template "description" . -}} {{template "aliases" . -}} {{template "parameters" . -}} {{template "fields" . -}} {{template "parent_traits" . -}} {{template "methods" . -}} ``` --- ## How to get Modo🧯 ###
↓
---- #### Python/pip `pip install pymodo`
#### Go `go install github.com/mlange-42/modo`
#### Pre-compiled binaries GitHub Releases --- ## @Modular ###
↓
---- #### Please...
Specify cross-ref syntax Include package re-exports in JSON Support Markdown lists in `Raises` section --- ## Contributing ###
↓
---- "Playtest" Give feedback on tool and docs Create issues & PRs --- ## Thank you! [
/mlange-42/modo](https://github.com/mlange-42/modo)