diff --git a/docs/source/develop/segments.rst b/docs/source/develop/segments.rst index 03a5108c..8d752229 100644 --- a/docs/source/develop/segments.rst +++ b/docs/source/develop/segments.rst @@ -172,6 +172,15 @@ Detailed description of used dictionary keys: `, :ref:`before `) will be ignored. + .. note:: + If target is inclusion of the segment in powerline upstream all segment + functions that output *only* subsegments with ``literal_contents`` key + must contain the following string in documentation:: + + No highlight groups are used (literal segment). + + String must be present on the separate line. + .. _dev-segments-draw_inner_divider: ``draw_hard_divider``, ``draw_soft_divider``, ``draw_inner_divider`` diff --git a/powerline/lint/checks.py b/powerline/lint/checks.py index 4e93fe06..4c746bf6 100644 --- a/powerline/lint/checks.py +++ b/powerline/lint/checks.py @@ -381,7 +381,10 @@ def check_segment_function(function_name, data, context, echoerr): hl_groups = [] divider_hl_group = None + hadproblem = False + if func.__doc__: + NO_H_G_USED_STR = 'No highlight groups are used (literal segment).' H_G_USED_STR = 'Highlight groups used: ' LHGUS = len(H_G_USED_STR) D_H_G_USED_STR = 'Divider highlight group used: ' @@ -391,6 +394,20 @@ def check_segment_function(function_name, data, context, echoerr): for i, line in enumerate(func.__doc__.split('\n')): if H_G_USED_STR in line: idx = line.index(H_G_USED_STR) + LHGUS + if hl_groups is None: + idx -= LHGUS + mark = Mark(mark_name, i + 1, idx + 1, func.__doc__, pointer + idx) + echoerr( + context='Error while checking theme (key {key})'.format(key=context.key), + context_mark=function_name.mark, + problem=( + 'found highlight group definition in addition to sentense stating that ' + 'no highlight groups are used' + ), + problem_mark=mark, + ) + hadproblem = True + continue hl_groups.append(( line[idx:], (mark_name, i + 1, idx + 1, func.__doc__), @@ -400,10 +417,24 @@ def check_segment_function(function_name, data, context, echoerr): idx = line.index(D_H_G_USED_STR) + LDHGUS + 2 mark = Mark(mark_name, i + 1, idx + 1, func.__doc__, pointer + idx) divider_hl_group = MarkedUnicode(line[idx:-3], mark) + elif NO_H_G_USED_STR in line: + idx = line.index(NO_H_G_USED_STR) + if hl_groups: + mark = Mark(mark_name, i + 1, idx + 1, func.__doc__, pointer + idx) + echoerr( + context='Error while checking theme (key {key})'.format(key=context.key), + context_mark=function_name.mark, + problem=( + 'found sentense stating that no highlight groups are used ' + 'in addition to highlight group definition' + ), + problem_mark=mark, + ) + hadproblem = True + continue + hl_groups = None pointer += len(line) + len('\n') - hadproblem = False - if divider_hl_group: r = hl_exists(divider_hl_group, data, context, echoerr, allow_gradients=True) if r: @@ -466,7 +497,7 @@ def check_segment_function(function_name, data, context, echoerr): h[0], list_sep.join(r)) ) hadproblem = True - else: + elif hl_groups is not None: r = hl_exists(function_name, data, context, echoerr, allow_gradients=True) if r: echoerr( diff --git a/powerline/segments/vim/__init__.py b/powerline/segments/vim/__init__.py index 5191e6fb..16ad0194 100644 --- a/powerline/segments/vim/__init__.py +++ b/powerline/segments/vim/__init__.py @@ -748,6 +748,8 @@ def tab(pl, segment_info, end=False): :param bool end: In place of starting region for the current tab end it. + + No highlight groups are used (literal segment). ''' try: return [{