-
Notifications
You must be signed in to change notification settings - Fork 59
Documentation ignores the \b characters in docstrings #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
Comments
Good point. Currently we render the help text as is and let Sphinx/docutils process that as is. If we were to support this, we'd need to modify that workflow to at least check for I'll try to get to this eventually but it's not something I presently use so it's rather low priority for me. If someone want to take this upon themselves, I'd be more than happy to review any/all patches. |
@stephenfin, thanks for your reply and being receptive to patches. I've looked at this briefly but sphinx and docbook are admittedly not my strong suit, as I understand (or not), it looks like ClickDirective._generate_nodes() needs some work to handle Judging from the comment around "# Description", it looks like there may be a workaround which would be to include restructured text in the help output itself (which may turn out to look not too bad in plain text as well). I will try to look further into this but dont know how much time I can focus on this... |
fixes issue click-contrib#8 We introduce an additional flag during the loop that parses the help text that determines whether to preserve line breaks across multiple lines of the help text. This flag is enabled by encountering '\b' and disabled when encountering a blank line. This is consistent with the expected behaviour of \b in click.
I've just attempted to fix this (see here). Works for my use case. I'll try and do a bit more testing and make a pull request soon. |
@philipstarkey, I tried your branch and it is an improvement, thanks. This further exposes an oversight I had made. Ideally it would be nice if the rendered HTML appeared like the paragraphs which appear in the doc comments and help text, however this falls flat on it's face without monospace fonts, and tolerance of leading whitespace on lines. It seems unwieldy to try to support this in a sphinx-click contrib package, and wrong to limit the whole document to monospace just because someone might have used |
@philipstarkey Looking forward to it. That would make for a good 1.1 release @gtristan I'm not sure I understand you. What exactly are you looking for? |
@stephenfin I guess I just went on a tangent on what might be the ideal solution... So, basically I have three outputs of my doc strings:
With the application help output, I can do some alignments and tables and stuff, like:
So I can create aligned output in the additional text I write in the documentation body and am not limited to the alignment provided by argument options; but in html this alignment is lost because of lack of monospace fonts. I think it makes sense with the current approach to force monospace fonts in the rendered docs, otherwise there is no way to use any alignment in your help text. Looking at the reverse approachWith man pages we have more freedom of expression than with help output, and with HTML we have even more freedom. The current approach with click is to write a very, very simple format for help output (the format is just text with a special meaning of the Things would make more sense the other way around:
Just saying, this would be a much nicer experience :) |
+1 to this, I was just looking into click + docstring + |
Following from [1] seemingly stagnating, I have reimplemented philipstarkey's fix for "Documentation ignores the \b characters in docstrings" in hopes of getting the ball rolling again [1] click-contrib#8
@gtristan I've recreated philipstarkey's patch to be compatible with the latest version of master. https://github.com/KnownNexus/sphinx-click/tree/Slash_b_ignored_in_docstrings |
Following from [1] seemingly stagnating, I have reimplemented philipstarkey's fix for "Documentation ignores the \b characters in docstrings" in hopes of getting the ball rolling again [1] click-contrib#8
Following from [1] seemingly stagnating, I have reimplemented philipstarkey's fix for "Documentation ignores the \b characters in docstrings" in hopes of getting the ball rolling again [1] #8
Fixed in the above commit. |
As is documented in click here, the docstrings for click commands are expected to contain
\b
characters before a paragraph which should not be made to wrap.This allows better formatting of docstrings in the help output, without this it is impossible to make any kind of formatting of the help such as point form lists which describe the meaning of each click.Choice() option.
This works well for click's help output, but is also broken for the click-man generated man pages, and for sphinx-click generated html (although the man pages are slightly less broken than the html).
See this example of the breakage and compare with the corresponding help output below:
The text was updated successfully, but these errors were encountered: