Use with Sphinx#
Add dargs.sphinx to the extensions of conf.py:
extensions = [
'dargs.sphinx',
]
Then dargs directive will be enabled:
.. dargs::
:module: dargs.sphinx
:func: _test_argument
where _test_argument returns an Argument. The documentation will be rendered as:
- test:#
- type:
str|dictargument path:testThis argument/variant is only used to test.
- test_argument:#
- type:
strargument path:test/test_argumentThis argument/variant is only used to test.
- test_list:#
- type:
typing.List[int], optionalargument path:test/test_list
Depending on the value of test_variant, different sub args are accepted.
- test_variant:#
This argument/variant is only used to test.
test_variant_argument: This argument/variant is only used to test.
When test_variant is set to
test_variant_argument:This argument/variant is only used to test.
- test_repeat_list:#
- type:
listargument path:test[test_variant_argument]/test_repeat_listThis argument/variant is only used to test.
This argument takes a list with each element containing the following:
- test_repeat_item:#
- type:
boolargument path:test[test_variant_argument]/test_repeat_list/test_repeat_itemThis argument/variant is only used to test.
- test_repeat_dict:#
- type:
dictargument path:test[test_variant_argument]/test_repeat_dictThis argument/variant is only used to test.
This argument takes a dict with each key-value pair containing the following:
- test_repeat_item:#
- type:
boolargument path:test[test_variant_argument]/test_repeat_dict/test_repeat_itemThis argument/variant is only used to test.
A list of Argument is also accepted.
- test1:#
- type:
intargument path:test1Argument 1
- test2:#
- type:
NoneType|floatargument path:test2Argument 2
- test3:#
- type:
typing.List[str], optional, default:['test']argument path:test3Argument 3
- base:#
To write Markdown files with MyST-Parser, one can use:
```{eval-rst}
.. dargs::
:module: dargs.sphinx
:func: _test_argument
```
Cross-referencing Arguments#
Both the following ways will create a cross-reference to the argument:
Both :dargs:argument:`this <test/test_argument>` and :ref:`this <test/test_argument>` will create a cross-reference to the argument!
It will be rendered as:
Index page#
The arguments will be added into the Index page. See test_argument in the Index page.