Skip to content

Commit 3255ef1

Browse files
authored
Add auto-generated API docs (#7)
1 parent ca12ed8 commit 3255ef1

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pytest src/metrax
2121
Develop the docs locally:
2222

2323
```
24+
pip install -r ./docs/requirements.txt
2425
sphinx-build ./docs /tmp/metrax_docs
2526
python -m http.server --directory /tmp/metrax_docs
2627
```

docs/conf.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
"""Configuration file for the Sphinx documentation builder."""
1616

1717
import sphinx_rtd_theme
18+
import os
19+
import sys
20+
21+
# Import local version of metrax.
22+
sys.path.insert(0, os.path.abspath('../src'))
23+
print('DEBUG: PATH', sys.path)
1824

1925
# -- Project information
2026

2127
project = 'metrax'
2228
copyright = '2025, The metrax Authors'
2329
author = 'The metrax Authors'
2430

25-
release = '0.0.2'
26-
version = '0.0.2'
31+
release = ''
32+
version = ''
2733

2834

2935
# -- General configuration
@@ -34,6 +40,8 @@
3440
'sphinx.ext.intersphinx',
3541
'sphinx.ext.napoleon',
3642
'sphinx_rtd_theme',
43+
'sphinx.ext.autodoc',
44+
'sphinx.ext.autosummary',
3745
]
3846

3947
intersphinx_mapping = {
@@ -50,3 +58,15 @@
5058

5159
# -- Options for EPUB output
5260
epub_show_urls = 'footnote'
61+
62+
63+
# -- Extension configuration
64+
65+
autodoc_member_order = 'bysource'
66+
67+
autodoc_default_options = {
68+
'members': None,
69+
'undoc-members': True,
70+
'show-inheritance': True,
71+
'special-members': '__call__, __init__',
72+
}

docs/index.rst

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,38 @@ metrax Documentation
33

44
**metrax** provides common evaluation metric implementations for JAX.
55

6-
.. note::
6+
Getting Started
7+
---------------
78

8-
This project is under active development.
9+
Metrics are based on `clu.Metric`.
10+
11+
.. code-block::
12+
13+
# Run model:
14+
y_true, y_pred = model(inputs)
15+
16+
# Create metric class:
17+
metric = metrics.Precision.from_model_output(
18+
predictions=y_pred,
19+
labels=y_true,
20+
)
21+
22+
# Update metric with new inputs:
23+
metric = metric.merge(
24+
metrics.Precision.from_model_output(
25+
predictions=y_pred,
26+
labels=y_true,
27+
)
28+
)
29+
30+
# Get result:
31+
result = metric.compute()
32+
33+
34+
Metrax API
35+
==========
36+
37+
.. toctree::
38+
:maxdepth: 2
39+
40+
metrax API <metrax>

docs/metrax.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
metrax
2+
======
3+
4+
.. automodule:: metrax

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
sphinx-rtd-theme==1.3.0rc1
2+
clu==0.0.12
3+
scikit-learn==1.6.1

0 commit comments

Comments
 (0)