Correct qutebrowser.conf documentation for list types

This commit is contained in:
Marshall Lochbaum 2016-07-29 16:08:42 -04:00
parent 2c37de3ac1
commit b22634e2eb
2 changed files with 25 additions and 2 deletions

View File

@ -419,7 +419,7 @@ class ConfigManager(QObject):
for optname, option in sect.items():
lines.append('#')
typestr = ' ({})'.format(option.typ.__class__.__name__)
typestr = ' ({})'.format(option.typ.get_name())
lines.append("# {}{}:".format(optname, typestr))
try:
@ -430,7 +430,7 @@ class ConfigManager(QObject):
continue
for descline in desc.splitlines():
lines += wrapper.wrap(descline)
valid_values = option.typ.valid_values
valid_values = option.typ.get_valid_values()
if valid_values is not None:
if valid_values.descriptions:
for val in valid_values:

View File

@ -124,6 +124,14 @@ class BaseType:
self.none_ok = none_ok
self.valid_values = None
def get_name(self):
"""Get a name for the type for documentation"""
return self.__class__.__name__
def get_valid_values(self):
"""Get the type's valid values for documentation"""
return self.valid_values
def _basic_validation(self, value):
"""Do some basic validation for the value (empty, non-printable chars).
@ -308,6 +316,17 @@ class List(BaseType):
self.inner_type = inner_type
self.length = length
_show_inner_type = True
def get_name(self):
name = super().get_name()
if self._show_inner_type:
name += " of " + self.inner_type.get_name()
return name
def get_valid_values(self):
return self.inner_type.get_valid_values()
def transform(self, value):
if not value:
return None
@ -341,6 +360,8 @@ class FlagList(List):
super().__init__(BaseType(), none_ok)
self.inner_type.valid_values = valid_values
_show_inner_type = False
def validate(self, value):
if self.inner_type.valid_values is not None:
super().validate(value)
@ -1124,6 +1145,8 @@ class Padding(List):
none_ok=none_ok, length=4)
self.inner_type.valid_values = valid_values
_show_inner_type = False
def transform(self, value):
elems = super().transform(value)
if elems is None: