fastapi / typer

Typer, build great CLIs. Easy to code. Based on Python type hints.
https://typer.tiangolo.com/
MIT License
15.76k stars 671 forks source link

[FEATURE] Typer python API docs #221

Open FaustinCarter opened 3 years ago

FaustinCarter commented 3 years ago

The Typer documentation is, in general, pretty great. But often what I really need is a concise API documentation similar to what Click offers.

If this exists please comment with the link and close the issue, but I feel like I've scoured the existing docs to no avail...

Such documentation would be a lot more straightforward than going to GitHub to read the code directly.

rth commented 3 years ago

but I feel like I've scoured the existing docs to no avail...

Same here. There is no way to see what parameters are supported by typer.Argument in the documentation, short of searching the code on Github. And even there there are no docstring / documentation for parameters.

laserson commented 3 years ago

+1 on this

mquasar commented 2 years ago

I also missed this when reading the docs

elucify commented 2 years ago

At least this issue was here to inform me that what I assumed must exist, doesn't.

I like the idea of seeing the documentation in vscode, but it doesn't show up for me there. 😞

jaskij commented 1 year ago

For me this is a blocker to using Typer in any real capacity.

MrMino commented 1 year ago

Worse yet, many nooks and crannies of the API aren't documented at all. I have a hard time figuring out what many kwargs to Option / Argument mean, and the only way to deal with this right now is reading the code.

MrMino commented 1 year ago

This website introduces the right ideas for this discussion: https://documentation.divio.com/

What Typer lacks is an API reference. The guide docs are cool for newcomers, but in most places the API is symmetrical enough for the more experienced people to not need it at all. What we need is a separate description for each function, method, and class, with their arguments listed and described as well.

mquasar commented 1 year ago

This website introduces the right ideas for this discussion: https://documentation.divio.com/

What Typer lacks is an API reference. The guide docs are cool for newcomers, but in most places the API is symmetrical enough for the more experienced people to not need it at all. What we need is a separate description for each function, method, and class, with their arguments listed and described as well.

This is what I missed the most when I used Typer for a personal project.

poleguy commented 1 year ago

I've used typer happily for several years, and just now realized I can't find any formal documentation for typer.Option() Where can I even get a list of parameters for Option()?

mjperrone commented 1 year ago

This project appears to be built on top of and in relation to click, with more modern python type hints at the core of the interface. Additionally, the existing documentation links to click to explain typer's behavior.

For these reasons, I think think it might be appropriate to set the documentation bar for typer at click's height. Click has a full API reference documentation.

I agree with other commenters here that the documentation would be much appreciated and useful. I think it will be necessary for me be able to convince my coworkers to use typer instead of click for our next python CLI.

jamesowers-cohere commented 8 months ago

Just a plus one that this would be much appreciated - I was searching through the lovely docs for an API reference for typer.Typer, but to no avail! I would have thought that autogenerating these and adding to the docs would be fairly easy, I'll give a PR a crack if I can find time.

Whilst I can see, in my case, the Typer class is not documented, it would still be useful to see what arguments and methods were available at a glance in the lovely docs.

MrMino commented 3 months ago

@tiangolo I'd like to push this an inch forward just by homing in on what's worth documenting in the library and how to do it. Is the following list something that you'd consider ~complete-adjacent?

Things to document:

I'm probably missing a lot of stuff but these seem to be the most used parts.

We would also need to figure out how to make such reference maintainable. I propose adding the docstrings (close to the code) and using something like https://github.com/mkdocstrings/mkdocstrings. The API reference would sit in a separate page.

@tiangolo do we have your blessing?