sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Intersphinx: Create link for Optional in description even if it is an inherited docstring

Open 1kastner opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. I realised that sometimes interphinx resolves typing.Optional into a link pointing to the docs and sometimes it doesn't. When it is used as a type hint in the class that is documented, everything works fine. When, on the other hand, the docstring is inherited from another class, then the type inside Optional is still resolved but not the Optional itself. This only applies to the type hint in the description, not in the signature. In the signature, everything works fine!

Describe the solution you'd like I'd like that a link is introduced for Optional to point to typing.Optional in the Python docs via intersphinx. If that is not possible, I favor consistency over feature-richness.

Describe alternatives you've considered I could add some code duplication so that no inheritance is necessary. That would be against several deisgn principles.

Additional context A very similar issue I have encountered when keyword arguments are documented, see https://github.com/sphinx-doc/sphinx/issues/10776. There, however, I can bypass the same issue with using the py obj role. In this issue, however, I cannot do this. One example for this behavior can be seen in https://conflowgen.readthedocs.io/en/latest/api.html#conflowgen.ContainerFlowAdjustmentByVehicleTypeAnalysis

1kastner avatar Aug 29 '22 09:08 1kastner