Skip to content

Conversation

@nicoddemus
Copy link
Member

This configures Sphinx autodoc to include the type annotations
along with the description of the function/method, instead of including
it into the signature.

Fix #8405

This configures Sphinx autodoc to include the type annotations
along with the description of the function/method, instead of including
it into the signature.

Fix pytest-dev#8405
@nicoddemus
Copy link
Member Author

As suggested by @davidism in #8405 (comment).

@bluetech
Copy link
Member

bluetech commented Mar 6, 2021

As implied in the issue, I'm -0.5 on this -- I think the existing placement makes more sense, but we can improve cases specifically.

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Mar 6, 2021

This looks much better IMHO, but somehow it seems to mess up definitions without type hints.

Old:
grafik
New:
grafik

Edit: Actually it looks like Sphinx is trying to parse optional parameters as type hints, or something like this.

Base automatically changed from master to main March 9, 2021 20:40
@nicoddemus
Copy link
Member Author

I guess we should close this then?

As implied in the issue, I'm -0.5 on this -- I think the existing placement makes more sense, but we can improve cases specifically.

Do you have anything in mind?

@nicoddemus
Copy link
Member Author

FTR I think this is much more readable than the current documentation:

Current:

image

This PR:

image

Often you look at the docs to get a sense of the parameters... and then each parameter has the full type annotation in the body of the docs. As it is today I have a hard time parsing the signature at all.

@RonnyPfannschmidt
Copy link
Member

Currently signatures are absymal in the docs, im +1 even tho i agree with @bluetech on the sentiment

But I prefer readability now over waiting for the solution

Let's make a follow-up issue for beautiful signatures

@nicoddemus
Copy link
Member Author

What do you say @bluetech ?

@bluetech
Copy link
Member

1+1-0.5 = 1.5 so seems good to go :)

@nicoddemus
Copy link
Member Author

1+1-0.5 = 1.5 so seems good to go :)

Hehehe thanks!

@nicoddemus nicoddemus merged commit ef1308c into pytest-dev:main Mar 13, 2021
@nicoddemus nicoddemus deleted the type-annotations-description-8405 branch March 13, 2021 17:46
@pradyunsg
Copy link
Contributor

Actually it looks like Sphinx is trying to parse optional parameters as type hints, or something like this.

It'd be a really good idea to share a minimal example reproducing this issue with Sphinx. This looks like a bug!

@astrojuanlu
Copy link

Was the issue with the non typed parameters reported upstream? Couldn't find anything after a quick look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Readability of API documentation with type annotations

6 participants