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

✨ Add docstring automation to get help message to typer objects #436

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mateusoliveira43
Copy link

Hi everyone,

Thanks for this awesome library, hope I can help :)

I hope this PR closes #227 and #336

My idea was to let typer get help messages to commands/arguments automatically from the objects docstrings.

I considered 3 docstrings formats: Numpy, Google and reST (Sphinx) (I believe they are the most common, right?).

I heve written some tests, but they can be improved (I felt that were a lot of duplications), and more can be written (units tests and more test cases, like callbacks).

@mateusoliveira43
Copy link
Author

I have updated the tests, to remove a bit of duplication.

But I noticed a problem: if a parameter documentation takes more then one line, only the first line is parsed. I did not had an idea to fix this yet 😬

@github-actions
Copy link

📝 Docs preview for commit 768644c at: https://639cea219c18df08fdc8417d--typertiangolo.netlify.app

@adam-moss
Copy link

@tiangolo is this something you'd consider adding? It would be exceedingly useful to incorporate this functionality directly into typer 😄

@svlandeg svlandeg added feature New feature, enhancement or request p3 labels Mar 6, 2024
@svlandeg svlandeg self-assigned this Aug 5, 2024
@pritam-dey3
Copy link

I am also waiting for this feature. It's a surprise to me that this is not already part of the library

@adam-moss
Copy link

I am also waiting for this feature. It's a surprise to me that this is not already part of the library

May be worth looking at https://cyclopts.readthedocs.io/en/latest/ as an alternative, switching isn't too onerous.

@svlandeg
Copy link
Member

svlandeg commented Aug 14, 2024

Hi, thanks for the PR and apologies for the delay in reviewing this!

I'll put this in draft, update with the latest from master, and then I'll review in more detail.

@svlandeg svlandeg marked this pull request as draft August 14, 2024 13:28
@svlandeg svlandeg changed the title feat: Add docstring automation to get help message to typer objects ✨ Add docstring automation to get help message to typer objects Aug 26, 2024
@svlandeg
Copy link
Member

svlandeg commented Sep 2, 2024

Note: pausing this for a bit longer to first review PRs #815 and #964.

From a first quick review though, I think we could consider using https://github.com/rr-/docstring_parser to implement the functionality proposed in this PR. I'll get back to this once the other PRs are done.

@svlandeg svlandeg removed their assignment Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request p3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text blob from --help; descriptions from docstrings?
5 participants