summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Schwab <git@nicholas-schwab.de>2021-04-08 17:25:23 +0200
committerNicholas Schwab <git@nicholas-schwab.de>2021-04-08 17:25:23 +0200
commit4ff204aecc96d77209a18594a14da96af703c43f (patch)
tree859039efbf02153e77506c773c08917d461458ef
parent7cf955640e346f8370b3511a0bc8f1ea2a22ffe4 (diff)
downloadqutebrowser-4ff204aecc96d77209a18594a14da96af703c43f.tar.gz
qutebrowser-4ff204aecc96d77209a18594a14da96af703c43f.zip
Added documentation generation for valid prefixes to config file generation.
-rw-r--r--qutebrowser/config/configfiles.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py
index f8566e2d0..78991b5ec 100644
--- a/qutebrowser/config/configfiles.py
+++ b/qutebrowser/config/configfiles.py
@@ -788,6 +788,15 @@ class ConfigPyWriter:
yield self._line("config.load_autoconfig(False)")
yield ''
+ def _gen_valid_list(self, head: str, valid_list) -> Iterator[str]:
+ yield self._line(head)
+ for val in valid_list:
+ try:
+ desc = valid_list.descriptions[val]
+ yield self._line("# - {}: {}".format(val, desc))
+ except KeyError:
+ yield self._line("# - {}".format(val))
+
def _gen_options(self) -> Iterator[str]:
"""Generate the options part of the config."""
for pattern, opt, value in self._options:
@@ -801,13 +810,13 @@ class ConfigPyWriter:
valid_values = opt.typ.get_valid_values()
if valid_values is not None and valid_values.generate_docs:
- yield self._line("# Valid values:")
- for val in valid_values:
- try:
- desc = valid_values.descriptions[val]
- yield self._line("# - {}: {}".format(val, desc))
- except KeyError:
- yield self._line("# - {}".format(val))
+ yield from self._gen_valid_list('# Valid Values: \n', valid_values)
+
+ valid_prefixes = opt.typ.get_valid_prefixes()
+ if valid_prefixes is not None and valid_prefixes.generate_docs:
+ yield from self._gen_valid_list(
+ '# Valid Prefixes (separator is {}): \n'.format(
+ valid_prefixes.separator), valid_prefixes)
if pattern is None:
yield self._line('c.{} = {!r}'.format(opt.name, value))