parent
d8f030496a
commit
33b44e8a3f
|
@ -19,7 +19,8 @@ from powerline.lint.checks import (check_matcher_func, check_ext, check_config,
|
|||
check_segment_module, check_exinclude_function, type_keys,
|
||||
check_segment_function, check_args, get_one_segment_function,
|
||||
check_highlight_groups, check_highlight_group, check_full_segment_data,
|
||||
get_all_possible_functions, check_segment_data_key, register_common_name)
|
||||
get_all_possible_functions, check_segment_data_key, register_common_name,
|
||||
highlight_group_spec)
|
||||
from powerline.lint.spec import Spec
|
||||
from powerline.lint.context import Context
|
||||
|
||||
|
@ -194,7 +195,6 @@ args_spec = Spec(
|
|||
pl=Spec().error('pl object must be set by powerline').optional(),
|
||||
segment_info=Spec().error('Segment info dictionary must be set by powerline').optional(),
|
||||
).unknown_spec(Spec(), Spec()).optional().copy
|
||||
highlight_group_spec = Spec().ident().copy
|
||||
segment_module_spec = Spec().type(unicode).func(check_segment_module).optional().copy
|
||||
sub_segments_spec = Spec()
|
||||
exinclude_spec = Spec().re(function_name_re).func(check_exinclude_function).copy
|
||||
|
|
|
@ -344,6 +344,28 @@ def check_full_segment_data(segment, data, context, echoerr):
|
|||
return check_key_compatibility(segment_copy, data, context, echoerr)
|
||||
|
||||
|
||||
highlight_group_spec = Spec().ident().copy
|
||||
_highlight_group_spec = highlight_group_spec().context_message(
|
||||
'Error while checking function documentation while checking theme (key {key})')
|
||||
|
||||
|
||||
def check_hl_group_name(hl_group, context_mark, context, echoerr):
|
||||
'''Check highlight group name: it should match naming conventions
|
||||
|
||||
:param str hl_group:
|
||||
Checked group.
|
||||
:param Mark context_mark:
|
||||
Context mark. May be ``None``.
|
||||
:param Context context:
|
||||
Current context.
|
||||
:param func echoerr:
|
||||
Function used for error reporting.
|
||||
|
||||
:return: ``False`` if check succeeded and ``True`` if it failed.
|
||||
'''
|
||||
return _highlight_group_spec.match(hl_group, context_mark=context_mark, context=context, echoerr=echoerr)[1]
|
||||
|
||||
|
||||
def check_segment_function(function_name, data, context, echoerr):
|
||||
havemarks(function_name)
|
||||
ext = data['ext']
|
||||
|
@ -385,13 +407,16 @@ def check_segment_function(function_name, data, context, echoerr):
|
|||
if r:
|
||||
echoerr(
|
||||
context='Error while checking theme (key {key})'.format(key=context.key),
|
||||
context_mark=function_name.mark,
|
||||
problem=(
|
||||
'found highlight group {0} not defined in the following colorschemes: {1}\n'
|
||||
'(Group name was obtained from function documentation.)'
|
||||
).format(divider_hl_group, list_sep.join(r)),
|
||||
problem_mark=function_name.mark
|
||||
problem_mark=divider_hl_group.mark,
|
||||
)
|
||||
hadproblem = True
|
||||
if check_hl_group_name(divider_hl_group, function_name.mark, context, echoerr):
|
||||
hadproblem = True
|
||||
|
||||
if hl_groups:
|
||||
greg = re.compile(r'``([^`]+)``( \(gradient\))?')
|
||||
|
@ -409,6 +434,8 @@ def check_segment_function(function_name, data, context, echoerr):
|
|||
match.group(1),
|
||||
Mark(*mark_args, pointer=sub_pointer + match.start(1))
|
||||
)
|
||||
if check_hl_group_name(hl_group, function_name.mark, context, echoerr):
|
||||
hadproblem = True
|
||||
gradient = bool(match.group(2))
|
||||
required_pack.append((hl_group, gradient))
|
||||
finally:
|
||||
|
|
Loading…
Reference in New Issue