Skip to content

Commit bae637f

Browse files
committed
doc: man: Generate labgrid-client manpages from argparse via sphinx
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 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 using make -C doc html. Signed-off-by: Jonas Rebmann <[email protected]>
1 parent 2360fdb commit bae637f

File tree

3 files changed

+40
-141
lines changed

3 files changed

+40
-141
lines changed

doc/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040
'sphinx.ext.napoleon',
4141
'sphinx.ext.coverage',
4242
'sphinx.ext.viewcode',
43+
'sphinxarg.ext', # sphinx-argparse
4344
'sphinx.ext.autosectionlabel',
4445
'sphinx_rtd_theme']
4546

47+
suppress_warnings = ['autosectionlabel.*']
48+
4649
# Add any paths that contain templates here, relative to this directory.
4750
templates_path = ['.templates']
4851

@@ -196,7 +199,12 @@
196199
'vxi11',
197200
'pysnmp',
198201
'kasa',
199-
'kasa.iot']
202+
'kasa.iot',
203+
'labgrid.driver.power.eaton',
204+
'labgrid.driver.power.poe_mib',
205+
'labgrid.driver.power.raritan',
206+
'labgrid.driver.power.tplink',
207+
]
200208

201209
# -- Options for autosection ----------------------------------------------
202210
autosectionlabel_prefix_document = True

doc/man/client.rst

Lines changed: 30 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,42 @@
11
.. _labgrid-client:
22

3-
================
4-
labgrid-client
5-
================
3+
labgrid-client
4+
==============
65

7-
labgrid-client interface to control boards
8-
==========================================
6+
Description
7+
-----------
98

10-
SYNOPSIS
11-
--------
9+
Labgrid is a scalable infrastructure and test architecture for embedded (linux) systems.
1210

13-
``labgrid-client`` ``--help``
11+
This is the client to control a boards status and interface with it on remote machines.
1412

15-
``labgrid-client`` -p <place> <command>
13+
Options
14+
=======
1615

17-
``labgrid-client`` ``places|resources``
16+
.. currentmodule:: labgrid.remote.client
1817

19-
DESCRIPTION
20-
-----------
21-
Labgrid is a scalable infrastructure and test architecture for embedded (linux) systems.
2218

23-
This is the client to control a boards status and interface with it on remote machines.
19+
.. argparse::
20+
:module: labgrid.remote.client
21+
:func: get_parser
22+
:prog: labgrid-client
2423

25-
OPTIONS
26-
-------
27-
-h, --help
28-
display command line help
29-
-p PLACE, --place PLACE
30-
specify the place to operate on
31-
-x ADDRESS, --coordinator ADDRESS
32-
coordinator ``HOST[:PORT]`` to connect to, defaults to ``127.0.0.1:20408``
33-
-c CONFIG, --config CONFIG
34-
set the configuration file
35-
-s STATE, --state STATE
36-
set an initial state before executing a command, requires a configuration
37-
file and strategy
38-
-i INITIAL_STATE, --initial-state INITIAL_STATE
39-
strategy state to force into before switching to desired state, requires a
40-
desired state (``-s``/``--state``/``LG_STATE``)
41-
-d, --debug
42-
enable debugging
43-
-v, --verbose
44-
increase verbosity
45-
-P PROXY, --proxy PROXY
46-
proxy connections over ssh
47-
48-
CONFIGURATION FILE
24+
25+
help : @skip
26+
skip.
27+
28+
complete : @skip
29+
skip.
30+
31+
available subcommands : @skip
32+
skip.
33+
34+
35+
Configuration File
4936
------------------
5037
The configuration file follows the description in ``labgrid-device-config``\(5).
5138

52-
ENVIRONMENT VARIABLES
39+
Environment Variables
5340
---------------------
5441
Various labgrid-client commands use the following environment variable:
5542

@@ -112,112 +99,15 @@ LG_AGENT_PREFIX
11299
Add a prefix to ``.labgrid_agent_{agent_hash}.py`` allowing specification for
113100
where on the exporter it should be uploaded to.
114101

115-
MATCHES
102+
Matches
116103
-------
117104
Match patterns are used to assign a resource to a specific place. The format is:
118105
exporter/group/cls/name, exporter is the name of the exporting machine, group is
119106
a name defined within the exporter, cls is the class of the exported resource
120107
and name is its name. Wild cards in match patterns are explicitly allowed, *
121108
matches anything.
122109

123-
LABGRID-CLIENT COMMANDS
124-
-----------------------
125-
``monitor`` Monitor events from the coordinator
126-
127-
``resources (r)`` List available resources
128-
129-
``places (p)`` List available places
130-
131-
``who`` List acquired places by user
132-
133-
``show`` Show a place and related resources
134-
135-
``create`` Add a new place (name supplied by -p parameter)
136-
137-
``delete`` Delete an existing place
138-
139-
``add-alias`` ``[alias]`` Add an alias to a place
140-
141-
``del-alias`` ``[alias]`` Delete an alias from a place
142-
143-
``set-comment`` ``[comment]`` Update or set the place comment
144-
145-
``set-tags`` ``[key=value]`` Set place tags (key=value)
146-
147-
``add-match`` ``[match]`` Add one (or multiple) match pattern(s) to a place, see MATCHES
148-
149-
``del-match`` ``[match]`` Delete one (or multiple) match pattern(s) from a place, see MATCHES
150-
151-
``add-named-match`` ``[match]`` ``[name]`` Add one match pattern with a name to a place
152-
153-
``acquire (lock)`` Acquire a place
154-
155-
``allow`` ``[user]`` Allow another user to access a place
156-
157-
``release (unlock)`` Release a place
158-
159-
``release-from`` ``[host/user]`` Atomically release a place, but only if acquired by a specific user.
160-
161-
Note that this command returns success as long
162-
as the specified user no longer owns the place,
163-
meaning it may be acquired by another user or
164-
not at all.
165-
166-
``env`` Generate a labgrid environment file for a place
167-
168-
``power (pw)`` ``[action]`` Change (or get) a place's power status, where action is one of get, on, off, cycle
169-
170-
``io`` ``[action]`` ``[name]`` Interact with GPIO (OneWire, relays, ...) devices, where action is one of high, low, get
171-
172-
``console (con)`` ``[name]`` Connect to the console
173-
174-
``dfu`` ``[arg]`` Run dfu commands
175-
176-
``fastboot`` ``[arg]`` Run fastboot with argument
177-
178-
``flashscript`` ``[script]`` ``[arg]`` Run arbitrary script with arguments to flash device
179-
180-
``bootstrap`` ``[filename]`` Start a bootloader
181-
182-
``sd-mux`` ``[action]`` Switch USB SD Muxer, where action is one of dut (device-under-test), host, off
183-
184-
``usb-mux`` ``[action]`` Switch USB Muxer, where action is one of off, dut-device, host-dut, host-device, host-dut+host-device
185-
186-
``ssh`` ``[command]`` Connect via SSH. Additional arguments are passed to ssh.
187-
188-
``scp`` ``[source]`` ``[destination]`` Transfer file via scp (use ':dir/file' for the remote side)
189-
190-
``rsync`` ``[source]`` ``[destination]`` Transfer files via rsync (use ':dir/file' for the remote side)
191-
192-
``sshfs`` ``[remotepath]`` ``[mountpoint]`` Mount a remote path via sshfs
193-
194-
``forward`` Forward local port to remote target
195-
196-
``telnet`` Connect via telnet
197-
198-
``video`` Start a video stream
199-
200-
``audio`` Start an audio stream
201-
202-
``tmc`` ``[command]`` Control a USB TMC device
203-
204-
``write-files`` ``[filename(s)]`` Copy files onto mass storage device
205-
206-
``write-image`` ``[filename]`` Write images onto block devices (USBSDMux, USB Sticks, …)
207-
208-
``reserve`` ``[filter]`` Create a reservation
209-
210-
``cancel-reservation`` ``[token]`` Cancel a pending reservation
211-
212-
``wait`` ``[token]`` Wait for a reservation to be allocated
213-
214-
``reservations`` List current reservations
215-
216-
``export`` ``[filename]`` Export driver information to file (needs environment with drivers)
217-
218-
``version`` Print the labgrid version
219-
220-
ADDING NAMED RESOURCES
110+
Adding Named Resources
221111
----------------------
222112
If a target contains multiple Resources of the same type, named matches need to
223113
be used to address the individual resources. In addition to the `match` taken by
@@ -229,7 +119,7 @@ given.
229119
If one of the resources should be used by default when no resource name is
230120
explicitly specified, it can be named ``default``.
231121

232-
EXAMPLES
122+
Examples
233123
--------
234124

235125
To retrieve a list of places run:
@@ -257,7 +147,7 @@ Add all resources with the group "example-group" to the place example-place:
257147
258148
$ labgrid-client -p example-place add-match */example-group/*/*
259149
260-
SEE ALSO
150+
See Also
261151
--------
262152

263153
``labgrid-exporter``\(1)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dynamic = ["version"] # via setuptools_scm
5656
doc = [
5757
"sphinx_rtd_theme>=1.0.0",
5858
"Sphinx>=2.0.0",
59+
"sphinx-argparse",
5960
]
6061
docker = ["docker>=5.0.2"]
6162
graph = ["graphviz>=0.17.0"]

0 commit comments

Comments
 (0)