Documentation ignores the \b characters in docstrings
See original GitHub issueAs 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:
Usage: bst show [OPTIONS] TARGET
Show elements in the pipeline
By default this will only show the specified element, use the --deps
option to show an entire pipeline.
FORMAT
~~~~~~
The --format option controls what should be printed for each element,
the following symbols can be used in the format string:
%{name} The element name
%{key} The abbreviated cache key (if all sources are consistent)
%{full-key} The full cache key (if all sources are consistent)
%{state} cached, buildable, waiting or inconsistent
%{config} The element configuration
%{vars} Variable configuration
%{env} Environment settings
%{public} Public domain data
The value of the %{symbol} without the leading '%' character is understood
as a pythonic formatting string, so python formatting features apply,
examle:
build-stream show target.bst --format \
'Name: %{name: ^20} Key: %{key: ^8} State: %{state}'
If you want to use a newline in a format string in bash, use the '$'
modifier:
build-stream show target.bst --format \
$'---------- %{name} ----------\n%{vars}'
Options:
-d, --deps [all|build|run] Optionally specify a dependency scope to show
--order [stage|alpha] Staging or alphabetic ordering of dependencies
-f, --format FORMAT Format string for each element
-a, --arch TEXT The target architecture (default: x86_64)
--variant TEXT A variant of the specified target
--help Show this message and exit.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Python Docstrings (With Examples) - Programiz
In this tutorial, we will learn about Python docstrings. More specifically, we will learn how and ... They are completely ignored by the...
Read more >How to Document Your Code - pydoctor documentation
Since docstrings are Python strings, escape sequences such as \n will be parsed as if the corresponding character—for example a newline—occurred at the ......
Read more >Multi-line description of a parameter description in python ...
Personally, I prefer to align all additional lines to the first description line of that parameter. Note, that reST will also ignore new...
Read more >Python: Docstrings - STechies
A docstring in Python is a way to provide an explanation along with functions, modules, and classes. They are documentation strings that are...
Read more >Documentation in Comments | Individual Software Process
The docstring must be the first thing inside a function and use a multi-line comment (“””). Same rule for class docstrings. The first...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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:
--help
outputWith 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 approach
With 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
\b
character); and then use that same format to generate man pages and html documentation.Things would make more sense the other way around:
--help
outputJust saying, this would be a much nicer experience 😃
Fixed in the above commit.