Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename @ECLASS-VARIABLE to @ECLASS_VARIABLE #336

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/pkgcore/ebuild/eclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,29 @@ def _supported_eapis(self, block, tag, lineno):


class EclassVarBlock(ParseEclassDoc):
"""ECLASS_VARIABLE doc block."""

tag = '@ECLASS_VARIABLE:'
key = 'variables'
default = True

def __init__(self):
tags = {
'@ECLASS_VARIABLE:': ('name', True, self._tag_inline_arg, None),
'@DEPRECATED:': ('deprecated', False, self._tag_deprecated, False),
'@DEFAULT_UNSET': ('default_unset', False, self._tag_bool, False),
'@INTERNAL': ('internal', False, self._tag_bool, False),
'@REQUIRED': ('required', False, self._tag_bool, False),
'@PRE_INHERIT': ('pre_inherit', False, self._tag_bool, False),
'@USER_VARIABLE': ('user_variable', False, self._tag_bool, False),
'@OUTPUT_VARIABLE': ('output_variable', False, self._tag_bool, False),
'@DESCRIPTION:': ('description', True, self._tag_multiline_str, None),
}
super().__init__(tags)


# For backwards compatibility, can be removed after 2022-12-31
class EclassVarBlockCompat(ParseEclassDoc):
mgorny marked this conversation as resolved.
Show resolved Hide resolved
"""ECLASS-VARIABLE doc block."""

tag = '@ECLASS-VARIABLE:'
Expand Down
23 changes: 19 additions & 4 deletions tests/ebuild/test_eclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,23 @@ def make_eclass(name, provides=None):
# }
# @CODE

# @ECLASS-VARIABLE: _FOO_INTERNAL_ECLASS_VAR
# @ECLASS_VARIABLE: _FOO_INTERNAL_ECLASS_VAR
# @INTERNAL
# @DEFAULT_UNSET
# @DESCRIPTION:
# Internal variable.

# @ECLASS-VARIABLE: FOO_PUBLIC_ECLASS_VAR
# @ECLASS_VARIABLE: FOO_PUBLIC_ECLASS_VAR
ulm marked this conversation as resolved.
Show resolved Hide resolved
# @PRE_INHERIT
# @REQUIRED
# @DEPRECATED: BAR_PUBLIC_ECLASS_VAR
# @DESCRIPTION:
# Public variable.

# @ECLASS-VARIABLE: FOO_ANOTHER_ECLASS_VAR
# @DESCRIPTION:
# Yet another variable.

# @FUNCTION: _foo_internal_func
# @USAGE: <bar> [<baz>]
# @RETURN: nothing special
Expand Down Expand Up @@ -141,7 +145,9 @@ def test_foo_eclass(self):

assert doc.function_variable_names == frozenset(('FOO_PUBLIC_VAR', '_FOO_INTERNAL_VAR'))

assert doc.variable_names == frozenset(('FOO_PUBLIC_ECLASS_VAR', '_FOO_INTERNAL_ECLASS_VAR'))
assert doc.variable_names == frozenset(('FOO_PUBLIC_ECLASS_VAR',
'_FOO_INTERNAL_ECLASS_VAR',
'FOO_ANOTHER_ECLASS_VAR'))
assert doc.internal_variable_names == frozenset(('_FOO_INTERNAL_ECLASS_VAR',))

assert len(doc.functions) == 2
Expand Down Expand Up @@ -175,7 +181,7 @@ def test_foo_eclass(self):
'required': True,
'description': '::\n\n Public variable for foo_public_func.'}

assert len(doc.variables) == 2
assert len(doc.variables) == 3
assert doc.variables[0] == {'name': '_FOO_INTERNAL_ECLASS_VAR',
'deprecated': False,
'default_unset': True,
Expand All @@ -194,6 +200,15 @@ def test_foo_eclass(self):
'user_variable': False,
'output_variable': False,
'description': '::\n\n Public variable.'}
assert doc.variables[2] == {'name': 'FOO_ANOTHER_ECLASS_VAR',
'deprecated': False,
'default_unset': False,
'internal': False,
'required': False,
'pre_inherit': False,
'user_variable': False,
'output_variable': False,
'description': '::\n\n Yet another variable.'}

def test_recursive_provides(self):
repo = FakeEclassRepo(self.dir, {
Expand Down