From 5c08c6c930d721a8a1ac9ac1a200ba059484015f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 2 Jul 2017 11:47:31 +0200 Subject: [PATCH] Add conditional backend infos to docs --- doc/help/settings.asciidoc | 6 ++++-- qutebrowser/config/configdata.py | 21 +++++++++------------ qutebrowser/config/configdata.yml | 7 ------- scripts/dev/src2asciidoc.py | 11 ++++++++++- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 31f7fc07a..31ee3cf9d 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -1305,7 +1305,6 @@ Default: empty [[content.print_element_backgrounds]] == content.print_element_backgrounds Whether the background color and images are also drawn when the page is printed. -# FIXME:conf This should be added automatically: # This setting only works with Qt 5.8 or newer when using the QtWebEngine backend. Valid values: @@ -1314,6 +1313,8 @@ Valid values: Default: +pass:[true]+ +On QtWebEngine, this setting requires Qt 5.8 or newer. + [[content.private_browsing]] == content.private_browsing Open new windows in private browsing mode which does not record visited pages. @@ -1329,7 +1330,6 @@ Default: empty == content.proxy The proxy to use. In addition to the listed values, you can use a `socks://...` or `http://...` URL. -# FIXME:conf This should be added automatically: # This setting only works with Qt 5.8 or newer when using the QtWebEngine # backend. Valid values: @@ -1338,6 +1338,8 @@ Valid values: Default: +pass:[system]+ +On QtWebEngine, this setting requires Qt 5.8 or newer. + [[content.proxy_dns_requests]] == content.proxy_dns_requests Whether to send DNS requests over the configured proxy. diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 0a0b8b557..f5a6f742a 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -47,7 +47,7 @@ MONOSPACE = (' xos4 Terminus, Terminus, Monospace, ' Option = collections.namedtuple('Option', ['name', 'typ', 'default', - 'backends', 'conditional_backends', + 'backends', 'raw_backends', 'description']) @@ -154,18 +154,16 @@ def _parse_yaml_backends(name, node): -> setting available based on the given conditionals. Return: - A list of backends, and a boolean whether the list is conditional based - on the Qt version. + A list of backends. """ if node is None: - return ([usertypes.Backend.QtWebKit, usertypes.Backend.QtWebEngine], - False) + return [usertypes.Backend.QtWebKit, usertypes.Backend.QtWebEngine] elif node == 'QtWebKit': - return ([usertypes.Backend.QtWebKit], False) + return [usertypes.Backend.QtWebKit] elif node == 'QtWebEngine': - return ([usertypes.Backend.QtWebEngine], False) + return [usertypes.Backend.QtWebEngine] elif isinstance(node, dict): - return (_parse_yaml_backends_dict(name, node), True) + return _parse_yaml_backends_dict(name, node) _raise_invalid_node(name, 'backends', node) @@ -188,15 +186,14 @@ def _read_yaml(yaml_data): raise ValueError("Invalid keys {} for {}".format( option.keys(), name)) - backends, conditional_backends = _parse_yaml_backends( - name, option.get('backend', None)) + backends = option.get('backend', None) parsed[name] = Option( name=name, typ=_parse_yaml_type(name, option['type']), default=option['default'], - backends=backends, - conditional_backends=conditional_backends, + backends=_parse_yaml_backends(name, backends), + raw_backends=backends if isinstance(backends, dict) else None, description=option['desc']) # Make sure no key shadows another. diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index d0e5a385c..3771266cb 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -439,9 +439,6 @@ content.print_element_backgrounds: Whether the background color and images are also drawn when the page is printed. - # FIXME:conf This should be added automatically: - # This setting only works with Qt 5.8 or newer when using the QtWebEngine backend. - content.private_browsing: type: Bool default: false @@ -460,10 +457,6 @@ content.proxy: In addition to the listed values, you can use a `socks://...` or `http://...` URL. - # FIXME:conf This should be added automatically: - # This setting only works with Qt 5.8 or newer when using the QtWebEngine - # backend. - content.proxy_dns_requests: default: true type: Bool diff --git a/scripts/dev/src2asciidoc.py b/scripts/dev/src2asciidoc.py index d9bd2036c..df561567c 100755 --- a/scripts/dev/src2asciidoc.py +++ b/scripts/dev/src2asciidoc.py @@ -387,7 +387,16 @@ def _generate_setting_option(f, opt): f.write("Default: empty\n") all_backends = [usertypes.Backend.QtWebKit, usertypes.Backend.QtWebEngine] - if opt.backends == all_backends or opt.conditional_backends: + if opt.raw_backends is not None: + for name, conditional in sorted(opt.raw_backends.items()): + if conditional is True: + pass + elif conditional is False: + f.write("\nOn {}, this setting is unavailable.\n".format(name)) + else: + f.write("\nOn {}, this setting requires {} or newer.\n" + .format(name, conditional)) + elif opt.backends == all_backends: pass elif opt.backends == [usertypes.Backend.QtWebKit]: f.write("\nThis setting is only available with the QtWebKit "