-
Notifications
You must be signed in to change notification settings - Fork 1
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
Request for decision: how should we mark up types in parameter lists #7
Comments
|
Another thought: besides unions, there are other potentially useful notations from Python's type hints syntax. For example, |
OTOH,
It's in this link: https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists
I still think |
That seems like a strawman. We all agree it's not a good idea to literally use type annotations in the signature -- it would be too verbose. But type expressions have other uses (e.g. in casts) and just because in the docs we don't integrate the types in the parameter list (like we do in code) doesn't mean we can't use (a readable subset of) type expressions in the longer parameter descriptions. At the same time I don't feel particularly strong about this, and I'll wait for the other EB member to speak up. This is defintely the kind of thing where the EB's decision will be valuable guidance for documentation authors going forward. |
Sorry, that was not my intention.
Indeed it is! Looking forward to the decision :) |
Another alternative that was brought up during the docs meeting is a way to show/hide types. This could be implemented in different ways:
These ideas have some downsides, but also some advantages (e.g. it would allow us to be as verbose as we want/need without affecting the current look of the docs or people that don't care about types). The actual pros/cons will also depend on the implementation itself. |
It's not linked here yet, but there was a discussion about this on discuss.python.org: How should we mark up multiple types in a type field? @willngc and I came around to "English is better" for a few reasons, mostly based on the squishy nature of what types actually mean and focusing on what would be most helpful for the readers who need the most help.
This sounded interesting until I saw the example. It's not hiding types, it's hiding the entire description of the parameter list. That doesn't seem useful to me. If I could make one change to the shown example, it would be to not put the entire signature on one line, but that's a section heading, so probably not easy. It's interesting to note in the example shown that |
Is this the EB decision? If so, let's close this as completed. |
Recently, we've marked up some functions and methods using parameter lists1. When a parameter can take multiple types, we've used
|
to separate the types, instead of usingor
, as recommended by the Sphinx docs23:I created a PR to align our markup with the Sphinx recommendation, but it turned out slightly controversial.
I'll try and summarise the arguments in favour of
|
:Arguments against
|
:Arguments in favour of
or
:int or None
is clear and contains no "weird symbols"4My personal preference would be
or
. I don't think the extra character is too verbose compared with|
, I think it is easier to grasp for beginners (and I don't think it will be a hindrance for more experienced users), and I think it is wise to avoid the similarity with type hints because that's not what it is.An example, where I think
or
is superior: "path-like object or None"Footnotes
examples: https://docs.python.org/3/library/functions.html#eval and https://docs.python.org/3/library/sqlite3.html#sqlite3.connect ↩
https://www.sphinx-doc.org/en/master/tutorial/describing-code.html#id5 ↩
https://www.sphinx-doc.org/en/master/usage/domains/python.html#info-field-lists ↩
https://github.com/python/cpython/pull/116389#issuecomment-1979766838 ↩ ↩2
https://github.com/python/cpython/pull/116389#issuecomment-1986203040 ↩
The text was updated successfully, but these errors were encountered: