-
Notifications
You must be signed in to change notification settings - Fork 210
Generate labgrid-client subcommand and option documentation from argparse #1707
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
base: master
Are you sure you want to change the base?
Conversation
44cf057
to
4f7a030
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1707 +/- ##
======================================
Coverage 55.6% 55.6%
======================================
Files 172 172
Lines 13471 13477 +6
======================================
+ Hits 7500 7506 +6
Misses 5971 5971
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
67059d8
to
148752f
Compare
148752f
to
d77c83d
Compare
285f4f7
to
fcd8e2f
Compare
As sphinx supports generating manpages, use it to simplify the process and drop the dependency on rst2man. All manpages are now tracked in doc/man. The Makefile in man/ remains for forward compatibility. Stop tracking manpages themselves in troff format. Signed-off-by: Jonas Rebmann <[email protected]>
This is an idiomatic way of setting up argument parsers and allows the parser to be re-used for manpage/documentation generation. Signed-off-by: Jonas Rebmann <[email protected]>
fcd8e2f
to
68e1a01
Compare
6d1576b
to
af588b0
Compare
42897f8
to
012df6b
Compare
Can we get rid of the "Default: " lines? Most of them are either misleading (expose internal implementation details) or redundant. Ideally the defaults should be part of the help strings where useful. Here's what I mean:
Here.
Here.
Here.
Here.
Here.
Here.
Here.
Here.
[...]
Here.
Here. [...]
Here.
Here. [...]
Here.
Here. [...]
Redundant.
Redundant.
Here.
Here.
Here.
Redundant.
Here.
Here.
Redundant. [...]
Redundant.
|
The old process was to manually duplicate information between the argparse struct in labgrid/remote/client.py and man/labgrid-client.rst which would then be translated to a manpage in man/labgrid-client.1 using rst2man and also tracked in version control. The man/labgrid-client.rst file was also sourced in doc/man/client.rst for sphinx to build html documentation of the labgrid-client cli documentation. Due to this duplication, labgrid-client command documentation was incomplete and inconsistend with argparse documentation accessible via the -h switch. Use sphinx-argparse to generate usage info from the argparse struct returned by get_parser() in labgrid/remote/client.py as part of doc/man/client.rst. Move documentation missing from the argparse struct from man/labgrid-client.1 to doc/man/client.rst. Generate both html cli documentation as well as the manpage from that. Future changes in subcommands and arguments of labgrid-client need only be documented in the argparse struct but more expansive documentation that includes markup can be added to the manpage, even to specific subcommands via the rst in doc/man. Signed-off-by: Jonas Rebmann <[email protected]>
Doesn't look good if every Arguments list of every subcommand of every command is listed here for the manpages generated from argparse. Signed-off-by: Jonas Rebmann <[email protected]>
The subcommands descriptions for create, release-from and flashscript had some extra details in the old rst manpages, not available in the argparse/cli help. Migrate these descriptions from the old to the new manpage by overwriting the subcommand descriptions. Keep the argparse help texts short and concise. Signed-off-by: Jonas Rebmann <[email protected]>
Hide intentionally undocumented subcommands and overlong lists of choices. PRs to fix the ineffective @Skip we have for those sections and to display ranges properly are open and these workarounds should be removed once the fixes made it into a release. Signed-off-by: Jonas Rebmann <[email protected]>
Since the defaults are mentioned in the help text where they're relevant, don't let sphinx-argparse print them again. Signed-off-by: Jonas Rebmann <[email protected]>
c02f952
to
d2f2131
Compare
One more observation: In "Named Arguments" there is no distinction between flags (e.g. |
@Bastian-Krause sadly, no. Generally I prefer the manpage format of autoprogram over that of sphinx-argparse, as it is more compact, idiomatic and does show option parameters:
We opted for sphinx-argparse for now in order to be able to replace subcommand descriptions. Maybe we keep an eye on progress of both alternatives. That said, shpinx-argparse is fairly simple and it would be easy for us to add missing functionality at a later time if necessary. |
Manage the documentation with sphinx and auto-document labgrid-client arguments and subcommands from source using sphinx-argparse.
Sections from the original man/labgrid-client.rst which are not obsoleted by the autogenerated reference are migrated into sphinx. Sphinx generates both the manpages as well as their html documentation counterpart.
I believe the result of this is much more useful than the current manpages we have that just don't sufficiently document usage of the subcommands.
See the readthedocs builds for results.