Sphinx describe valid input values to api
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Bleepage Open
--
Chapters
00:00 Question
02:29 Accepted answer (Score 3)
04:07 Thank you
--
Full question
https://stackoverflow.com/questions/2997...
Accepted answer links:
[ZipFile]: https://docs.python.org/3/library/zipfil...
[os.chmod]: https://docs.python.org/2/library/os.htm...
[format specification mini-language]: https://docs.python.org/3/library/string...
[numpy.array]: https://numpy.org/doc/stable/reference/g...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #api #flask #pythonsphinx #documentationgeneration
#avk47
ACCEPTED ANSWER
Score 3
A good approach is to look at existing documentation of a popular and well-documented project such as Python itself. Python documentation uses several methods to documenting parameters that can take one of a set of values:
- Textual form as in ZipFile:
The mode parameter should be 'r' to read an existing file, 'w' to truncate and write a new file, or 'a' to append to an existing file.
- Bullet list of values, possibly with descriptions, as in os.chmod:
mode may take one of the following values (as defined in the stat module) or bitwise ORed combinations of them:
- stat.S_ISUID
- stat.S_ISGID
- stat.S_ENFMT
- Table of values and their descriptions as in format specification mini-language.
Edit
In the spirit of this answer, the documentation for the numpy.array order parameter starts as follows:
order : {'K', 'A', 'C', 'F'}, optional
Here we see that the allowed values are written as the type. That is, rather than specifying that order takes the type str and then explaining what specific str values are allowed, the set of values that are allowed are listed as the type and users infer the type is str.