Show type annotations on properties#7385
Show type annotations on properties#7385eric-wieser wants to merge 1 commit intosphinx-doc:3.0.xfrom
Conversation
65d2e46 to
d865626
Compare
Note that in order to do this, we extend the signature parser to allow things like:
```rst
.. attr:: MyClass.attr : int
docs
```
which mirrors the syntax of
```python
class MyClass:
attr : int
```
d865626 to
813d515
Compare
|
Thank you for proposal. Seems good to me. But, sadly, we have a plan to separate property to an independent directive (see #7068) in 3.1.0. So I'd not like to merge this into 3.0. |
|
What are your thoughts on the part of this patch which allows: for consistency with I could put that part in separately. |
|
Since 2.4.0, we've provided So that is already implemented in different way. |
|
I'm aware it's already possible to provide this data to sphinx. My suggestion is more about matching python syntax. Due to python 3.5 supporting: def meth() -> int:
passyou added support for writing .. method:: meth() -> intas a short version of .. method:: meth()
:rtype: intPython 3.6+ now supports: some_var : intSo by symmetry, I think it makes sense to support .. data:: some_var : intas a short version of .. data:: some_var
:type: int |
|
Okay, I understand. Before starting the discussion, I need to correct your misunderstanding. It was added before type annotations support in python. So it does not modify the signature of function in the generated document. Surely they are similar, but different notation. On the other hand, The reason why I added On development 2.4, I separated the |
|
Anyway, 3.0.x branch is now under feature freeze for the coming release. No more breaking changes and deprecations are prohibited. So it would be better to change these ideas on 3.x branch. |
|
Agreed
Thanks for the explanation, that makes sense to me
I think what I actually care about most is that when viewing the web docs, I'd prefer to see the documentation in the form instead of I suppose this is orthogonal though, and there's no need to make the rst match.
I'd argue it's (slightly) confusing to the user that they can write their Perhaps the hesistation would go away if |
As you said, this is not related to the notations. In fact, the current python domain generates such output.
What do you mean? I guess nobody confuses by method notation. And there no directive options to describe the type of method.
Yes, acceptable. |
What is the status of this plan? All the referenced PRs appear to be closed without merging. |
|
Ping, @tk0miya - could you respond to the above comment? |
Now I reopened #7298. I'll work for it in this week. Please wait for a moment.
Really? It seems working fine on my local: |
Yep, works fine for me too now - I can only assume the CI i was using had a different sphinx version to what I thought. Sorry for wasting your time! |

Fixes gh-7383
Keeping the description short since the issue gives the context.
An example in the wild: