Closed lamblin closed 10 years ago
Here are some things worth noting when you work on docstring formatting.
While we follow the Numpy standard for docstrings, we open and close the docstrings differently (see http://deeplearning.net/software/pylearn/v2_planning/API_coding_style.html) :
You do not need to add an extra blank line before the closing quotes of
a multi-line docstring. Also, we ask that the first line of a multi-line
docstring should contain only the opening quotes.
For example:
# Good.
"""
This is a multi-line docstring.
Which means it has more than one line.
"""
# Bad.
"""This is a multi-line docstring.
Which means it has more than one line.
"""
Also, make sure the colon after the parameter is surrounded by spaces, otherwise it won't be parsed correctly:
# Good
"""
Parameters
----------
a : int
the first value
b : int
the second value
"""
# Bad
"""
Parameters
----------
a: int
the first value
b: int
the second value
"""
EDIT: There is an extension installed in our doc called sphinx.ext.todo
which you can use to add WRITEMEs to the docstrings:
"""
.. todo::
WRITEME
"""
It has the advantage of looking nicer when rendered as HTML than a plain WRITEME, so I suggest we take advantage of it when formatting the docstrings.
Do this fix the display problem? Is so, the second part about the semi-colon should be added in the URL you sended.
On Tue, Jul 9, 2013 at 2:11 PM, vdumoulin notifications@github.com wrote:
Here are some things worth noting when you work on docstring formatting.
While we follow the Numpy standard for docstrings, we open and close the docstrings differently (see http://deeplearning.net/software/pylearn/v2_planning/API_coding_style.html) :
You do not need to add an extra blank line before the closing quotes of a multi-line docstring. Also, we ask that the first line of a multi-line docstring should contain only the opening quotes.
For example:
Good.
""" This is a multi-line docstring. Which means it has more than one line. """
Bad.
"""This is a multi-line docstring. Which means it has more than one line. """
Also, make sure the colon after the parameter is surrounded by spaces, otherwise it won't be parsed correctly:
Good"""Parameters----------a : int the first valueb : int the second value"""
Bad"""Parameters----------a: int the first valueb: int the second value"""
— Reply to this email directly or view it on GitHubhttps://github.com/lisa-lab/pylearn2/issues/372#issuecomment-20693893 .
It does not fix the problem, which seems to be appearing only sometimes. For example, compare expr
and get_gradients
here:
http://deeplearning.net/software/pylearn2/library/costs.html#module-pylearn2.costs.cost
One has Parameters: displayed correctly, and the other has not.
I think it has more to do with the length of the text to be displayed; if you play with the size of your browser's window, you can get both Parameters: to be displayed incorrectly.
What it does change, however, is that the type of a parameter is displayed correctly, i.e. not in bold, as seen on that webpage.
ok, but adding it in the doc would help people know about this.
On Tue, Jul 9, 2013 at 4:01 PM, vdumoulin notifications@github.com wrote:
It does not fix the problem, which seems to be appearing only sometimes. For example, compare expr and get_gradients here:
http://deeplearning.net/software/pylearn2/library/costs.html#module-pylearn2.costs.cost
One has Parameters: displayed correctly, and the other has not.
I think it has more to do with the length of the text to be displayed; if you play with the size of your browser's window, you can get both Parameters:\ to be displayed incorrectly.
What it does change, however, is that the type of a parameter is displayed correctly, i.e. not in bold, as seen on that webpage.
— Reply to this email directly or view it on GitHubhttps://github.com/lisa-lab/pylearn2/issues/372#issuecomment-20701200 .
I agree with you on that. I'll add it with the doc and make a pull request for that plus some warnings fixes.
Oops! I thought that documentation was under Pylearn2, but it is actually under Pylearn.
I edited my post to add a mention to sphinx.ext.todo
.
This ticket is not done yet. I need to verify all those files.
ignored
@memimo set up the numpydoc extension for Sphinx (gh-42), now we have to make sure the documentation generates cleanly (no errors or warning, displayed correctly, etc.).
Also, classes and methods lacking docstrings should have a docstring reading "WRITEME", so we can later grep for them and fill them in.
We will split the repository in:
Numpy standard for docstrings can be found at https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt#docstring-standard
If some classes (or functions/methods) already have well-formatted docstrings using another standard, that is OK for the moment, but newly-written or newly-formatted ones should follow the above convention.