-
Notifications
You must be signed in to change notification settings - Fork 621
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
Adds hyperlinks to docstrings of Qobj and Qobjevo class #1499
Conversation
@purva-thakre Thank you for opening this! Let us know when it's ready and we'll review. Please ask if you have any questions or get stuck with anything. |
@hodgestar I do not know how to link any of the methods listed in a table like in the methods table for Qobj class here. I tried to link The screenshot below tries to link an attribute which was corrected to a method later. I forgot to screenshot the one where its I think this has to do with how Appreciate any pointers about any workaround to this. If not, I can just skip the links in the table because there'e no problems to adding links to other docstrings. |
Have you tried
? |
@BoxiLi Yes, I have not used parentheses for functions not in the public API. These changes are still local and haven't been pushed yet. My issue is with the I think this is due to how Sphinx tables are defined and a similar manner to define python object references as well. One workaround to this could be adding reference labels to these functions. |
Well for one that table of methods just shouldn't exist - it can all be deleted. It's a holdover from a previous method of doing API documentation, but now since we use numpydoc, the equivalent gets done automatically for us right below where that table appears in the docs. You'll not succeed at any sort of formatting in that table, because all the headers are parsed as literal strings, and (mostly) aren't subject to rst formatting at all. This isn't a feature of all rst tables, just this implicit table created from a definition list. Second, should you want it elsewhere, the minimal magic incantation is |
Thanks ! I have removed the table. Couple of questions :
|
I don't think we should link to non-public API in the doc. Non-public API should not (at least no encouraged) be used outside of QuTiP because we may change it without issuing a deprecation warning. Besides,
To make the life simpler, I would recommend to use the shortcut |
@purva-thakre, is this still a draft PR? |
@nathanshammah Yes, I still have to make a couple of changes to this. |
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.
Thank you for making the PR - I saw lots of fixed typos, and places where added links definitely helped the documentation.
However, I only got part way through, but really there's also a lot of changes that aren't appropriate here, sorry. Most of Qobj
and QobjEvo
already do link when they should (though it's not quite 100%). A few points:
- Don't put a link on a word if it doesn't specifically refer to the object you're linking to. For example, the words "ket", "bra" and "operator" should almost never have links - they're just words, and they're not referring to any function or module. The word "tensor" usually just means "tensor", it shouldn't be a link to the module. The reason not to do this is that it makes it seem like we're giving a special meaning to common words, and it dilutes the use of "real" links.
- "Raises" sections should be used very sparingly. There's no need to point out that passing an incorrect value or an incorrect type will cause a
ValueError
orTypeError
, for example. The reason is that this just dilutes the available information - it's always the case that an incorrect value will raiseValueError
, so the programmer doesn't get any new information from this. It's more appropriate to use the "Parameters" section to document what's allowed; a programmer can assume that if they violate that, a suitable exception will be raised. The "Raises" section should only be for very non-obvious errors, or errors that even a programmer who has read the "Parameters" section might reasonably make accidentally. - Don't put the error message in the description of a "Raises" section. The message is intended to inform the user when it appears, but when you're writing a "Raises" section, that's the purpose of the description below the type of the exception; there's no additional information gained from having the message, and it clutters up the docs.
- Take care not to change the meaning of sentences when you're adding in additional formatting - I saw a few places where changes in the formatting accidentally deleted a word, or hid some extra meaning.
- In RST, single backticks (
`
) produce italics, not monospaced text. - There's no need to change
:class:
/:func:
/:meth:
directives into:obj:
directives - either style is totally fine. Don't worry about it now that you've done it, though, it's fine to leave them in the new style (because either is fine).
Do you have the docs building correctly? It's worth checking to make sure that the changes you made are showing up the way you expected. In the worst case scenario, GitHub now builds them for you whenever you push changes. Click on the "Checks" tab at the top of the PR, and on the right of the screen there's an "Artifacts" button - you can download the file there, and open "index.html" in your web browser to get the full set of rendered docs.
Yeah, I was worried if linking words like ket, bra were needed or not. I'll remove them.
No problem. I will remove errors created due to incorrect parameters and other obvious errors + error messages. I will add a parameters section if needed to clarify over ValueError.
I think the accidental deletes might have been due to getting caught in some cut/copy/paste flow.
Yes, I do. I was a bit confused about how to try to format to functions not in API doc. So, I still tried to link a |
Description
Adds hyperlinks for functions, classes, attributes etc. wherever possible.
:obj:`.some_func`
TypeError
andValueError
etc. in docstrings when an error of either type is raised by a function. Most of these might not be needed as this link advises to provide information about only the obvious errors. I read the link after making the changes. If needed, the new additions can be removed from the docstrings.Related issues or PRs
One of the fixes for issue 71 in documentation.
Changelog
Add hyperlinks in documentation and errors in docstrings of functions in qobj and qobevo