Skip to content

Commit b75ee4e

Browse files
authored
Adds python API reference (#25)
* added python API reference * added autodoc-pydantic to requirements * better docstrings via napoleon * added explanatory note for controls docstrings * added plotting page * removed plot_bayes due to docstring * review fixes * review fixes
1 parent b37f6ea commit b75ee4e

File tree

18 files changed

+160
-2
lines changed

18 files changed

+160
-2
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ build/
1313
source/.buildinfo
1414
source/*.inv
1515
source/_outputs/
16+
17+
# direnv
18+
.envrc
19+
20+
# autogenerated documentation
21+
source/reference/python/RATapi.*

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ pydata-sphinx-theme==0.15.2
44
sphinx_design==0.6.0
55
sphinx-copybutton==0.5.2
66
RATapi==0.0.0.dev4
7+
autodoc_pydantic==2.2.0
8+
enum-tools[sphinx]==0.12.0

source/conf.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# add extensions path for snippets
4040
sys.path.append(os.path.abspath("./_ext"))
4141

42-
extensions = ['sphinxcontrib.matlab', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx_design', 'sphinx_copybutton', 'snippets']
42+
extensions = ['sphinxcontrib.matlab', 'sphinx.ext.napoleon', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinxcontrib.autodoc_pydantic', 'sphinx_design', 'sphinx_copybutton', 'snippets', 'enum_tools.autoenum']
4343

4444
# Add any paths that contain templates here, relative to this directory.
4545
templates_path = ['_templates']
@@ -80,4 +80,27 @@
8080
}
8181

8282
copybutton_prompt_text = r">>> |>> "
83-
copybutton_prompt_is_regexp = True
83+
copybutton_prompt_is_regexp = True
84+
85+
autodoc_typehints = "description"
86+
87+
### autodoc_pydantic settings
88+
# hide JSON schemas by default
89+
autodoc_pydantic_model_show_json = False
90+
autodoc_pydantic_settings_show_json = False
91+
92+
# don't show validators or config
93+
autodoc_pydantic_field_list_validators = False
94+
autodoc_pydantic_model_show_config_summary = False
95+
autodoc_pydantic_model_show_validator_summary = False
96+
autodoc_pydantic_model_show_validator_members = False
97+
98+
# hide parameter list in class signature
99+
autodoc_pydantic_settings_hide_paramlist = True
100+
101+
# do not show list of fields if they do not have docstrings
102+
# (e.g. for models we use the main docstring)
103+
autodoc_pydantic_model_undoc_members = False
104+
105+
# get field documentation from field docstrings
106+
autodoc_pydantic_field_doc_policy = "docstring"

source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ RAT contains a number of improvements over legacy RasCAL, including:
5555
Learn more by diving into the RAT reference:
5656

5757
* :ref:`matlab_api`: Detailed information about all of RAT's MATLAB API.
58+
* :ref:`python_api`: Detailed information about the RAT Python API.
5859

5960

6061
.. grid-item-card::
@@ -77,4 +78,5 @@ RAT contains a number of improvements over legacy RasCAL, including:
7778
install
7879
guide
7980
reference/matlab/index
81+
reference/python/index
8082

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ClassList
2+
---------
3+
4+
.. autoclass:: RATapi.ClassList
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Controls
2+
--------
3+
4+
The ``Controls`` class details control parameters for the RAT run. Note that many of these are
5+
specific to certain procedures: the relevant procedure is listed in square brackets before the
6+
field description.
7+
8+
.. autopydantic_model:: RATapi.Controls
9+
:members:

source/reference/python/core.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RAT Core
2+
--------
3+
4+
This module contains the `Pybind11 <https://pybind11.readthedocs.io/en/stable/index.html>`_ objects
5+
which are used to interface with RAT's C++ code.
6+
7+
.. automodule:: RATapi.rat_core
8+
:members:

source/reference/python/enums.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Enums
2+
-----
3+
4+
This utility module (found in ``RATapi.utils.enums``) contains the Enum objects
5+
which are used under the hood to represent arguments given as string options,
6+
such as those for control parameters or background types.
7+
8+
.. automodule:: RATapi.utils.enums
9+
:members:

source/reference/python/events.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Events
2+
------
3+
4+
.. automodule:: RATapi.events
5+
:members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Examples
2+
--------
3+
4+
.. automodule:: RATapi.examples
5+
:members:

0 commit comments

Comments
 (0)