Skip to content

Commit 40bfa0a

Browse files
committed
Automatic list of config options in doc
1 parent 942e067 commit 40bfa0a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ stagpy.egg-info/
88
docs/_build/
99
docs/_static/
1010
docs/_templates/
11+
docs/sources/config_opts.rst

docs/conf.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,41 @@ def __getattr__(cls, name):
315315

316316
# If true, do not generate a @detailmenu in the "Top" node's menu.
317317
#texinfo_no_detailmenu = False
318+
319+
from pathlib import Path
320+
from textwrap import dedent
321+
import stagpy
322+
dfile = Path('.') / 'sources' / 'config_opts.rst'
323+
with dfile.open('w') as fid:
324+
fid.write(dedent(
325+
"""\
326+
..
327+
This doc is automatically generated in conf.py.
328+
Editing it will have no effect.
329+
Modify conf.py instead.
330+
331+
List of configuration options
332+
=============================
333+
334+
These tables list configuration options.
335+
"""))
336+
for section in stagpy.conf.sections_():
337+
fid.write(dedent(
338+
"""
339+
.. list-table:: {}
340+
:header-rows: 1
341+
342+
* - Name
343+
- Description
344+
- CLI, config file?
345+
""".format(section)))
346+
for opt, meta in stagpy.conf[section].defaults_():
347+
if meta.cmd_arg and meta.conf_arg:
348+
c_f = 'both'
349+
elif meta.cmd_arg:
350+
c_f = 'CLI'
351+
else:
352+
c_f = 'config file'
353+
fid.write(' * - {}\n'.format(opt))
354+
fid.write(' - {}\n'.format(meta.help))
355+
fid.write(' - {}\n'.format(c_f))

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ Welcome to StagPy's documentation!
5353
sources/apiref/step
5454
sources/apiref/stagyyparsers
5555
sources/apiref/time
56+
sources/config_opts
5657

0 commit comments

Comments
 (0)