Generate API documentation with quarto.
Project description
quartodoc
Generate python API documentation for quarto.
Install
pip install quartodoc
Or for the latest changes:
python3 -m pip install -e git+https://github.com/machow/quartodoc.git#egg=quartodoc
Basic use
from quartodoc import get_function, MdRenderer
# get function object ---
f_obj = get_function("quartodoc", "get_function")
# render ---
renderer = MdRenderer(header_level = 1)
print(
renderer.to_md(f_obj)
)
# get_function
`get_function(module: str, func_name: str, parser: str = 'numpy')`
Fetch a function.
## Parameters
| Name | Type | Description | Default |
|-------------|--------|----------------------------|-----------|
| `module` | str | A module name. | required |
| `func_name` | str | A function name. | required |
| `parser` | str | A docstring parser to use. | `'numpy'` |
## Examples
```python
>>> get_function("quartodoc", "get_function")
<Function('get_function', ...
```
How it works
quartodoc consists of two pieces:
- collection: using the library griffe to statically collect information about functions and classes in a program.
- docstring parsing: also handled by griffe, which breaks it into a tree structure.
- docstring rendering: use plum-dispatch on methods like MdRenderer.to_md to decide how to visit and render each piece of the tree (e.g. the examples section, a parameter, etc..).
Here is a quick example of how you can grab a function from griffe and walk through it.
from griffe.loader import GriffeLoader
from griffe.docstrings.parsers import Parser
griffe = GriffeLoader(docstring_parser = Parser("numpy"))
mod = griffe.load_module("quartodoc")
f_obj = mod._modules_collection["quartodoc.get_function"]
f_obj.name
'get_function'
docstring = f_obj.docstring.parsed
docstring
[<griffe.docstrings.dataclasses.DocstringSectionText at 0x105a2c310>,
<griffe.docstrings.dataclasses.DocstringSectionParameters at 0x10f7961f0>,
<griffe.docstrings.dataclasses.DocstringSectionExamples at 0x10f7965b0>]
Note that quartodoc’s MdRenderer can be called on any part of the parsed docstring.
from quartodoc import MdRenderer
renderer = MdRenderer()
print(
renderer.to_md(docstring[1])
)
| Name | Type | Description | Default |
|-------------|--------|----------------------------|-----------|
| `module` | str | A module name. | required |
| `func_name` | str | A function name. | required |
| `parser` | str | A docstring parser to use. | `'numpy'` |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quartodoc-0.0.3.tar.gz.
File metadata
- Download URL: quartodoc-0.0.3.tar.gz
- Upload date:
- Size: 101.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d39d681c4831a7079c64e43451a5a6541f29ce5bcf35ed1211878ab0011ffe09
|
|
| MD5 |
7899b0eb55668b4bd5f69aa18056ed68
|
|
| BLAKE2b-256 |
7abfd4608701058d197ce55c580c30568e077488af94a8d2255d01c42120456a
|
File details
Details for the file quartodoc-0.0.3-py2.py3-none-any.whl.
File metadata
- Download URL: quartodoc-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abecada5f1a63444729db0196517a956d38baa60e13995f481bbf8a820758159
|
|
| MD5 |
591ec48a2c23205e5ed6af1465e48091
|
|
| BLAKE2b-256 |
a0d678db4d04f37468b11edc51e2a5d3a966f9541cd0151b651499bd0188ec0d
|