mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Get function signature right since the beginning
This commit is contained in:
parent
02119aba8d
commit
ae3eab278c
@ -28,8 +28,7 @@ To use autodoc, first add it to the list of enabled extensions:
|
||||
]
|
||||
|
||||
Next, move the content of the ``.. py:function`` directive to the function
|
||||
docstring in the original Python file and add an optional ``kind`` argument,
|
||||
as follows:
|
||||
docstring in the original Python file, as follows:
|
||||
|
||||
.. code-block:: python
|
||||
:caption: lumache.py
|
||||
|
@ -178,7 +178,7 @@ function ``get_random_ingredients`` like this:
|
||||
.. code-block:: python
|
||||
:caption: lumache.py
|
||||
|
||||
def get_random_ingredients():
|
||||
def get_random_ingredients(kind=None):
|
||||
return ["eggs", "bacon", "spam"]
|
||||
|
||||
You can now run ``make doctest`` to execute the doctests of your documentation.
|
||||
@ -214,7 +214,7 @@ for easy examination. It is now time to fix the function:
|
||||
:caption: lumache.py
|
||||
:emphasize-lines: 2
|
||||
|
||||
def get_random_ingredients():
|
||||
def get_random_ingredients(kind=None):
|
||||
return ["shells", "gorgonzola", "parsley"]
|
||||
|
||||
And finally, ``make test`` reports success!
|
||||
|
Loading…
Reference in New Issue
Block a user