Skip to content

Commit 952610a

Browse files
committed
Update api docs to render docstrings correctly
1 parent 1398e51 commit 952610a

9 files changed

Lines changed: 71 additions & 54 deletions

File tree

anypytools/abcutils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def execute_anybodycon(
139139
140140
Parameters
141141
----------
142-
macro : list of str
142+
macro : list[str]
143143
List of macros strings to pass to the AnyBody Console Application
144-
logfile : file like object, optional
144+
logfile : typing.TextIO, optional
145145
An open file like object to write to pipe the output of AnyBody
146146
into. (Defaults to None, in which case it will use sys.stdout)
147147
anybodycon_path : str, optional
148-
Path to the AnyBodyConsole application. Default to None, in which
148+
Path to the AnyBodyConsole applibcation. Default to None, in which
149149
case the default installed AnyBody installation will be looked up
150150
in the Windows registry.
151151
timeout : int, optional
@@ -165,15 +165,15 @@ def execute_anybodycon(
165165
interactive_mode : bool, optional
166166
If set to True, the AnyBody Console application will be started in iteractive
167167
mode, and will not shutdown autmaticaly after running the macro. (Defaults to False)
168-
debug_mode : int
168+
debug_mode : int, optional
169169
The AMS debug mode to use. Defaults to 0 which is disabled. 1 correspond to
170170
crashdump enabled
171171
folder :
172172
the folder in which AnyBody is executed
173173
174174
Returns
175175
-------
176-
int
176+
error_code : int
177177
The return code from the AnyBody Console application.
178178
179179
"""
@@ -497,7 +497,7 @@ class AnyPyProcess(object):
497497
String which will be prefixed to the generated log files. This can be used
498498
to assign a more meaningfull name to a batch of logfiles.
499499
(Defaults to None)
500-
python_env : pathlike, optional
500+
python_env : str, optional
501501
Path to a python environment/installation that the AnyBody Modeling System
502502
should use for Python Hooks. This will added the ``PYTHONHOME`` environment variable and
503503
prepended to the ``PATH`` before starting the AnyBody Console application.
@@ -746,10 +746,10 @@ def start_macro(
746746
747747
Parameters
748748
----------
749-
macrolist : list of macrocommands, optional
749+
macrolist : list, optional
750750
List of anyscript macro commands. This may also be obmitted in
751751
which case the previous macros will be re-run.
752-
folderlist : list of str, optional
752+
folderlist : list[str], optional
753753
List of folders in which to excute the macro commands. If `None` the
754754
current working directory is used. This may also be a list of
755755
tuples to specify a name to appear in the output

anypytools/macroutils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_macro(self, index, **kwarg):
7979
8080
Returns
8181
-------
82-
string
82+
str
8383
A string with the AnyScript macro
8484
8585
"""
@@ -139,9 +139,9 @@ class SetValue(MacroCommand):
139139
140140
Parameters
141141
----------
142-
var : string
142+
var : str
143143
An AnyScript variable.
144-
value : number or list of number
144+
value : float | list[float]
145145
A value or list of values to assign to the AnyScript variable.
146146
147147
Examples
@@ -232,13 +232,13 @@ def _format_macro(self, val):
232232
class SetValue_random(SetValue):
233233
"""Create a 'Set Value' macro command from a distribution.
234234
235-
The value is connected to a distibution in scipy.stats.distributions.
235+
The value is connected to a distibution in ``scipy.stats.distributions``.
236236
237237
Parameters
238238
----------
239239
var : str
240240
An AnyScript variable.
241-
frozen_distribution : <scipy.stats.distributions.rv_frozen>
241+
frozen_distribution :
242242
A frozen distribution from scipy.stats.distributions
243243
default_lower_tail_probability : float
244244
The lower tail probability of the default value. Defaults to 0.5 which
@@ -430,11 +430,11 @@ class ExtendOutput(MacroCommand):
430430
----------
431431
var_name : str
432432
Name of the variable in output.
433-
value : any
433+
value : int | float | str | np.ndarray
434434
The value to add to the output.
435435
436-
Examples:
437-
---------
436+
Examples
437+
--------
438438
>>> ExtendOutput('MyVar', 23.5)
439439
print MyVar = 23.5;
440440
@@ -719,8 +719,7 @@ class AnyMacro(MutableSequence):
719719
>>> mg = AnyMacro(number_of_macros = 22)
720720
>>> mg.append( Load('c:/MyModel/model.main.any', defs = {}, paths = {} ) )
721721
>>> mg.append( SetValue('Main.myvar', 12.3) )
722-
>>> mg.extend( [RunOperation('Main.Study.Kinematics'),
723-
Dump('Main.Study.Output.MyVar') ] )
722+
>>> mg.extend( [RunOperation('Main.Study.Kinematics'), Dump('Main.Study.Output.MyVar') ] )
724723
>>> mg
725724
[['load "c:/MyModel/model.main.any"',
726725
'classoperation Main.myvar "Set Value" --value="12.3"',

anypytools/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"anybodycon_version",
4949
"AMSVersion",
5050
"parse_anybodycon_output",
51-
"wraptext"
51+
"wraptext",
5252
]
5353

5454

docs/api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
:::{toctree}
55
:maxdepth: 2
6-
:hidden:
76

87
pytest-plugin
9-
apidocs/index
8+
api/index
109

1110
:::

docs/conf.py

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,53 @@
55
from anypytools import __version__ as ANYPYTOOLS_VERSION
66

77
# load extensions
8-
extensions = ["myst_nb", "autodoc2", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx_design"
8+
extensions = [
9+
"myst_nb",
10+
"autodoc2",
11+
"sphinx.ext.intersphinx",
12+
"sphinx.ext.autosummary",
13+
"sphinx.ext.napoleon",
14+
"sphinx_design"
15+
]
16+
17+
18+
autodoc2_packages = [
19+
"../anypytools",
20+
]
921

22+
autodoc2_output_dir = "api"
23+
autodoc2_render_plugin = "rst"
1024

25+
autodoc2_module_all_regexes = [
26+
r"anypytools\..*",
1127
]
1228

29+
30+
nitpick_ignore = [
31+
('py:class', 'optional'),
32+
('py:class', 'np.ndarray'),
33+
]
34+
35+
36+
# autodoc2_render_plugin = "myst"
37+
38+
# autodoc2_hidden_objects = ["dunder", "inherited"]
39+
autodoc2_replace_annotations = [
40+
("re.Pattern", "typing.Pattern"),
41+
("markdown_it.MarkdownIt", "markdown_it.main.MarkdownIt"),
42+
]
43+
autodoc2_replace_bases = [
44+
("sphinx.directives.SphinxDirective", "sphinx.util.docutils.SphinxDirective"),
45+
]
46+
47+
napoleon_use_ivar = True
48+
49+
# Napoleon settings for NumPy-style
50+
napoleon_google_docstring = False
51+
napoleon_numpy_docstring = True
52+
napoleon_use_admonition_for_notes = False
53+
54+
1355
intersphinx_mapping = {
1456
"python": ("https://docs.python.org/3/", None),
1557
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
@@ -106,29 +148,6 @@
106148
"doc_path": "docs",
107149
}
108150

109-
110-
autodoc2_packages = [
111-
{
112-
"path": "../anypytools",
113-
# "exclude_files": ["_docs.py"],
114-
}
115-
]
116-
117-
autodoc2_module_all_regexes = [
118-
r"anypytools\..*",
119-
]
120-
121-
122-
autodoc2_render_plugin = "myst"
123-
124-
# autodoc2_hidden_objects = ["dunder", "inherited"]
125-
autodoc2_replace_annotations = [
126-
("re.Pattern", "typing.Pattern"),
127-
("markdown_it.MarkdownIt", "markdown_it.main.MarkdownIt"),
128-
]
129-
autodoc2_replace_bases = [
130-
("sphinx.directives.SphinxDirective", "sphinx.util.docutils.SphinxDirective"),
131-
]
132151
# autodoc2_docstring_parser_regexes = [
133152
# ("myst_parser", "myst"),
134153
# (r"myst_parser\.setup", "myst"),

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ User guide <user-guide/index>
7575
## API Documenation
7676

7777
* [PyTest plugin for testing AnyBody models](pytest-plugin)
78-
* [API reference](apidocs/index)
78+
* [API reference](api/index)
7979

8080
:::{toctree}
8181
:maxdepth: 2

docs/pytest-plugin.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ collect and run AnyScript files with a `test_` prefix (e.g.
77
`Main.RunTest` operation if it exists. If the models produce error while
88
loading and running, the framework considers it a failed test.
99

10-
.. autodoc2-summary::
11-
:renderer: myst
10+
:::{autodoc2-summary}
11+
:renderer: myst
1212

1313
anypytools.pytest_plugin
14-
14+
:::

pixi.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ astroid = ">=2.7,<4"
9797
sphinxcontrib-napoleon = ">=0.7,<0.8"
9898

9999
[feature.docs.pypi-dependencies]
100-
sphinx-autodoc2 = { git = "https://github.com/AnyBody-Research-Group/sphinx-autodoc2", branch = "main" }
100+
sphinx-autodoc2 = { git = "https://github.com/AnyBody-Research-Group/sphinx-autodoc2", rev = "215f04e72efc7294a0c93de4f038b9a1aa806e8f" }
101101

102102
[feature.docs.tasks]
103103
build-docs = {cmd="sphinx-build -nW --keep-going -b html docs/ docs/_build/html"}

0 commit comments

Comments
 (0)