Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yt-project
GitHub Repository: yt-project/yt
Path: blob/main/doc/docstring_idioms.txt
928 views
1
Idioms for Docstrings in yt
2
===========================
3
4
For a full list of recognized constructs for marking up docstrings, see the
5
Sphinx documentation:
6
7
http://www.sphinx-doc.org/en/master/
8
9
Specifically, this section:
10
11
http://www.sphinx-doc.org/en/master/usage/restructuredtext/
12
http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax
13
14
Variables in Examples
15
---------------------
16
17
In order to construct short, useful examples, some variables must be specified.
18
However, because often examples require a bit of setup, here is a list of
19
useful variable names that correspond to specific instances that the user is
20
presupposed to have created.
21
22
* `ds`: a dataset, loaded successfully
23
* `sp`: a sphere
24
* `c`: a 3-component "center"
25
* `L`: a 3-component vector that corresponds to either angular momentum or a
26
normal vector
27
28
Cross-Referencing
29
-----------------
30
31
To enable sufficient linkages between different sections of the documentation,
32
good cross-referencing is key. To reference a section of the documentation,
33
you can use this construction:
34
35
For more information, see :ref:`image_writer`.
36
37
This will insert a link to the section in the documentation which has been
38
identified with `image_writer` as its name.
39
40
Referencing Classes and Functions
41
---------------------------------
42
43
To indicate the return type of a given object, you can reference it using this
44
construction:
45
46
This function returns a :class:`ProjectionPlot`.
47
48
To reference a function, you can use:
49
50
To write out this array, use :func:`save_image`.
51
52
To reference a method, you can use:
53
54
To add a projection, use :meth:`ProjectionPlot.set_width`.
55
56