Docstrings Syntax¶
You can use any Markdown syntax, and inari
provides some additional features.
List Arguments/Attributes¶
inari
emphasizes names of listed arguments automatically.
Example:
def func(alpha: str, beta: str) -> str:
"""
Sample function.
**Args**
* alpha (`str`): Explain `alpha` .
* beta (`str`): Explain `beta` .
**Returns**
* `str`: Return type.
"""
return alpha + beta
That will be converted to this:
## Functions
### func
```python
def func(alpha: str, beta: str) -> str
```
Sample function.
**Args**
- **alpha** (`str`): Explain `alpha` .
- **beta** (`str`): Explain `beta` .
**Returns**
- `str`: Return type.
Cross Reference¶
inari
generates cross reference in API documents. module.submodule.function
will be converted to appropriate relative link like [`function `](submodule.md#function)
.
Note
If you installed inari
without MkDocs
, you have to install Python-Markdown
and enable Attribute Lists extension to create hash anchors.
Example:
# `module/submodule.py`
def func(alpha: str, bata: str) -> str:
"""
Link to some method like `module.anothermodule.SampleClass.some_method`
"""
return alpha + bata
# `module/anothermodule.py`
class SampleClass:
"""
Make reference like `module.submodule.func`
"""
def some_method(self):
pass
inari
makes hyperlink like this:
<!-- docs/module/submodule-py.md -->
# Module module.submodule
## Functions
### func {: #func }
```python
def func(alpha: str, bata: str) -> str
```
Link to some method like [`SampleClass.some_method `](anothermodule-py.md#SampleClass.some_method)
<!-- docs/module/anothermodule-py.md -->
# Module module.anothermodule
## Classes
### SampleClass {: #SampleClass }
```python
class SampleClass()
```
Make reference like [`func `](submodule-py.md#func)
---
#### Methods {: #SampleClass-methods }
[**some_method**](#SampleClass.some_method){: #SampleClass.some_method }
```python
def some_method(self)
```