Skip to content
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

Display types in function signatures #473

Closed
not-my-profile opened this issue Feb 3, 2022 · 2 comments · Fixed by #595
Closed

Display types in function signatures #473

not-my-profile opened this issue Feb 3, 2022 · 2 comments · Fixed by #595
Labels
astbuilder A substantive change is required in the astbuilder flow in order to fix this issue
Milestone

Comments

@not-my-profile
Copy link
Contributor

not-my-profile commented Feb 3, 2022

Something that really bothers me about Pydoctor is that the return type is only shown at the very end of the function documentation:

image

Another problem is that parameter default values can be far apart from the type & description of parameters.

I think the best way to solve both of these problems would be to display all types in the function signature. I'd argue that types are important enough to warrant them being displayed first. And actually when I want to learn about a function I want to read its full type signature first before reading any text about the function.

This would obviously require a rework of the functionDef as has already been suggested in #422. Though I don't think <wbr> are the way to go. If the signature is too long it should just be properly formatted from the get go.

@tristanlatr
Copy link
Contributor

See #417 (comment) about type annotations in signatures.

I think it’s a good idea to show them I the signature.

@tristanlatr tristanlatr added this to the 22.x milestone May 11, 2022
@tristanlatr
Copy link
Contributor

Let's talk about rendering the type annotation inside signatures, @cretz, here is what's my old code (#417) currently generates for a random function (not overloaded):

by default 2022-05-26 at 7 42 44 PM

As talked about with @glyph, I believe we should only see the following instead:

by default 2022-05-26 at 7 46 59 PM

Here are notes on this issue:

Change the FieldHandler to show nothing when none of the parameters (annotated or not) are documented (stop listing the parameters or return value as "undocumented" when they only have AST annotation, this makes the behaviour more consistent because we don't list undocumented param that don't have AST annotation). In case there is only one parameter documented, then still show the whole table of parameters with "undocumented" when parameters miss docs, like we do for functions without annotations.

@tristanlatr tristanlatr added the astbuilder A substantive change is required in the astbuilder flow in order to fix this issue label May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astbuilder A substantive change is required in the astbuilder flow in order to fix this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants