Skip to content

Commit bc99813

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 dad6682 commit bc99813

File tree

3 files changed

+151
-2
lines changed

3 files changed

+151
-2
lines changed

doc/conf.py

Lines changed: 13 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

@@ -156,6 +159,8 @@
156159
# (source start file, name, description, authors, manual section).
157160
man_pages = [
158161
(master_doc, 'labgrid', 'labgrid Documentation',
162+
[author], 1),
163+
('man/client', 'labgrid-client', 'labgrid\'s client interface to control boards',
159164
[author], 1)
160165
]
161166

@@ -181,7 +186,14 @@
181186
autodoc_mock_imports = ['onewire',
182187
'gi',
183188
'gi.repository',
184-
'vxi11']
189+
'vxi11',
190+
'pysnmp',
191+
'kasa',
192+
'labgrid.driver.power.eaton',
193+
'labgrid.driver.power.poe_mib',
194+
'labgrid.driver.power.raritan',
195+
'labgrid.driver.power.tplink',
196+
]
185197

186198
# -- Options for autosection ----------------------------------------------
187199
autosectionlabel_prefix_document = True

doc/man/client.rst

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,138 @@
11
.. _labgrid-client:
2-
.. include:: ../../man/labgrid-client.rst
2+
3+
labgrid-client
4+
==============
5+
6+
Labgrid is a scalable infrastructure and test architecture for embedded (linux) systems.
7+
8+
This is the client to control a boards status and interface with it on remote machines.
9+
10+
.. argparse::
11+
:module: labgrid.remote.client
12+
:func: get_parser
13+
:prog: labgrid-client
14+
:noepilog:
15+
:nodescription:
16+
17+
help : @skip
18+
skip help
19+
20+
Configuration File
21+
------------------
22+
The configuration file follows the description in ``labgrid-device-config``\(5).
23+
24+
Environment Variables
25+
---------------------
26+
Various labgrid-client commands use the following environment variable:
27+
28+
LG_PLACE
29+
~~~~~~~~
30+
This variable can be used to specify a place without using the ``-p`` option, the ``-p`` option overrides it.
31+
32+
LG_TOKEN
33+
~~~~~~~~
34+
This variable can be used to specify a reservation for the ``wait`` command and
35+
for the ``+`` place expansion.
36+
37+
LG_STATE
38+
~~~~~~~~
39+
This variable can be used to specify a state which the device transitions into
40+
before executing a command. Requires a configuration file and a Strategy
41+
specified for the device.
42+
43+
LG_INITIAL_STATE
44+
~~~~~~~~~~~~~~~~
45+
This variable can be used to specify an initial state the device is known to
46+
be in.
47+
This is useful during development. The Strategy used must implement the
48+
``force()`` method.
49+
A desired state must be set using ``LG_STATE`` or ``-s``/``--state``.
50+
51+
LG_ENV
52+
~~~~~~
53+
This variable can be used to specify the configuration file to use without
54+
using the ``--config`` option, the ``--config`` option overrides it.
55+
56+
LG_COORDINATOR
57+
~~~~~~~~~~~~~~
58+
This variable can be used to set the default coordinator in the format
59+
``HOST[:PORT]`` (instead of using the ``-x`` option).
60+
61+
LG_PROXY
62+
~~~~~~~~
63+
This variable can be used to specify a SSH proxy hostname which should be used
64+
to connect to the coordinator and any resources which are normally accessed
65+
directly.
66+
67+
LG_HOSTNAME
68+
~~~~~~~~~~~
69+
Override the hostname used when accessing a resource. Typically only useful for
70+
CI pipelines where the hostname may not be consistent between pipeline stages.
71+
72+
LG_USERNAME
73+
~~~~~~~~~~~
74+
Override the username used when accessing a resource. Typically only useful for
75+
CI pipelines where the username may not be consistent between pipeline stages.
76+
77+
LG_SSH_CONNECT_TIMEOUT
78+
~~~~~~~~~~~~~~~~~~~~~~
79+
Set the connection timeout when using SSH (The ``ConnectTimeout`` option). If
80+
unspecified, defaults to 30 seconds.
81+
82+
LG_AGENT_PREFIX
83+
~~~~~~~~~~~~~~~~~~~~~~
84+
Add a prefix to ``.labgrid_agent_{agent_hash}.py`` allowing specification for
85+
where on the exporter it should be uploaded to.
86+
87+
Matches
88+
-------
89+
Match patterns are used to assign a resource to a specific place. The format is:
90+
exporter/group/cls/name, exporter is the name of the exporting machine, group is
91+
a name defined within the exporter, cls is the class of the exported resource
92+
and name is its name. Wild cards in match patterns are explicitly allowed, *
93+
matches anything.
94+
95+
Adding Named Resources
96+
----------------------
97+
If a target contains multiple Resources of the same type, named matches need to
98+
be used to address the individual resources. In addition to the `match` taken by
99+
`add-match`, `add-named-match` also takes a name for the resource. The other
100+
client commands support the name as an optional parameter and will inform the
101+
user that a name is required if multiple resources are found, but no name is
102+
given.
103+
104+
If one of the resources should be used by default when no resource name is
105+
explicitly specified, it can be named ``default``.
106+
107+
Examples
108+
--------
109+
110+
To retrieve a list of places run:
111+
112+
.. code-block:: bash
113+
114+
$ labgrid-client places
115+
116+
To access a place, it needs to be acquired first, this can be done by running
117+
the ``acquire command`` and passing the placename as a -p parameter:
118+
119+
.. code-block:: bash
120+
121+
$ labgrid-client -p <placename> acquire
122+
123+
Open a console to the acquired place:
124+
125+
.. code-block:: bash
126+
127+
$ labgrid-client -p <placename> console
128+
129+
Add all resources with the group "example-group" to the place example-place:
130+
131+
.. code-block:: bash
132+
133+
$ labgrid-client -p example-place add-match */example-group/*/*
134+
135+
See Also
136+
--------
137+
138+
``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)