From 6fa001481d544df4a215fe4e0b4fe13d30c90447 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 4 Oct 2017 11:43:14 +0200 Subject: [PATCH] Add some comments to generated config.py --- qutebrowser/config/configfiles.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index fe55312f1..8f174b869 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -248,11 +248,31 @@ class ConfigAPI: def write_config_py(filename, options, bindings): """Write a config.py file from given values.""" with open(filename, 'w', encoding='utf-8') as f: + f.write("# Autogenerated config.py - please remove lines you don't " + "customize!\n") + f.write("# Documentation:\n") + f.write("# qute://help/configuring.html\n") + f.write("# qute://help/settings.html\n\n") + for opt, value in options: if opt.name in ['bindings.commands', 'bindings.default']: continue + for line in textwrap.wrap(opt.description): f.write('# {}\n'.format(line)) + + f.write('# Type: {}\n'.format(opt.typ.get_name())) + + valid_values = opt.typ.get_valid_values() + if valid_values is not None: + f.write("# Valid values:\n") + for val in valid_values: + try: + desc = valid_values.descriptions[val] + f.write("# - {}: {}".format(val, desc) + "\n") + except KeyError: + f.write("# - {}".format(val) + "\n") + f.write('c.{} = {!r}\n\n'.format(opt.name, value)) normal_bindings = bindings.pop('normal', {})