|
18 | 18 | The :attr:`module_level_variable1` module level variables must be documented |
19 | 19 | in an inline docstring immediately following the variable. |
20 | 20 |
|
| 21 | +See Also: |
| 22 | + `Extension Documentation`_ for more details on the extension. |
| 23 | +
|
21 | 24 | .. todo:: |
22 | 25 | * For TODOs directive module |
23 | 26 | * You have to also use ``sphinx.ext.todo`` extension |
24 | 27 |
|
25 | 28 | .. _Sphinx Python Style Guide: |
26 | 29 | https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html |
| 30 | +
|
| 31 | +.. _Extension Documentation: |
| 32 | + https://marketplace.visualstudio.com/items?itemName=rodolphebarbanneau.python-docstring-highlighter |
27 | 33 | """ |
28 | 34 |
|
29 | 35 | module_level_variable1 = 12345 |
|
36 | 42 | """ |
37 | 43 |
|
38 | 44 |
|
39 | | -def function_with_types_in_docstring(param1, param2): |
| 45 | +def function_with_types_in_docstring(param1, param2, param3): |
40 | 46 | """Example function with types documented in the docstring. |
41 | 47 |
|
42 | 48 | `PEP 484`_ type annotations are supported. If attribute, parameter, and |
43 | 49 | return types are annotated according to `PEP 484`_, they do not need to be |
44 | 50 | included in the docstring: |
45 | 51 |
|
46 | 52 | :param int param1: The first parameter. |
47 | | - :param str param2: The second parameter. |
48 | | -
|
| 53 | + :param int param2: The second parameter. |
| 54 | + :param str param3: The third parameter. |
| 55 | + :return: The return value. True for success, False otherwise. |
49 | 56 | :rtype: bool |
50 | | - :returns: The return value. True for success, False otherwise. |
51 | 57 |
|
52 | 58 | .. _PEP 484: |
53 | 59 | https://www.python.org/dev/peps/pep-0484/ |
54 | 60 | """ |
55 | 61 | pass |
56 | 62 |
|
57 | 63 |
|
58 | | -def function_with_pep484_type_annotations(param1: int, param2: str) -> bool: |
| 64 | +def function_with_pep484_type_annotations( |
| 65 | + param1: int, param2: int, param3: str |
| 66 | +) -> bool: |
59 | 67 | """Example function with PEP 484 type annotations. |
60 | 68 |
|
61 | 69 | :param param1: The first parameter. |
62 | 70 | :param param2: The second parameter. |
63 | | - :returns: The return value. True for success, False otherwise. |
| 71 | + :param param3: The third parameter. |
| 72 | + :return: The return value. True for success, False otherwise. |
64 | 73 | """ |
65 | 74 | return True |
66 | 75 |
|
@@ -92,15 +101,15 @@ def module_level_function(param1, param2=None, *args, **kwargs): |
92 | 101 | :param kwargs: Miscellaneous. |
93 | 102 |
|
94 | 103 | :rtype: bool |
95 | | - :returns: True if successful, False otherwise. |
| 104 | + :return: True if successful, False otherwise. |
96 | 105 |
|
97 | 106 | The return type is optional and may be specified using the ``:rtype:`` |
98 | 107 | directive. |
99 | 108 |
|
100 | | - The ``:returns:`` description may span multiple lines and paragraphs. |
| 109 | + The ``:return:`` description may span multiple lines and paragraphs. |
101 | 110 | Following lines should be indented to match the first line. |
102 | 111 |
|
103 | | - The ``:returns:`` description supports any reStructuredText formatting, |
| 112 | + The ``:return:`` description supports any reStructuredText formatting, |
104 | 113 | including literal blocks:: |
105 | 114 |
|
106 | 115 | { |
@@ -218,8 +227,8 @@ def example_method(self, param1, param2): |
218 | 227 |
|
219 | 228 | :param str param1: The first parameter. |
220 | 229 | :param int param2: The second parameter. |
221 | | - :returns: True if successful, False otherwise. |
222 | | - :rtype: bool |
| 230 | + :return: A sequence of strings. |
| 231 | + :rtype: Sequence[str] |
223 | 232 |
|
224 | 233 | .. note:: |
225 | 234 | Do not include the `self` parameter in the ``:param:``directives. |
|
0 commit comments