-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix sphinx warnings #1312
fix sphinx warnings #1312
Conversation
@@ -1,2 +1,5 @@ | |||
.. automodule:: MDAnalysis.lib._distances | |||
C-distances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sphinx really wants to have these headings. I don't know why though.
I also think the cross reference warnings are hard to get rid of. They might be a sphinx bug. I'm glad to hear any ideas where they might come from. |
output = zip(*C.results) | ||
with open("eigenvalues.dat", "w") as outputfile: | ||
for item in output[1]: | ||
outputfile.write(item + "\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the \n
here broke the docs. This has the be set to a raw string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this break the docs???
(Wouldn't this be considered a bug in sphinx?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is normal python behavior. \n
is an escape sequence and just like for docs with a latex string inside we need to tell python the string is a raw string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't realized that this was Python code inside a doc string...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you understand me correct. This is a escape sequence in a string. This is a problem for sphinx in any doc string no matter where it stands. That's why we have the raw string hint in the docs for documentation.
See Also | ||
-------- | ||
:class:`GNMAnalysis` | ||
|
||
|
||
.. versionchanged:: 0.16.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found by trial and error that the normal .. *
sections only work in numpy docs when we leave two blank lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kain88-de I love you! This was ruining my life!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the explanation for this in an old sphinx issue. But yeah it's a weird bug/feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note to our doc docs.... keeping this kind of knowledge around is really helpful.
We should also add (if we haven't already) that
- numpy See Also does not work well for us
- do not use "Examples"/"Example" as a normal section heading unless as a numpy example section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Also
works really fine for me Where have you seen problems.
Were do we document our docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In @jbarnoud 's PR #1247 IIRC. EDIT: see #1247 (comment)
Documenting docs: see wiki style guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you find that See Also works then remove the section in the style guide where I recommend against using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've already done that.
and K. Lindorff-Larsen. ENCORE: Software for quantitative ensemble | ||
comparison. *PLoS Comput Biol*, **11** (2015), e1004415. doi: | ||
`10.1371/journal.pcbi.1004415`_ | ||
[Tiberti2015]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here I have a fundamental question. Sphinx doesn't like that we define the reference [Tiberti2015]
in several places. So far in my clean up here my strategy was to use one definition in the source code and use that link in the rst files. Is that OK. Should we go a different route?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit hackish, we could just uniquely define it, so call it 2015b]
to avoid the collision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I like to have just one definition in the docs. Then we are guaranteed to always use the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed your advice now.
This PR as of now should half our sphinx errors. |
There is one last class of errors that I just can't fix. For some reason unknown to me currently sphinx sometimes wants to cross reference occurences of
We really need to fix them since they lead to completely wrong docs as shown in #1312 (comment) |
OK I should have fixed all the errors in the docs now. There seems to be some new pylint errors though. |
Also I plan to rebase the history to something sane once all tests are passing. |
74dffc4
to
29a96b7
Compare
I did a lot of changes since this review
@richardjgowers I'm so far done now.
It would be nice if someone could review it again to make sure everything is still alright. The PR touches a lot of things. |
@@ -536,7 +536,6 @@ def q1q2(u, selection='all', radius=4.5, | |||
# until then it remains because we don't have the functionality | |||
# elsewhere. | |||
|
|||
@deprecate(new_name="Contacts", message="This class will be removed in 0.17") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having the deprecate at the top of the class made sphinx think this is a function and not a class. Moving it to the __init__
function fixed that. Bonus we can also use the recent sphinx version now.
tests all look like they pass. It's just the one with coverage that always freezes at the end. |
On 04/17/2017 07:11 PM, Max Linke wrote:
***@***.**** commented on this pull request.
------------------------------------------------------------------------
In package/MDAnalysis/analysis/gnm.py
<#1312 (comment)>:
>
- .. SeeAlso:: :class:`GNMAnalysis`
+ Notes
+ -----
+ The `MassWeight` option does not perform a true mass weighting but
+ weighting by the number of atoms in each residue; the name of the parameter
+ exists for historical reasons and will be removed in 0.17.0. Until then,
+ setting `MassWeight` to anything but ``None`` will override `weights`.
+
+ See Also
+ --------
+ :class:`GNMAnalysis`
+
.. versionchanged:: 0.16.0
|See Also| works really fine for me Where have you seen problems.
Were do we document our docs?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1312 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUWuhIIva06OQqbOblvMNGMg4XOMnYdks5rw51QgaJpZM4M-pn0>.
I had problems, but from what I see, the double new line should fix them.
|
Generally speaking, if one writes docs one actually needs to look at the NumPy doc format and reST to write syntactically correct docs. Not everything that looks reasonable actually works. Probably the most useful page for me is the NumPy example
I just added these links to https://github.com/MDAnalysis/mdanalysis/wiki/Style-Guide#writing-docstrings
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks. The only reason why I am blocking is because of the handling of the box
keyword (see comments).
package/MDAnalysis/analysis/gnm.py
Outdated
|
||
.. versionchanged:: 0.16.0 | ||
Made :meth:`generate_output` a private method :meth:`_generate_output`. | ||
|
||
.. deprecated:: 0.16.0 | ||
Instead of ``MassWeight=True`` use ``weights="size"``. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a trailing blank empty line necessary?
(I don't care if it's there or not if it's aesthetics but would want to know if there are functional/weird reasons.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. Might be a leftover from some early tries fixing the sphinx warnings.
@@ -151,8 +151,12 @@ class TransTable(object): | |||
|
|||
Parameters | |||
---------- | |||
n_atoms, n_residues, n_segments : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a doc pattern that needs to be unlearned by us all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is valid for numpy docs. But Napoleon doesn't work well with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad, I liked this pattern. It avoided quite a lot of repetition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it still works in some places. We used it more often. But there also isn't a good way to look at the intermediate rEst to know what exactly is going on.
package/MDAnalysis/core/topology.py
Outdated
@@ -165,7 +169,7 @@ class TransTable(object): | |||
|
|||
Attributes | |||
---------- | |||
n_atoms, n_residues, n_segments : int | |||
`n_atoms`, n_residues, n_segments : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be individual entries, shouldn't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if escaping the first one works, it seems inconsistent with all the other docs that do not have backtics on variable names or argument names in these lists.
@@ -1362,7 +1362,7 @@ class Bonds(_Connection): | |||
|
|||
Must be initialised by a list of zero based tuples. | |||
These indices refer to the atom indices. | |||
Eg: [(0, 1), (1, 2), (2, 3)] | |||
Eg: [(0, 1), (1, 2), (2, 3)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"E.g.," contains periods and is followed by a comma. think it makes more sense to show the list of tuples as code.
E.g., ` [(0, 1), (1, 2), (2, 3)]`
@@ -1416,8 +1416,7 @@ class Angles(_Connection): | |||
"""Angles between three atoms | |||
|
|||
Initialise with a list of 3 long tuples | |||
Eg: | |||
[(0, 1, 2), (1, 2, 3), (2, 3, 4)] | |||
Eg: [(0, 1, 2), (1, 2, 3), (2, 3, 4)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"E.g.," contains periods and is followed by a comma. think it makes more sense to show the list of tuples as code.
@@ -68,7 +68,7 @@ def search(self, atoms, radius, level='A'): | |||
|
|||
Parameters | |||
---------- | |||
atoms : AtomGroup or Atom | |||
atoms : AtomGroup or `Atom` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would Atom
be recognized if the types were separated by comma and not "or", i.e.,
atoms : AtomGroup, Atom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope it doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But tellling it exactly the class we mean works and it links correctly. That's not bad.
package/MDAnalysis/lib/util.py
Outdated
reset : boolean | ||
start the stream from the beginning (either :meth:`reset` or :meth:`seek`) | ||
when the class instance is constructed | ||
close : booelan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean (typo)
Also note that bool
gets linked to bool whereas boolean
is left as text.
package/MDAnalysis/lib/util.py
Outdated
Notes | ||
----- | ||
By default, this stream will *not* be closed by :keyword:`with` and | ||
:meth:`close` (see there) unless the *close* keyword is set to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use backtics for name references:
*close* --> `close`
@@ -203,7 +200,8 @@ def guess_bonds(atoms, coords, **kwargs): | |||
|
|||
lower_bound = kwargs.get('lower_bound', 0.1) | |||
|
|||
box = kwargs.get('box', None) | |||
if box: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bad and will typically fail for box
being an array with ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
You should use
if box is not None:
or similar.
Or do a try/except
.
Make sure to assign None
in all cases where there is no array. Downstream code might actually rely on box = None
and not handle box = False
or box = 0
correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is not None
check is enough. That will reflect the old behavior and the numpy asarray call later ensures us the we have an array.
On 04/17/2017 08:48 PM, Oliver Beckstein wrote:
How does this PR interact with @jbarnoud <https://github.com/jbarnoud>
's #1247 <#1247> ?
Ties in with #1277 <#1277>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1312 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUWulAbkxaGOCYBALv-UzCo7g_NGjyDks5rw7QQgaJpZM4M-pn0>.
My #1247 is broken. I'll rework it on top of this commit.
|
This also activates the .. TODO:: sections to be legal
use more ci-helpers goodies.
They are triggered now. I don't know how to fix them. I think they are triggered now because pylint used to be tripped by errors in the docs. Why that happened I'm not sure.
The original cdn will be taken down on 30 April 2017
@orbeckst fixed your remarks |
Fixes #1313
Changes made in this Pull Request:
This only fixes the warnings when we search for modules. The cross-reference
warnings aren't fixed. But that seems to be a bug inside of sphinx.
PR Checklist