-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Doc string formatting behavior for multi-line comments #74
Comments
Thanks for using Cyclopts! The space between the Usage-string and the description is intentional. Currently there is no way of removing this newline, but if you're curious, it's injected right here. The newlines in the |
ok, revisiting this, I now understand what you meant, you meant this space:
That is indeed unintentional, let me dig in. |
So diving in, the "problem" is kind of in parse_docstring. In docstring_parser, they call
and the output of the
The documentation says to refer to PEP-0257. Here are some important relevent quotes:
The issue here, is your docstring doesn't have a "summary" (aka short_description) line, and so it interprets your first non-blank line as such. I think this is a bit erroneous behavior, as the line So, if you format your docstring with the short_description, things will be formatted more as expected:
My takeaway thoughts:
|
a workaround: I could do something like the following:
Thoughts on something like this? |
I merged in some code into v2.1.1 that implements the spirit of the above. I still think functions should generally have a short description (they're used in the help-page for the command panel), but I think the current splitting was erroneous. As for rst/md parsing, we can continue discussion in #81. |
Wow, I appreciate the expeditious response and solution! Your solution here sounds great. One thing to note, but it looks like the short description gets parsed into the top level help command as well. In the case of the above:
In the context of the proposed solution, clearing the short description looks like it might result in this being blank (unless I'm wrong). I'm not sure what the solution here would be. Options would seem to be:
I think most of those other than option 1 would feel alright. Option 3 feels the most flexible to different documentation styles. |
Current behavior (as of v2.1.1) will be your (1):
(2) is a potential solution, but I don't think I want to deviate this far. Standard docstring syntax is:
IMHO the current extension implemented in #82 is more consistent with PEP-0257, which is why I was ok with it. In short, I think it should be blank if there isn't a proper short_description. I don't think it's unreasonable to expect the user to provide a short_description/summary (standard practice) at the top of their docstring if they want the short_description field to be populated in the help-page. |
I think going with whatever is most consistent with the PEP makes sense here. I'll align my documentation to avail of this. Thanks for your help! |
Hi! Just learned about this library and love it so far - this is some beautiful command line tooling. I'm seeing some interesting behavior with docstrings. Let's take the sample app:
Running
my_app foo -h
, I seeFirst, I have a slightly different docstring format than yours, but cool to see it just works for the most part. I am noticing that it looks like it generates a space after the first line. Is this intended behavior/is there any way to avoid injecting this space?
Or maybe this is just telling me I should be more concise :). Why waste time say lot word when few word do trick.
The text was updated successfully, but these errors were encountered: