The main thread, as already mentioned in other answers, probably follows the Sphinx path so you can use Sphinx to create these unusual documents later.
At the same time, I personally sometimes use the built-in style of comments.
def complex( # Form a complex number real=0.0, # the real part (default 0.0) imag=0.0 # the imaginary part (default 0.0) ):
Another example here, with some tiny details documented in a line:
def foo(
Benefits (as @ mark-horvath already mentioned in another comment):
- Most importantly, the parameters and their document always remain together, which gives the following advantages:
- Less input (no need to repeat the variable name)
- Easier maintenance when changing / deleting a variable. After renaming a parameter, there will never be a paragraph with a parameter document.
- and easier to find a missing comment.
Now, some might think that this style looks ugly. But I would say ugly is a subjective word. A more neutral way is to say that this style is not mainstream, so it may seem less familiar to you and therefore less convenient. Again, โconvenientโ is also a subjective word. But the fact is that all the advantages described above are objective. You cannot reach them if you follow the standard path.
We hope that someday in the future there will be a tool for generating documents that can also use such a built-in style. This will encourage adoption.
PS: This answer stems from my own preference for using inline comments whenever I see fit. I use the same inline style to document the dictionary too.
RayLuo Sep 19 '16 at 20:15 2016-09-19 20:15
source share