Fix lint
This commit is contained in:
parent
abf5fbc063
commit
8f19da7e54
@ -1,4 +1,6 @@
|
|||||||
|
# pylint: disable=too-many-lines
|
||||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||||
|
# Note the "disable=too-many-lines" needs to be in the first line to work.
|
||||||
|
|
||||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||||
#
|
#
|
||||||
@ -785,8 +787,8 @@ DATA = OrderedDict([
|
|||||||
"Foreground color of completion widget category headers."),
|
"Foreground color of completion widget category headers."),
|
||||||
|
|
||||||
('completion.category.bg',
|
('completion.category.bg',
|
||||||
SettingValue(types.QssColor(), 'qlineargradient(x1:0, y1:0, x2:0, y2:1, '
|
SettingValue(types.QssColor(), 'qlineargradient(x1:0, y1:0, x2:0, '
|
||||||
'stop:0 #888888, stop:1 #505050)'),
|
'y2:1, stop:0 #888888, stop:1 #505050)'),
|
||||||
"Background color of the completion widget category headers."),
|
"Background color of the completion widget category headers."),
|
||||||
|
|
||||||
('completion.category.border.top',
|
('completion.category.border.top',
|
||||||
@ -810,7 +812,8 @@ DATA = OrderedDict([
|
|||||||
"Top border color of the completion widget category headers."),
|
"Top border color of the completion widget category headers."),
|
||||||
|
|
||||||
('completion.item.selected.border.bottom',
|
('completion.item.selected.border.bottom',
|
||||||
SettingValue(types.QssColor(), '${completion.item.selected.border.top}'),
|
SettingValue(types.QssColor(), '${completion.item.selected.border.'
|
||||||
|
'top}'),
|
||||||
"Bottom border color of the selected completion item."),
|
"Bottom border color of the selected completion item."),
|
||||||
|
|
||||||
('completion.match.fg',
|
('completion.match.fg',
|
||||||
|
@ -28,17 +28,20 @@ from tempfile import mkstemp
|
|||||||
|
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
|
|
||||||
import qutebrowser.app
|
# We import qutebrowser.app so all @cmdutils-register decorators are run.
|
||||||
|
import qutebrowser.app # pylint: disable=unused-import
|
||||||
import qutebrowser.commands.utils as cmdutils
|
import qutebrowser.commands.utils as cmdutils
|
||||||
import qutebrowser.config.configdata as configdata
|
import qutebrowser.config.configdata as configdata
|
||||||
from qutebrowser.utils.usertypes import enum
|
from qutebrowser.utils.usertypes import enum
|
||||||
|
|
||||||
|
|
||||||
def _open_file(name, mode='w'):
|
def _open_file(name, mode='w'):
|
||||||
"""Open a file with a preset newline/encoding mode."""
|
"""Open a file with a preset newline/encoding mode."""
|
||||||
return open(name, mode, newline='\n', encoding='utf-8')
|
return open(name, mode, newline='\n', encoding='utf-8')
|
||||||
|
|
||||||
def _parse_docstring(func):
|
|
||||||
"""Generates documentation based on a docstring of a command handler.
|
def _parse_docstring(func): # noqa
|
||||||
|
"""Generate documentation based on a docstring of a command handler.
|
||||||
|
|
||||||
The docstring needs to follow the format described in HACKING.
|
The docstring needs to follow the format described in HACKING.
|
||||||
|
|
||||||
@ -48,8 +51,9 @@ def _parse_docstring(func):
|
|||||||
Return:
|
Return:
|
||||||
A (short_desc, long_desc, arg_descs) tuple.
|
A (short_desc, long_desc, arg_descs) tuple.
|
||||||
"""
|
"""
|
||||||
State = enum('short', 'desc', 'desc_hidden', 'arg_start', 'arg_inside',
|
# pylint: disable=too-many-branches
|
||||||
'misc')
|
State = enum('short', 'desc', # pylint: disable=invalid-name
|
||||||
|
'desc_hidden', 'arg_start', 'arg_inside', 'misc')
|
||||||
doc = inspect.getdoc(func)
|
doc = inspect.getdoc(func)
|
||||||
lines = doc.splitlines()
|
lines = doc.splitlines()
|
||||||
|
|
||||||
@ -102,10 +106,13 @@ def _parse_docstring(func):
|
|||||||
|
|
||||||
|
|
||||||
def _get_cmd_syntax(name, cmd):
|
def _get_cmd_syntax(name, cmd):
|
||||||
|
"""Get the command syntax for a command."""
|
||||||
|
# pylint: disable=no-member
|
||||||
words = []
|
words = []
|
||||||
argspec = inspect.getfullargspec(cmd.handler)
|
argspec = inspect.getfullargspec(cmd.handler)
|
||||||
if argspec.defaults is not None:
|
if argspec.defaults is not None:
|
||||||
defaults = dict(zip(reversed(argspec.args), reversed(list(argspec.defaults))))
|
defaults = dict(zip(reversed(argspec.args),
|
||||||
|
reversed(list(argspec.defaults))))
|
||||||
else:
|
else:
|
||||||
defaults = {}
|
defaults = {}
|
||||||
words.append(name)
|
words.append(name)
|
||||||
@ -123,6 +130,7 @@ def _get_cmd_syntax(name, cmd):
|
|||||||
|
|
||||||
|
|
||||||
def _get_command_quickref(cmds):
|
def _get_command_quickref(cmds):
|
||||||
|
"""Generate the command quick reference."""
|
||||||
out = []
|
out = []
|
||||||
out.append('[options="header",width="75%",cols="25%,75%"]')
|
out.append('[options="header",width="75%",cols="25%,75%"]')
|
||||||
out.append('|==============')
|
out.append('|==============')
|
||||||
@ -135,6 +143,7 @@ def _get_command_quickref(cmds):
|
|||||||
|
|
||||||
|
|
||||||
def _get_setting_quickref():
|
def _get_setting_quickref():
|
||||||
|
"""Generate the settings quick reference."""
|
||||||
out = []
|
out = []
|
||||||
for sectname, sect in configdata.DATA.items():
|
for sectname, sect in configdata.DATA.items():
|
||||||
if not getattr(sect, 'descriptions'):
|
if not getattr(sect, 'descriptions'):
|
||||||
@ -143,7 +152,7 @@ def _get_setting_quickref():
|
|||||||
out.append('[options="header",width="75%",cols="25%,75%"]')
|
out.append('[options="header",width="75%",cols="25%,75%"]')
|
||||||
out.append('|==============')
|
out.append('|==============')
|
||||||
out.append('|Setting|Description')
|
out.append('|Setting|Description')
|
||||||
for optname, option in sect.items():
|
for optname, _option in sect.items():
|
||||||
desc = sect.descriptions[optname]
|
desc = sect.descriptions[optname]
|
||||||
out.append('|<<setting-{}-{},{}>>|{}'.format(
|
out.append('|<<setting-{}-{},{}>>|{}'.format(
|
||||||
sectname, optname, optname, desc))
|
sectname, optname, optname, desc))
|
||||||
@ -152,6 +161,7 @@ def _get_setting_quickref():
|
|||||||
|
|
||||||
|
|
||||||
def _get_command_doc(name, cmd):
|
def _get_command_doc(name, cmd):
|
||||||
|
"""Generate the documentation for a command."""
|
||||||
output = ['[[cmd-{}]]'.format(name)]
|
output = ['[[cmd-{}]]'.format(name)]
|
||||||
output += ['==== {}'.format(name)]
|
output += ['==== {}'.format(name)]
|
||||||
syntax, defaults = _get_cmd_syntax(name, cmd)
|
syntax, defaults = _get_cmd_syntax(name, cmd)
|
||||||
@ -174,6 +184,7 @@ def _get_command_doc(name, cmd):
|
|||||||
|
|
||||||
|
|
||||||
def generate_header(f):
|
def generate_header(f):
|
||||||
|
"""Generate an asciidoc header."""
|
||||||
f.write('= qutebrowser manpage\n')
|
f.write('= qutebrowser manpage\n')
|
||||||
f.write('Florian Bruhin <mail@qutebrowser.org>\n')
|
f.write('Florian Bruhin <mail@qutebrowser.org>\n')
|
||||||
f.write(':toc:\n')
|
f.write(':toc:\n')
|
||||||
@ -181,6 +192,7 @@ def generate_header(f):
|
|||||||
|
|
||||||
|
|
||||||
def generate_commands(f):
|
def generate_commands(f):
|
||||||
|
"""Generate the complete commands section."""
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write("== Commands\n")
|
f.write("== Commands\n")
|
||||||
normal_cmds = []
|
normal_cmds = []
|
||||||
@ -220,6 +232,7 @@ def generate_commands(f):
|
|||||||
|
|
||||||
|
|
||||||
def generate_settings(f):
|
def generate_settings(f):
|
||||||
|
"""Generate the complete settings section."""
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
f.write("== Settings\n")
|
f.write("== Settings\n")
|
||||||
f.write(_get_setting_quickref() + "\n")
|
f.write(_get_setting_quickref() + "\n")
|
||||||
@ -278,8 +291,8 @@ def regenerate_authors(filename):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with _open_file('doc/qutebrowser.asciidoc') as f:
|
with _open_file('doc/qutebrowser.asciidoc') as fobj:
|
||||||
generate_header(f)
|
generate_header(fobj)
|
||||||
generate_settings(f)
|
generate_settings(fobj)
|
||||||
generate_commands(f)
|
generate_commands(fobj)
|
||||||
regenerate_authors('README.asciidoc')
|
regenerate_authors('README.asciidoc')
|
||||||
|
Loading…
Reference in New Issue
Block a user