generated from jCloud/repository-template
style: ensure trailing commas in multi-line statements
This commit is contained in:
30 files changed
+1760
-1756
No files matched your search
@@ -18,5 +18,5 @@ from .core import __all__ as _core__all__
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'cli',
|
'cli',
|
||||||
*_core__all__
|
*_core__all__,
|
||||||
]
|
]
|
||||||
@@ -19,5 +19,5 @@ from .cli import main
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'cli',
|
'cli',
|
||||||
'languages',
|
'languages',
|
||||||
'main'
|
'main',
|
||||||
]
|
]
|
||||||
@@ -25,7 +25,7 @@ __all__ = [
|
|||||||
'existing_directory',
|
'existing_directory',
|
||||||
'error',
|
'error',
|
||||||
'create_argument_parser',
|
'create_argument_parser',
|
||||||
'main'
|
'main',
|
||||||
]
|
]
|
||||||
|
|
||||||
_LANG_PYTHON = 'python'
|
_LANG_PYTHON = 'python'
|
||||||
@@ -70,33 +70,33 @@ def create_argument_parser() -> argparse.ArgumentParser:
|
|||||||
type = existing_directory,
|
type = existing_directory,
|
||||||
nargs = '?',
|
nargs = '?',
|
||||||
default = pathlib.Path('.'),
|
default = pathlib.Path('.'),
|
||||||
help = 'The directory of the project'
|
help = 'The directory of the project',
|
||||||
)
|
)
|
||||||
common_parser.add_argument(
|
common_parser.add_argument(
|
||||||
'-o',
|
'-o',
|
||||||
'--output-dir',
|
'--output-dir',
|
||||||
type = pathlib.Path,
|
type = pathlib.Path,
|
||||||
help = 'the output directory the documentation will be written to'
|
help = 'the output directory the documentation will be written to',
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_parser = argparse.ArgumentParser()
|
argument_parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
subparsers = argument_parser.add_subparsers(
|
subparsers = argument_parser.add_subparsers(
|
||||||
dest = 'language',
|
dest = 'language',
|
||||||
required = True
|
required = True,
|
||||||
)
|
)
|
||||||
|
|
||||||
python_parser = subparsers.add_parser(
|
python_parser = subparsers.add_parser(
|
||||||
_LANG_PYTHON,
|
_LANG_PYTHON,
|
||||||
parents = [common_parser],
|
parents = [common_parser],
|
||||||
help = 'generate documentation for Python project'
|
help = 'generate documentation for Python project',
|
||||||
)
|
)
|
||||||
python_parser.add_argument(
|
python_parser.add_argument(
|
||||||
'-s',
|
'-s',
|
||||||
'--sections',
|
'--sections',
|
||||||
nargs = '+',
|
nargs = '+',
|
||||||
choices = VALID_PYTHON_SECTIONS,
|
choices = VALID_PYTHON_SECTIONS,
|
||||||
help = 'the sections to be included in the documentation'
|
help = 'the sections to be included in the documentation',
|
||||||
)
|
)
|
||||||
python_parser.add_argument(
|
python_parser.add_argument(
|
||||||
'-S',
|
'-S',
|
||||||
@@ -107,7 +107,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
|
|||||||
help = (
|
help = (
|
||||||
'the sections to be excluded in the documentation. '
|
'the sections to be excluded in the documentation. '
|
||||||
'If a section shall be included AND excluded, it is excluded.'
|
'If a section shall be included AND excluded, it is excluded.'
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
python_parser.add_argument(
|
python_parser.add_argument(
|
||||||
'-H',
|
'-H',
|
||||||
@@ -116,7 +116,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
|
|||||||
help = (
|
help = (
|
||||||
'indicates whether HTML is allowed in the documentation. '
|
'indicates whether HTML is allowed in the documentation. '
|
||||||
'By default, HTML is disabled.'
|
'By default, HTML is disabled.'
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
python_parser.add_argument(
|
python_parser.add_argument(
|
||||||
'-T',
|
'-T',
|
||||||
@@ -126,7 +126,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
|
|||||||
'indicates whether Markdown tables are allowed in the '
|
'indicates whether Markdown tables are allowed in the '
|
||||||
'documentation. By default, Markdown tables are disabled. '
|
'documentation. By default, Markdown tables are disabled. '
|
||||||
'Warning: Markdown tables are not CommonMark.'
|
'Warning: Markdown tables are not CommonMark.'
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return argument_parser
|
return argument_parser
|
||||||
@@ -147,7 +147,7 @@ def main(argv = None) -> int:
|
|||||||
include_sections = args.sections,
|
include_sections = args.sections,
|
||||||
exclude_sections = args.sections_exclude,
|
exclude_sections = args.sections_exclude,
|
||||||
allow_html = args.allow_html,
|
allow_html = args.allow_html,
|
||||||
allow_tables = args.allow_tables
|
allow_tables = args.allow_tables,
|
||||||
)
|
)
|
||||||
except FileNotFoundError as exc:
|
except FileNotFoundError as exc:
|
||||||
return error(f'{exc.filename}: no such file or directory')
|
return error(f'{exc.filename}: no such file or directory')
|
||||||
|
|||||||
@@ -15,5 +15,5 @@
|
|||||||
from . import python
|
from . import python
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'python'
|
'python',
|
||||||
]
|
]
|
||||||
@@ -15,14 +15,14 @@
|
|||||||
import pathlib
|
import pathlib
|
||||||
from ...core.python import (
|
from ...core.python import (
|
||||||
PythonDefinitionDocumentationIncludeSections,
|
PythonDefinitionDocumentationIncludeSections,
|
||||||
PythonDocumentationGenerator
|
PythonDocumentationGenerator,
|
||||||
)
|
)
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'VALID_SECTIONS',
|
'VALID_SECTIONS',
|
||||||
'parse_sections_list',
|
'parse_sections_list',
|
||||||
'generate'
|
'generate',
|
||||||
]
|
]
|
||||||
|
|
||||||
VALID_SECTIONS = list(
|
VALID_SECTIONS = list(
|
||||||
@@ -31,7 +31,7 @@ VALID_SECTIONS = list(
|
|||||||
|
|
||||||
def parse_sections_list(
|
def parse_sections_list(
|
||||||
include_sections: Optional[list[str]] = None,
|
include_sections: Optional[list[str]] = None,
|
||||||
exclude_sections: list[str] = []
|
exclude_sections: list[str] = [],
|
||||||
) -> PythonDefinitionDocumentationIncludeSections:
|
) -> PythonDefinitionDocumentationIncludeSections:
|
||||||
'''
|
'''
|
||||||
Returns a Python definition documentation sections list from the
|
Returns a Python definition documentation sections list from the
|
||||||
@@ -64,7 +64,7 @@ def parse_sections_list(
|
|||||||
docstring = 'docstring' in include_sections,
|
docstring = 'docstring' in include_sections,
|
||||||
bases = 'bases' in include_sections,
|
bases = 'bases' in include_sections,
|
||||||
decorators = 'decorators' in include_sections,
|
decorators = 'decorators' in include_sections,
|
||||||
class_body = 'class_body' in include_sections
|
class_body = 'class_body' in include_sections,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _generate(
|
def _generate(
|
||||||
@@ -75,7 +75,7 @@ def _generate(
|
|||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections()
|
||||||
),
|
),
|
||||||
allow_html: bool = False,
|
allow_html: bool = False,
|
||||||
allow_tables: bool = False
|
allow_tables: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Generates the documentation for a Python project.
|
Generates the documentation for a Python project.
|
||||||
@@ -99,7 +99,7 @@ def _generate(
|
|||||||
output_directory,
|
output_directory,
|
||||||
include_sections = include_sections,
|
include_sections = include_sections,
|
||||||
allow_html = allow_html,
|
allow_html = allow_html,
|
||||||
allow_tables = allow_tables
|
allow_tables = allow_tables,
|
||||||
)
|
)
|
||||||
docs_generator.generate_documentation()
|
docs_generator.generate_documentation()
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ def generate(
|
|||||||
include_sections: Optional[list[str]] = None,
|
include_sections: Optional[list[str]] = None,
|
||||||
exclude_sections: list[str] = [],
|
exclude_sections: list[str] = [],
|
||||||
allow_html: bool = False,
|
allow_html: bool = False,
|
||||||
allow_tables: bool = False
|
allow_tables: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Generates the documentation for a Python project.
|
Generates the documentation for a Python project.
|
||||||
@@ -139,5 +139,5 @@ def generate(
|
|||||||
output_directory,
|
output_directory,
|
||||||
include_sections = sections,
|
include_sections = sections,
|
||||||
allow_html = allow_html,
|
allow_html = allow_html,
|
||||||
allow_tables = allow_tables
|
allow_tables = allow_tables,
|
||||||
)
|
)
|
||||||
@@ -15,5 +15,5 @@
|
|||||||
from . import python
|
from . import python
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'python'
|
'python',
|
||||||
]
|
]
|
||||||
@@ -18,5 +18,5 @@ from . import namespaces
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
*_core__all__,
|
*_core__all__,
|
||||||
'namespaces'
|
'namespaces',
|
||||||
]
|
]
|
||||||
@@ -20,7 +20,7 @@ from .definitions import (
|
|||||||
PythonAsyncFunctionDefinition,
|
PythonAsyncFunctionDefinition,
|
||||||
PythonClassDefinition,
|
PythonClassDefinition,
|
||||||
PythonDefinition,
|
PythonDefinition,
|
||||||
PythonFunctionDefinition
|
PythonFunctionDefinition,
|
||||||
)
|
)
|
||||||
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
||||||
from .docstrings import PythonDocstring
|
from .docstrings import PythonDocstring
|
||||||
@@ -63,11 +63,11 @@ _Arguments: TypeAlias = tuple[
|
|||||||
list[PythonFunctionArgument],
|
list[PythonFunctionArgument],
|
||||||
Union[PythonFunctionArgument, None],
|
Union[PythonFunctionArgument, None],
|
||||||
list[PythonFunctionArgument],
|
list[PythonFunctionArgument],
|
||||||
Union[PythonFunctionArgument, None]
|
Union[PythonFunctionArgument, None],
|
||||||
]
|
]
|
||||||
|
|
||||||
def _group_argument_list(
|
def _group_argument_list(
|
||||||
argument_list: list[PythonFunctionArgument]
|
argument_list: list[PythonFunctionArgument],
|
||||||
) -> _Arguments:
|
) -> _Arguments:
|
||||||
'''
|
'''
|
||||||
Groups the argument list into a list of positional-only arguments, a
|
Groups the argument list into a list of positional-only arguments, a
|
||||||
@@ -86,7 +86,7 @@ def _group_argument_list(
|
|||||||
for arg in argument_list
|
for arg in argument_list
|
||||||
]):
|
]):
|
||||||
raise PythonArgumentStructureError(
|
raise PythonArgumentStructureError(
|
||||||
'arguments cannot follow var-keyword argument'
|
'arguments cannot follow var-keyword argument',
|
||||||
)
|
)
|
||||||
|
|
||||||
positional_only_args = []
|
positional_only_args = []
|
||||||
@@ -106,7 +106,7 @@ def _group_argument_list(
|
|||||||
if vararg is not None:
|
if vararg is not None:
|
||||||
raise PythonArgumentStructureError(
|
raise PythonArgumentStructureError(
|
||||||
'* argument may only appear once',
|
'* argument may only appear once',
|
||||||
definition = arg
|
definition = arg,
|
||||||
)
|
)
|
||||||
vararg = arg
|
vararg = arg
|
||||||
|
|
||||||
@@ -121,11 +121,11 @@ def _group_argument_list(
|
|||||||
normal_args,
|
normal_args,
|
||||||
vararg,
|
vararg,
|
||||||
keyword_only_args,
|
keyword_only_args,
|
||||||
kwargs
|
kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _signature_argument_list(
|
def _signature_argument_list(
|
||||||
argument_list: list[PythonFunctionArgument]
|
argument_list: list[PythonFunctionArgument],
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
'''
|
'''
|
||||||
Returns a list of the arguments as strings for a function signature.
|
Returns a list of the arguments as strings for a function signature.
|
||||||
@@ -142,7 +142,7 @@ def _signature_argument_list(
|
|||||||
normal_args,
|
normal_args,
|
||||||
vararg,
|
vararg,
|
||||||
keyword_only_args,
|
keyword_only_args,
|
||||||
kwargs
|
kwargs,
|
||||||
) = _group_argument_list(argument_list)
|
) = _group_argument_list(argument_list)
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
@@ -198,7 +198,7 @@ def _markdown_table(
|
|||||||
allow_markdown_table: bool = False,
|
allow_markdown_table: bool = False,
|
||||||
force_row_lengths: bool = False,
|
force_row_lengths: bool = False,
|
||||||
one_line_values: bool = True,
|
one_line_values: bool = True,
|
||||||
missing_value: str = '--'
|
missing_value: str = '--',
|
||||||
) -> str:
|
) -> str:
|
||||||
'''
|
'''
|
||||||
Generates a table.
|
Generates a table.
|
||||||
@@ -247,7 +247,7 @@ def _markdown_table(
|
|||||||
"s"
|
"s"
|
||||||
if header_len > 1
|
if header_len > 1
|
||||||
else ""
|
else ""
|
||||||
}, got {len(row)}'
|
}, got {len(row)}',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row = _fit_row_length(header_len, row)
|
row = _fit_row_length(header_len, row)
|
||||||
@@ -273,7 +273,7 @@ def _markdown_table(
|
|||||||
"s"
|
"s"
|
||||||
if header_len > 1
|
if header_len > 1
|
||||||
else ""
|
else ""
|
||||||
}, got {len(row)}'
|
}, got {len(row)}',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row = _fit_row_length(header_len, row)
|
row = _fit_row_length(header_len, row)
|
||||||
@@ -358,7 +358,7 @@ def _argument_kind_human_readable(argument_kind: PythonArgumentKind) -> str:
|
|||||||
|
|
||||||
def _function_params_info(
|
def _function_params_info(
|
||||||
arg_list: list[PythonFunctionArgument],
|
arg_list: list[PythonFunctionArgument],
|
||||||
docstring_arg_list: list[docstring_parser.DocstringParam]
|
docstring_arg_list: list[docstring_parser.DocstringParam],
|
||||||
) -> dict[str, _FunctionParamInfo]:
|
) -> dict[str, _FunctionParamInfo]:
|
||||||
'''
|
'''
|
||||||
Returns a dictionary with the parameter info.
|
Returns a dictionary with the parameter info.
|
||||||
@@ -388,7 +388,7 @@ def _function_params_info(
|
|||||||
if arg.arg_name in arg_annotations.keys():
|
if arg.arg_name in arg_annotations.keys():
|
||||||
arg_annotations[arg.arg_name] = _FunctionParamInfo(
|
arg_annotations[arg.arg_name] = _FunctionParamInfo(
|
||||||
arg_annotations[arg.arg_name].annotation or arg.type_name,
|
arg_annotations[arg.arg_name].annotation or arg.type_name,
|
||||||
arg.description
|
arg.description,
|
||||||
)
|
)
|
||||||
|
|
||||||
return arg_annotations
|
return arg_annotations
|
||||||
@@ -427,7 +427,7 @@ class PythonDefinitionDocumentationIncludeSections:
|
|||||||
docstring: bool = True,
|
docstring: bool = True,
|
||||||
bases: bool = True,
|
bases: bool = True,
|
||||||
decorators: bool = True,
|
decorators: bool = True,
|
||||||
class_body: bool = True
|
class_body: bool = True,
|
||||||
):
|
):
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
self.returns = returns
|
self.returns = returns
|
||||||
@@ -456,13 +456,13 @@ class PythonDefinitionDocumentationIncludeSections:
|
|||||||
[
|
[
|
||||||
key + ' = ' + repr(value)
|
key + ' = ' + repr(value)
|
||||||
for key, value in self._args.items()
|
for key, value in self._args.items()
|
||||||
]
|
],
|
||||||
) + ')'
|
) + ')'
|
||||||
|
|
||||||
def __eq__(self, value) -> str:
|
def __eq__(self, value) -> str:
|
||||||
if not isinstance(
|
if not isinstance(
|
||||||
value,
|
value,
|
||||||
PythonDefinitionDocumentationIncludeSections
|
PythonDefinitionDocumentationIncludeSections,
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
return self._args == value._args
|
return self._args == value._args
|
||||||
@@ -505,7 +505,7 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
allow_html: bool = True,
|
allow_html: bool = True,
|
||||||
allow_tables: bool = False,
|
allow_tables: bool = False,
|
||||||
skip_empty_sections: bool = True,
|
skip_empty_sections: bool = True,
|
||||||
is_method: bool = False
|
is_method: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.definition = definition
|
self.definition = definition
|
||||||
self.include_sections = include_sections
|
self.include_sections = include_sections
|
||||||
@@ -539,13 +539,13 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
|
|
||||||
if isinstance(self.definition, PythonClassDefinition):
|
if isinstance(self.definition, PythonClassDefinition):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
'Cannot generate a signature of a class definition.'
|
'Cannot generate a signature of a class definition.',
|
||||||
)
|
)
|
||||||
|
|
||||||
signature = self.definition.name + '(' + ', '.join(
|
signature = self.definition.name + '(' + ', '.join(
|
||||||
_signature_argument_list(
|
_signature_argument_list(
|
||||||
self.definition.args
|
self.definition.args,
|
||||||
)
|
),
|
||||||
) + ')'
|
) + ')'
|
||||||
|
|
||||||
if self.definition.returns is not None:
|
if self.definition.returns is not None:
|
||||||
@@ -616,7 +616,7 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
|
|
||||||
params_types = _function_params_info(
|
params_types = _function_params_info(
|
||||||
self.definition.args,
|
self.definition.args,
|
||||||
self._docstring.params
|
self._docstring.params,
|
||||||
)
|
)
|
||||||
|
|
||||||
if params_types:
|
if params_types:
|
||||||
@@ -632,11 +632,11 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
('`' + arg.default + '`')
|
('`' + arg.default + '`')
|
||||||
if arg.default is not None
|
if arg.default is not None
|
||||||
else None,
|
else None,
|
||||||
non_empty_str(params_types.get(arg.name).description)
|
non_empty_str(params_types.get(arg.name).description),
|
||||||
)
|
)
|
||||||
for arg in self.definition.args
|
for arg in self.definition.args
|
||||||
],
|
],
|
||||||
allow_markdown_table = self.allow_tables
|
allow_markdown_table = self.allow_tables,
|
||||||
)
|
)
|
||||||
|
|
||||||
md += '\n\n'
|
md += '\n\n'
|
||||||
@@ -800,7 +800,7 @@ class PythonDefinitionDocumentationGenerator:
|
|||||||
allow_html = self.allow_html,
|
allow_html = self.allow_html,
|
||||||
allow_tables = self.allow_tables,
|
allow_tables = self.allow_tables,
|
||||||
skip_empty_sections = self.skip_empty_sections,
|
skip_empty_sections = self.skip_empty_sections,
|
||||||
is_method = True
|
is_method = True,
|
||||||
).generate_documentation() + '\n\n'
|
).generate_documentation() + '\n\n'
|
||||||
|
|
||||||
if not self.definition.body and not self.skip_empty_sections:
|
if not self.definition.body and not self.skip_empty_sections:
|
||||||
@@ -896,12 +896,12 @@ class PythonModuleDocumentationGenerator:
|
|||||||
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections()
|
||||||
),
|
),
|
||||||
**kwargs
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
if module_path.name.count('.') > 1:
|
if module_path.name.count('.') > 1:
|
||||||
raise InvalidNamespaceError(
|
raise InvalidNamespaceError(
|
||||||
'namespace identifier cannot contain more than one dot',
|
'namespace identifier cannot contain more than one dot',
|
||||||
namespace_identifier = module_path.name
|
namespace_identifier = module_path.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.module_path = pathlib.Path(str(module_path))
|
self.module_path = pathlib.Path(str(module_path))
|
||||||
@@ -956,8 +956,8 @@ class PythonModuleDocumentationGenerator:
|
|||||||
module_identifier = '.'.join(
|
module_identifier = '.'.join(
|
||||||
get_relative_path_segments(
|
get_relative_path_segments(
|
||||||
self.module_path,
|
self.module_path,
|
||||||
self.src_directory
|
self.src_directory,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
if module_identifier.endswith('.py'):
|
if module_identifier.endswith('.py'):
|
||||||
md += module_identifier[:-3]
|
md += module_identifier[:-3]
|
||||||
@@ -977,7 +977,7 @@ class PythonModuleDocumentationGenerator:
|
|||||||
definition,
|
definition,
|
||||||
self.include_sections,
|
self.include_sections,
|
||||||
2,
|
2,
|
||||||
**self.kwargs
|
**self.kwargs,
|
||||||
).generate_documentation() + '\n\n'
|
).generate_documentation() + '\n\n'
|
||||||
|
|
||||||
return md.strip()
|
return md.strip()
|
||||||
@@ -990,7 +990,7 @@ def _generate_package_namespace_documentation(
|
|||||||
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections()
|
||||||
),
|
),
|
||||||
kwargs: dict = {}
|
kwargs: dict = {},
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Generates the documentation for a package namespace and writes it to
|
Generates the documentation for a package namespace and writes it to
|
||||||
@@ -1021,7 +1021,7 @@ def _generate_package_namespace_documentation(
|
|||||||
documentation_directory / sub_namespace.name,
|
documentation_directory / sub_namespace.name,
|
||||||
root_directory, dir / sub_namespace.name,
|
root_directory, dir / sub_namespace.name,
|
||||||
include_sections,
|
include_sections,
|
||||||
kwargs
|
kwargs,
|
||||||
)
|
)
|
||||||
elif isinstance(sub_namespace, PythonModuleNamespace):
|
elif isinstance(sub_namespace, PythonModuleNamespace):
|
||||||
(
|
(
|
||||||
@@ -1031,7 +1031,7 @@ def _generate_package_namespace_documentation(
|
|||||||
pathlib.Path(str(dir / (sub_namespace.name + '.py'))),
|
pathlib.Path(str(dir / (sub_namespace.name + '.py'))),
|
||||||
pathlib.Path(str(root_directory)),
|
pathlib.Path(str(root_directory)),
|
||||||
include_sections,
|
include_sections,
|
||||||
**kwargs
|
**kwargs,
|
||||||
).generate_documentation()
|
).generate_documentation()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1055,7 +1055,7 @@ class PythonDocumentationGenerator:
|
|||||||
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections()
|
||||||
),
|
),
|
||||||
**kwargs
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.project_directory = pathlib.Path(str(project_directory))
|
self.project_directory = pathlib.Path(str(project_directory))
|
||||||
self.docs_directory = pathlib.Path(str(docs_directory))
|
self.docs_directory = pathlib.Path(str(docs_directory))
|
||||||
@@ -1100,5 +1100,5 @@ class PythonDocumentationGenerator:
|
|||||||
self.project_directory / 'src',
|
self.project_directory / 'src',
|
||||||
self.project_directory / 'src',
|
self.project_directory / 'src',
|
||||||
self.include_sections,
|
self.include_sections,
|
||||||
self.kwargs
|
self.kwargs,
|
||||||
)
|
)
|
||||||
@@ -20,7 +20,7 @@ from ...utils import assert_that_is_instance
|
|||||||
from ...exceptions import (
|
from ...exceptions import (
|
||||||
InvalidPythonAnnotationError,
|
InvalidPythonAnnotationError,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
PythonArgumentStructureError
|
PythonArgumentStructureError,
|
||||||
)
|
)
|
||||||
import keyword
|
import keyword
|
||||||
import types
|
import types
|
||||||
@@ -28,7 +28,7 @@ import types
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonArgumentKind',
|
'PythonArgumentKind',
|
||||||
'PythonFunctionArgument',
|
'PythonFunctionArgument',
|
||||||
'PythonASTArgumentsListParser'
|
'PythonASTArgumentsListParser',
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonArgumentKind(Enum):
|
class PythonArgumentKind(Enum):
|
||||||
@@ -57,7 +57,7 @@ class PythonFunctionArgument:
|
|||||||
name: str,
|
name: str,
|
||||||
kind: PythonArgumentKind,
|
kind: PythonArgumentKind,
|
||||||
default: Union[str, None],
|
default: Union[str, None],
|
||||||
annotation: Union[str, None]
|
annotation: Union[str, None],
|
||||||
) -> None:
|
) -> None:
|
||||||
assert_that_is_instance(name, str)
|
assert_that_is_instance(name, str)
|
||||||
assert_that_is_instance(kind, PythonArgumentKind)
|
assert_that_is_instance(kind, PythonArgumentKind)
|
||||||
@@ -68,7 +68,7 @@ class PythonFunctionArgument:
|
|||||||
if not name or not name.isidentifier() or keyword.iskeyword(name):
|
if not name or not name.isidentifier() or keyword.iskeyword(name):
|
||||||
raise InvalidPythonIdentifierError(
|
raise InvalidPythonIdentifierError(
|
||||||
'invalid identifier',
|
'invalid identifier',
|
||||||
identifier = name
|
identifier = name,
|
||||||
)
|
)
|
||||||
|
|
||||||
# check whether the annotation is a valid annotation
|
# check whether the annotation is a valid annotation
|
||||||
@@ -77,7 +77,7 @@ class PythonFunctionArgument:
|
|||||||
if annotation is not None and not annotation:
|
if annotation is not None and not annotation:
|
||||||
raise InvalidPythonAnnotationError(
|
raise InvalidPythonAnnotationError(
|
||||||
'invalid annotation',
|
'invalid annotation',
|
||||||
annotation = annotation
|
annotation = annotation,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -87,11 +87,11 @@ class PythonFunctionArgument:
|
|||||||
|
|
||||||
if self.kind in (
|
if self.kind in (
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
PythonArgumentKind.KWARGS
|
PythonArgumentKind.KWARGS,
|
||||||
) and self.default is not None:
|
) and self.default is not None:
|
||||||
raise PythonArgumentStructureError(
|
raise PythonArgumentStructureError(
|
||||||
'* or ** arguments cannot have default values',
|
'* or ** arguments cannot have default values',
|
||||||
definition = self.signature_repr()
|
definition = self.signature_repr(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __eq__(self, value: PythonFunctionArgument) -> bool:
|
def __eq__(self, value: PythonFunctionArgument) -> bool:
|
||||||
@@ -109,7 +109,7 @@ class PythonFunctionArgument:
|
|||||||
self.name,
|
self.name,
|
||||||
self.kind,
|
self.kind,
|
||||||
self.default,
|
self.default,
|
||||||
self.annotation
|
self.annotation,
|
||||||
))
|
))
|
||||||
|
|
||||||
def signature_repr(self) -> str:
|
def signature_repr(self) -> str:
|
||||||
@@ -192,8 +192,8 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
arguments.append(
|
arguments.append(
|
||||||
@@ -201,7 +201,9 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
ast.unparse(arg.annotation)))
|
ast.unparse(arg.annotation),
|
||||||
|
),
|
||||||
|
)
|
||||||
i += 1
|
i += 1
|
||||||
for arg in self.ast_arguments_list.args:
|
for arg in self.ast_arguments_list.args:
|
||||||
if arg.annotation is None:
|
if arg.annotation is None:
|
||||||
@@ -210,8 +212,8 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
arguments.append(
|
arguments.append(
|
||||||
@@ -219,8 +221,8 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
ast.unparse(arg.annotation)
|
ast.unparse(arg.annotation),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
i += 1
|
i += 1
|
||||||
if self.ast_arguments_list.vararg is not None:
|
if self.ast_arguments_list.vararg is not None:
|
||||||
@@ -230,8 +232,8 @@ class PythonASTArgumentsListParser:
|
|||||||
self.ast_arguments_list.vararg.arg,
|
self.ast_arguments_list.vararg.arg,
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
arguments.append(
|
arguments.append(
|
||||||
@@ -239,8 +241,8 @@ class PythonASTArgumentsListParser:
|
|||||||
self.ast_arguments_list.vararg.arg,
|
self.ast_arguments_list.vararg.arg,
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
ast.unparse(self.ast_arguments_list.vararg.annotation)
|
ast.unparse(self.ast_arguments_list.vararg.annotation),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
for arg in self.ast_arguments_list.kwonlyargs:
|
for arg in self.ast_arguments_list.kwonlyargs:
|
||||||
if arg.annotation is None:
|
if arg.annotation is None:
|
||||||
@@ -249,8 +251,8 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
arguments.append(
|
arguments.append(
|
||||||
@@ -258,8 +260,8 @@ class PythonASTArgumentsListParser:
|
|||||||
arg.arg,
|
arg.arg,
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
defaults[i],
|
defaults[i],
|
||||||
ast.unparse(arg.annotation)
|
ast.unparse(arg.annotation),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
i += 1
|
i += 1
|
||||||
if self.ast_arguments_list.kwarg is not None:
|
if self.ast_arguments_list.kwarg is not None:
|
||||||
@@ -269,8 +271,8 @@ class PythonASTArgumentsListParser:
|
|||||||
self.ast_arguments_list.kwarg.arg,
|
self.ast_arguments_list.kwarg.arg,
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
arguments.append(
|
arguments.append(
|
||||||
@@ -278,8 +280,8 @@ class PythonASTArgumentsListParser:
|
|||||||
self.ast_arguments_list.kwarg.arg,
|
self.ast_arguments_list.kwarg.arg,
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
ast.unparse(self.ast_arguments_list.kwarg.annotation)
|
ast.unparse(self.ast_arguments_list.kwarg.annotation),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return arguments
|
return arguments
|
||||||
@@ -26,7 +26,7 @@ __all__ = [
|
|||||||
'PythonDefinition',
|
'PythonDefinition',
|
||||||
'PythonFunctionDefinition',
|
'PythonFunctionDefinition',
|
||||||
'PythonAsyncFunctionDefinition',
|
'PythonAsyncFunctionDefinition',
|
||||||
'PythonClassDefinition'
|
'PythonClassDefinition',
|
||||||
]
|
]
|
||||||
|
|
||||||
def _python_docstring(doc: Union[str, None]) -> Union[PythonDocstring, None]:
|
def _python_docstring(doc: Union[str, None]) -> Union[PythonDocstring, None]:
|
||||||
@@ -63,12 +63,12 @@ class PythonDefinition:
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
doc: Union[PythonDocstring, None],
|
doc: Union[PythonDocstring, None],
|
||||||
decorators: list[str]
|
decorators: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
if keyword.iskeyword(name) or not name.isidentifier() or not name:
|
if keyword.iskeyword(name) or not name.isidentifier() or not name:
|
||||||
raise InvalidPythonIdentifierError(
|
raise InvalidPythonIdentifierError(
|
||||||
'invalid identifier',
|
'invalid identifier',
|
||||||
identifier = name
|
identifier = name,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_that_is_instance(doc, (PythonDocstring, types.NoneType))
|
assert_that_is_instance(doc, (PythonDocstring, types.NoneType))
|
||||||
@@ -81,7 +81,7 @@ class PythonDefinition:
|
|||||||
return (
|
return (
|
||||||
self.name,
|
self.name,
|
||||||
self.doc,
|
self.doc,
|
||||||
self.decorators
|
self.decorators,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
@@ -99,7 +99,7 @@ class PythonDefinition:
|
|||||||
return cls(
|
return cls(
|
||||||
node.name,
|
node.name,
|
||||||
_python_docstring(ast.get_docstring(node)),
|
_python_docstring(ast.get_docstring(node)),
|
||||||
[ast.unparse(d) for d in node.decorator_list]
|
[ast.unparse(d) for d in node.decorator_list],
|
||||||
)
|
)
|
||||||
|
|
||||||
def __eq__(self, value: object) -> bool:
|
def __eq__(self, value: object) -> bool:
|
||||||
@@ -133,7 +133,7 @@ class PythonFunctionDefinition(PythonDefinition):
|
|||||||
args: list[PythonFunctionArgument],
|
args: list[PythonFunctionArgument],
|
||||||
returns: Union[str, None],
|
returns: Union[str, None],
|
||||||
doc: Union[PythonDocstring, None],
|
doc: Union[PythonDocstring, None],
|
||||||
decorators: list[str]
|
decorators: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, doc, decorators)
|
super().__init__(name, doc, decorators)
|
||||||
self.args = args
|
self.args = args
|
||||||
@@ -145,7 +145,7 @@ class PythonFunctionDefinition(PythonDefinition):
|
|||||||
self.args,
|
self.args,
|
||||||
self.returns,
|
self.returns,
|
||||||
self.doc,
|
self.doc,
|
||||||
self.decorators
|
self.decorators,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -162,7 +162,7 @@ class PythonFunctionDefinition(PythonDefinition):
|
|||||||
PythonASTArgumentsListParser(node.args).to_argument_list(),
|
PythonASTArgumentsListParser(node.args).to_argument_list(),
|
||||||
ast.unparse(node.returns) if node.returns is not None else None,
|
ast.unparse(node.returns) if node.returns is not None else None,
|
||||||
_python_docstring(ast.get_docstring(node)),
|
_python_docstring(ast.get_docstring(node)),
|
||||||
[ast.unparse(d) for d in node.decorator_list]
|
[ast.unparse(d) for d in node.decorator_list],
|
||||||
)
|
)
|
||||||
|
|
||||||
class PythonAsyncFunctionDefinition(PythonFunctionDefinition):
|
class PythonAsyncFunctionDefinition(PythonFunctionDefinition):
|
||||||
@@ -210,7 +210,7 @@ class PythonClassDefinition(PythonDefinition):
|
|||||||
bases: list[str],
|
bases: list[str],
|
||||||
doc: Union[PythonDocstring, None],
|
doc: Union[PythonDocstring, None],
|
||||||
decorators: list[str],
|
decorators: list[str],
|
||||||
body: list[PythonDefinition]
|
body: list[PythonDefinition],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, doc, decorators)
|
super().__init__(name, doc, decorators)
|
||||||
self.bases = bases
|
self.bases = bases
|
||||||
@@ -222,7 +222,7 @@ class PythonClassDefinition(PythonDefinition):
|
|||||||
self.bases,
|
self.bases,
|
||||||
self.doc,
|
self.doc,
|
||||||
self.decorators,
|
self.decorators,
|
||||||
self.body
|
self.body,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -253,5 +253,5 @@ class PythonClassDefinition(PythonDefinition):
|
|||||||
expr,
|
expr,
|
||||||
(ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)
|
(ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)
|
||||||
)
|
)
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
@@ -16,7 +16,7 @@ from __future__ import annotations
|
|||||||
from ...exceptions import (
|
from ...exceptions import (
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
NamespaceNotFoundError,
|
NamespaceNotFoundError,
|
||||||
NamespaceExistsError
|
NamespaceExistsError,
|
||||||
)
|
)
|
||||||
from ...utils import assert_that_is_instance
|
from ...utils import assert_that_is_instance
|
||||||
from typing import Union, TypeAlias, Dict, List
|
from typing import Union, TypeAlias, Dict, List
|
||||||
@@ -24,7 +24,7 @@ from typing import Union, TypeAlias, Dict, List
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonNamespace',
|
'PythonNamespace',
|
||||||
'PythonPackageNamespace',
|
'PythonPackageNamespace',
|
||||||
'PythonModuleNamespace'
|
'PythonModuleNamespace',
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonNamespace:
|
class PythonNamespace:
|
||||||
@@ -40,7 +40,7 @@ class PythonNamespace:
|
|||||||
if not name.strip():
|
if not name.strip():
|
||||||
raise InvalidNamespaceError(
|
raise InvalidNamespaceError(
|
||||||
'invalid namespace',
|
'invalid namespace',
|
||||||
namespace_identifier = name
|
namespace_identifier = name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -52,8 +52,8 @@ PythonPackageNamespaceDictType: TypeAlias = Dict[
|
|||||||
str,
|
str,
|
||||||
Union[
|
Union[
|
||||||
str,
|
str,
|
||||||
'PythonPackageNamespaceDictType'
|
'PythonPackageNamespaceDictType',
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonPackageNamespace(PythonNamespace):
|
class PythonPackageNamespace(PythonNamespace):
|
||||||
@@ -69,7 +69,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
sub_namespaces: List[PythonNamespace]
|
sub_namespaces: List[PythonNamespace],
|
||||||
) -> None:
|
) -> None:
|
||||||
assert_that_is_instance(sub_namespaces, list)
|
assert_that_is_instance(sub_namespaces, list)
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
|
|
||||||
def _sub_namespaces_names(
|
def _sub_namespaces_names(
|
||||||
self,
|
self,
|
||||||
package: PythonPackageNamespace
|
package: PythonPackageNamespace,
|
||||||
) -> PythonPackageNamespaceDictType:
|
) -> PythonPackageNamespaceDictType:
|
||||||
'''
|
'''
|
||||||
Returns the names of all sub-namespaces of the specified package
|
Returns the names of all sub-namespaces of the specified package
|
||||||
@@ -177,7 +177,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
|
|
||||||
raise NamespaceNotFoundError(
|
raise NamespaceNotFoundError(
|
||||||
'no such namespace',
|
'no such namespace',
|
||||||
namespace_identifier = name
|
namespace_identifier = name,
|
||||||
)
|
)
|
||||||
|
|
||||||
def add(self, namespace: PythonNamespace) -> None:
|
def add(self, namespace: PythonNamespace) -> None:
|
||||||
@@ -195,7 +195,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
self.__getitem__(namespace.name)
|
self.__getitem__(namespace.name)
|
||||||
raise NamespaceExistsError(
|
raise NamespaceExistsError(
|
||||||
'namespace already exists',
|
'namespace already exists',
|
||||||
namespace_identifier = namespace.name
|
namespace_identifier = namespace.name,
|
||||||
)
|
)
|
||||||
except NamespaceNotFoundError:
|
except NamespaceNotFoundError:
|
||||||
self._sub_namespaces.append(namespace)
|
self._sub_namespaces.append(namespace)
|
||||||
|
|||||||
+13
-12
@@ -41,7 +41,7 @@ class ExistingDirectory(pathlib.Path):
|
|||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
errno.ENOENT,
|
errno.ENOENT,
|
||||||
'no such file or directory',
|
'no such file or directory',
|
||||||
path
|
path,
|
||||||
)
|
)
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
raise NotADirectoryError(errno.ENOTDIR, 'not a directory', path)
|
raise NotADirectoryError(errno.ENOTDIR, 'not a directory', path)
|
||||||
@@ -61,7 +61,7 @@ class ExistingFile(pathlib.Path):
|
|||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
errno.ENOENT,
|
errno.ENOENT,
|
||||||
'no such file or directory',
|
'no such file or directory',
|
||||||
path
|
path,
|
||||||
)
|
)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
raise IsADirectoryError(errno.EISDIR, 'is a directory', path)
|
raise IsADirectoryError(errno.EISDIR, 'is a directory', path)
|
||||||
@@ -85,7 +85,7 @@ def _quote(string: str, quotation_mark: str) -> str:
|
|||||||
def human_readable_list(
|
def human_readable_list(
|
||||||
ls: list,
|
ls: list,
|
||||||
final_separator: str = 'and',
|
final_separator: str = 'and',
|
||||||
quotation_mark: str = ''
|
quotation_mark: str = '',
|
||||||
) -> str:
|
) -> str:
|
||||||
'''
|
'''
|
||||||
Generates a human-readable list from a list.
|
Generates a human-readable list from a list.
|
||||||
@@ -118,7 +118,7 @@ def human_readable_list(
|
|||||||
quotation_mark
|
quotation_mark
|
||||||
) # quote the string representation of the object
|
) # quote the string representation of the object
|
||||||
for obj in ls[:-1] # do not include the last element of the list
|
for obj in ls[:-1] # do not include the last element of the list
|
||||||
]
|
],
|
||||||
) + ' ' + final_separator + ' ' + _quote(str(ls[-1]), quotation_mark)
|
) + ' ' + final_separator + ' ' + _quote(str(ls[-1]), quotation_mark)
|
||||||
|
|
||||||
def _list_type_names(types: list[type]) -> list[str]:
|
def _list_type_names(types: list[type]) -> list[str]:
|
||||||
@@ -140,13 +140,13 @@ def assert_that_is_instance(
|
|||||||
class_or_tuple: Union[
|
class_or_tuple: Union[
|
||||||
type,
|
type,
|
||||||
types.UnionType,
|
types.UnionType,
|
||||||
tuple[type, ...]
|
tuple[type, ...],
|
||||||
]
|
],
|
||||||
) -> None:
|
) -> None:
|
||||||
if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]):
|
if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'class_or_tuple: expected \'Union[type, types.UnionType, '
|
f'class_or_tuple: expected \'Union[type, types.UnionType, '
|
||||||
f'tuple[type, ...]]\', \'got {type(class_or_tuple).__name__}\''
|
f'tuple[type, ...]]\', \'got {type(class_or_tuple).__name__}\'',
|
||||||
)
|
)
|
||||||
if not isinstance(obj, class_or_tuple):
|
if not isinstance(obj, class_or_tuple):
|
||||||
if isinstance(class_or_tuple, (tuple, types.UnionType)):
|
if isinstance(class_or_tuple, (tuple, types.UnionType)):
|
||||||
@@ -157,13 +157,14 @@ def assert_that_is_instance(
|
|||||||
else:
|
else:
|
||||||
exception_message_expected = ''
|
exception_message_expected = ''
|
||||||
exception_message_expected += human_readable_list(
|
exception_message_expected += human_readable_list(
|
||||||
_list_type_names(class_or_tuple), 'or', '\'')
|
_list_type_names(class_or_tuple), 'or', '\'',
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
exception_message_expected = '\'' + class_or_tuple.__name__ + '\''
|
exception_message_expected = '\'' + class_or_tuple.__name__ + '\''
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'expected {exception_message_expected}, got \'{type(
|
f'expected {exception_message_expected}, got \'{type(
|
||||||
obj
|
obj
|
||||||
).__name__}\''
|
).__name__}\'',
|
||||||
)
|
)
|
||||||
|
|
||||||
def non_empty_str(value: Union[str, None]) -> Union[str, None]:
|
def non_empty_str(value: Union[str, None]) -> Union[str, None]:
|
||||||
@@ -192,7 +193,7 @@ def non_empty_str(value: Union[str, None]) -> Union[str, None]:
|
|||||||
|
|
||||||
def get_relative_path_segments(
|
def get_relative_path_segments(
|
||||||
path: pathlib.Path,
|
path: pathlib.Path,
|
||||||
root: pathlib.Path
|
root: pathlib.Path,
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
'''
|
'''
|
||||||
Returns the path segments relative to ``root``.
|
Returns the path segments relative to ``root``.
|
||||||
@@ -209,7 +210,7 @@ def get_relative_path_segments(
|
|||||||
return list(
|
return list(
|
||||||
path.resolve()
|
path.resolve()
|
||||||
.relative_to(
|
.relative_to(
|
||||||
root.resolve()
|
root.resolve(),
|
||||||
)
|
)
|
||||||
.parts
|
.parts,
|
||||||
)
|
)
|
||||||
@@ -21,10 +21,10 @@ def test_cli():
|
|||||||
sys.executable,
|
sys.executable,
|
||||||
'-m',
|
'-m',
|
||||||
'jcloud_docsgen',
|
'jcloud_docsgen',
|
||||||
'--help'
|
'--help',
|
||||||
],
|
],
|
||||||
capture_output = True,
|
capture_output = True,
|
||||||
text = True
|
text = True,
|
||||||
)
|
)
|
||||||
stdout = result.stdout.lower()
|
stdout = result.stdout.lower()
|
||||||
assert \
|
assert \
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from jcloud_docsgen.cli.cli import create_argument_parser
|
|||||||
@pytest.mark.parametrize('lang', [
|
@pytest.mark.parametrize('lang', [
|
||||||
'javascript',
|
'javascript',
|
||||||
'Python',
|
'Python',
|
||||||
'PYTHON'
|
'PYTHON',
|
||||||
])
|
])
|
||||||
def test_language_error(lang):
|
def test_language_error(lang):
|
||||||
parser = create_argument_parser()
|
parser = create_argument_parser()
|
||||||
@@ -27,7 +27,7 @@ def test_language_error(lang):
|
|||||||
parser.parse_args([lang])
|
parser.parse_args([lang])
|
||||||
|
|
||||||
@pytest.mark.parametrize('lang', [
|
@pytest.mark.parametrize('lang', [
|
||||||
'python'
|
'python',
|
||||||
])
|
])
|
||||||
def test_language_success(lang):
|
def test_language_success(lang):
|
||||||
parser = create_argument_parser()
|
parser = create_argument_parser()
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = False,
|
bases = False,
|
||||||
decorators = False,
|
decorators = False,
|
||||||
class_body = False
|
class_body = False,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[],
|
[],
|
||||||
@@ -48,8 +48,8 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = False,
|
bases = False,
|
||||||
decorators = False,
|
decorators = False,
|
||||||
class_body = False
|
class_body = False,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['signature'],
|
['signature'],
|
||||||
@@ -63,8 +63,8 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = False,
|
bases = False,
|
||||||
decorators = False,
|
decorators = False,
|
||||||
class_body = False
|
class_body = False,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['signature'],
|
['signature'],
|
||||||
@@ -78,13 +78,13 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = False,
|
bases = False,
|
||||||
decorators = False,
|
decorators = False,
|
||||||
class_body = False
|
class_body = False,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections(),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['signature', 'exceptions', 'bases', 'class_body'],
|
['signature', 'exceptions', 'bases', 'class_body'],
|
||||||
@@ -98,8 +98,8 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = False,
|
bases = False,
|
||||||
decorators = False,
|
decorators = False,
|
||||||
class_body = True
|
class_body = True,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
@@ -113,8 +113,8 @@ from jcloud_docsgen.core.python import (
|
|||||||
docstring = False,
|
docstring = False,
|
||||||
bases = True,
|
bases = True,
|
||||||
decorators = True,
|
decorators = True,
|
||||||
class_body = True
|
class_body = True,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
def test_parse_sections_list(include, exclude, expected):
|
def test_parse_sections_list(include, exclude, expected):
|
||||||
@@ -127,7 +127,7 @@ def test_sections_error():
|
|||||||
parser.parse_args([
|
parser.parse_args([
|
||||||
'python',
|
'python',
|
||||||
'-s',
|
'-s',
|
||||||
'param' # correct: `params`
|
'param', # correct: `params`
|
||||||
])
|
])
|
||||||
|
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
@@ -135,7 +135,7 @@ def test_sections_error():
|
|||||||
'python',
|
'python',
|
||||||
'-s',
|
'-s',
|
||||||
'params',
|
'params',
|
||||||
'docstrng' # correct: `docstring`
|
'docstrng', # correct: `docstring`
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_sections_success():
|
def test_sections_success():
|
||||||
@@ -144,13 +144,13 @@ def test_sections_success():
|
|||||||
parser.parse_args([
|
parser.parse_args([
|
||||||
'python',
|
'python',
|
||||||
'-s',
|
'-s',
|
||||||
'params'
|
'params',
|
||||||
])
|
])
|
||||||
parser.parse_args([
|
parser.parse_args([
|
||||||
'python',
|
'python',
|
||||||
'-s',
|
'-s',
|
||||||
'params',
|
'params',
|
||||||
'docstring'
|
'docstring',
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_docs_generation(expectdir):
|
def test_docs_generation(expectdir):
|
||||||
@@ -164,5 +164,5 @@ def test_docs_generation(expectdir):
|
|||||||
'docstring',
|
'docstring',
|
||||||
'-HTo',
|
'-HTo',
|
||||||
str(output_dir),
|
str(output_dir),
|
||||||
str(input_dir)
|
str(input_dir),
|
||||||
])
|
])
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -15,7 +15,7 @@
|
|||||||
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
|
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
|
||||||
from src.jcloud_docsgen.core.python.namespaces import (
|
from src.jcloud_docsgen.core.python.namespaces import (
|
||||||
PythonModuleNamespace,
|
PythonModuleNamespace,
|
||||||
PythonPackageNamespace
|
PythonPackageNamespace,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
import pathlib
|
import pathlib
|
||||||
@@ -28,9 +28,9 @@ import pathlib
|
|||||||
),
|
),
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
'tests/unit/core/python/_core/test_project_dirs/pdir_1/docs'
|
'tests/unit/core/python/_core/test_project_dirs/pdir_1/docs'
|
||||||
)
|
|
||||||
),
|
),
|
||||||
[]
|
),
|
||||||
|
[],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDocumentationGenerator(
|
PythonDocumentationGenerator(
|
||||||
@@ -39,16 +39,16 @@ import pathlib
|
|||||||
),
|
),
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
'tests/unit/core/python/_core/test_project_dirs/pdir_2/docs'
|
'tests/unit/core/python/_core/test_project_dirs/pdir_2/docs'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
[
|
[
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'pkg',
|
'pkg',
|
||||||
[
|
[
|
||||||
PythonModuleNamespace('module')
|
PythonModuleNamespace('module')
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDocumentationGenerator(
|
PythonDocumentationGenerator(
|
||||||
@@ -57,7 +57,7 @@ import pathlib
|
|||||||
),
|
),
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
'tests/unit/core/python/_core/test_project_dirs/pdir_3/docs'
|
'tests/unit/core/python/_core/test_project_dirs/pdir_3/docs'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
[
|
[
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
@@ -69,17 +69,17 @@ import pathlib
|
|||||||
[
|
[
|
||||||
PythonModuleNamespace(
|
PythonModuleNamespace(
|
||||||
'module2'
|
'module2'
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDocumentationGenerator_collect_modules(
|
def test_PythonDocumentationGenerator_collect_modules(
|
||||||
python_documentation_generator: PythonDocumentationGenerator,
|
python_documentation_generator: PythonDocumentationGenerator,
|
||||||
expected
|
expected,
|
||||||
):
|
):
|
||||||
assert python_documentation_generator.namespace() == expected
|
assert python_documentation_generator.namespace() == expected
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_PythonDocume'
|
'tests/unit/core/python/_core/test_PythonDocume'
|
||||||
'ntationGenerator/test_generate_documentation/'
|
'ntationGenerator/test_generate_documentation/'
|
||||||
)
|
),
|
||||||
).iterdir()
|
).iterdir()
|
||||||
])
|
])
|
||||||
def test_generate_documentation(dir, expectdir):
|
def test_generate_documentation(dir, expectdir):
|
||||||
@@ -103,13 +103,13 @@ def test_generate_documentation(dir, expectdir):
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_PythonDocume'
|
'tests/unit/core/python/_core/test_PythonDocume'
|
||||||
'ntationGenerator/test_generate_documentation/'
|
'ntationGenerator/test_generate_documentation/'
|
||||||
)
|
),
|
||||||
) /
|
) /
|
||||||
dir /
|
dir /
|
||||||
'project'
|
'project',
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
pathlib.Path(str(d)),
|
pathlib.Path(str(d)),
|
||||||
allow_tables = True,
|
allow_tables = True,
|
||||||
allow_html = False
|
allow_html = False,
|
||||||
).generate_documentation() # simplify the tests
|
).generate_documentation() # simplify the tests
|
||||||
@@ -25,194 +25,192 @@ import pytest
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/fil'
|
'tests/unit/core/python/_core/fil'
|
||||||
'es_with_more_than_one_dot/a.b.c'
|
'es_with_more_than_one_dot/a.b.c'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'namespace identifier cannot contain more than one dot: a.b.c'
|
'namespace identifier cannot contain more than one dot: a.b.c',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/file'
|
'tests/unit/core/python/_core/file'
|
||||||
's_with_more_than_one_dot/a.b.c.d'
|
's_with_more_than_one_dot/a.b.c.d'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'namespace identifier cannot contain more than one dot: a.b.c.d'
|
'namespace identifier cannot contain more than one dot: a.b.c.d',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files'
|
'tests/unit/core/python/_core/files'
|
||||||
'_with_more_than_one_dot/a.b.c.d.e'
|
'_with_more_than_one_dot/a.b.c.d.e'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot cont'
|
'namespace identifier cannot cont'
|
||||||
'ain more than one dot: a.b.c.d.e'
|
'ain more than one dot: a.b.c.d.e'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_'
|
'tests/unit/core/python/_core/files_'
|
||||||
'with_more_than_one_dot/a.b.c.d.e.f'
|
'with_more_than_one_dot/a.b.c.d.e.f'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot conta'
|
'namespace identifier cannot conta'
|
||||||
'in more than one dot: a.b.c.d.e.f'
|
'in more than one dot: a.b.c.d.e.f'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_w'
|
'tests/unit/core/python/_core/files_w'
|
||||||
'ith_more_than_one_dot/a.b.c.d.e.f.g'
|
'ith_more_than_one_dot/a.b.c.d.e.f.g'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contai'
|
'namespace identifier cannot contai'
|
||||||
'n more than one dot: a.b.c.d.e.f.g'
|
'n more than one dot: a.b.c.d.e.f.g'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_wi'
|
'tests/unit/core/python/_core/files_wi'
|
||||||
'th_more_than_one_dot/a.b.c.d.e.f.g.h'
|
'th_more_than_one_dot/a.b.c.d.e.f.g.h'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contain'
|
'namespace identifier cannot contain'
|
||||||
' more than one dot: a.b.c.d.e.f.g.h'
|
' more than one dot: a.b.c.d.e.f.g.h'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_wit'
|
'tests/unit/core/python/_core/files_wit'
|
||||||
'h_more_than_one_dot/a.b.c.d.e.f.g.h.py'
|
'h_more_than_one_dot/a.b.c.d.e.f.g.h.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contain m'
|
'namespace identifier cannot contain m'
|
||||||
'ore than one dot: a.b.c.d.e.f.g.h.py'
|
'ore than one dot: a.b.c.d.e.f.g.h.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_wi'
|
'tests/unit/core/python/_core/files_wi'
|
||||||
'th_more_than_one_dot/a.b.c.d.e.f.g.py'
|
'th_more_than_one_dot/a.b.c.d.e.f.g.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contain '
|
'namespace identifier cannot contain '
|
||||||
'more than one dot: a.b.c.d.e.f.g.py'
|
'more than one dot: a.b.c.d.e.f.g.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_w'
|
'tests/unit/core/python/_core/files_w'
|
||||||
'ith_more_than_one_dot/a.b.c.d.e.f.py'
|
'ith_more_than_one_dot/a.b.c.d.e.f.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contain'
|
'namespace identifier cannot contain'
|
||||||
' more than one dot: a.b.c.d.e.f.py'
|
' more than one dot: a.b.c.d.e.f.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files_'
|
'tests/unit/core/python/_core/files_'
|
||||||
'with_more_than_one_dot/a.b.c.d.e.py'
|
'with_more_than_one_dot/a.b.c.d.e.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot contai'
|
'namespace identifier cannot contai'
|
||||||
'n more than one dot: a.b.c.d.e.py'
|
'n more than one dot: a.b.c.d.e.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/files'
|
'tests/unit/core/python/_core/files'
|
||||||
'_with_more_than_one_dot/a.b.c.d.py'
|
'_with_more_than_one_dot/a.b.c.d.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot conta'
|
'namespace identifier cannot conta'
|
||||||
'in more than one dot: a.b.c.d.py'
|
'in more than one dot: a.b.c.d.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/file'
|
'tests/unit/core/python/_core/file'
|
||||||
's_with_more_than_one_dot/a.b.c.py'
|
's_with_more_than_one_dot/a.b.c.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
(
|
(
|
||||||
'namespace identifier cannot cont'
|
'namespace identifier cannot cont'
|
||||||
'ain more than one dot: a.b.c.py'
|
'ain more than one dot: a.b.c.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/fil'
|
'tests/unit/core/python/_core/fil'
|
||||||
'es_with_more_than_one_dot/a.b.py'
|
'es_with_more_than_one_dot/a.b.py'
|
||||||
)
|
),
|
||||||
)
|
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'namespace identifier cannot contain more than one dot: a.b.py'
|
'namespace identifier cannot contain more than one dot: a.b.py',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/direc'
|
'tests/unit/core/python/_core/direc'
|
||||||
'tory.with.more.than.one.dot/a.b.py'
|
'tory.with.more.than.one.dot/a.b.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'namespace identifier cannot contain more than one dot: a.b.py'
|
'namespace identifier cannot contain more than one dot: a.b.py',
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test_PythonModuleDocumentationGenerator_exceptions(
|
def test_PythonModuleDocumentationGenerator_exceptions(
|
||||||
module_path,
|
module_path,
|
||||||
src_directory,
|
src_directory,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_msg
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
PythonModuleDocumentationGenerator(module_path, src_directory)
|
PythonModuleDocumentationGenerator(module_path, src_directory)
|
||||||
@@ -225,13 +223,13 @@ def test_PythonModuleDocumentationGenerator_exceptions(
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_pr'
|
'tests/unit/core/python/_core/test_pr'
|
||||||
'oject_dirs/pdir_2/src/pkg/module.py'
|
'oject_dirs/pdir_2/src/pkg/module.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
pathlib.Path(
|
pathlib.Path(
|
||||||
'tests/unit/core/python/_core/test_project_dirs/pdir_2/src/'
|
'tests/unit/core/python/_core/test_project_dirs/pdir_2/src/'
|
||||||
),
|
),
|
||||||
allow_tables = True,
|
allow_tables = True,
|
||||||
allow_html = False
|
allow_html = False,
|
||||||
),
|
),
|
||||||
'''# Module `pkg.module`
|
'''# Module `pkg.module`
|
||||||
|
|
||||||
@@ -409,11 +407,11 @@ A dog.'''
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_pr'
|
'tests/unit/core/python/_core/test_pr'
|
||||||
'oject_dirs/pdir_2/src/pkg/module.py'
|
'oject_dirs/pdir_2/src/pkg/module.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
allow_tables = True,
|
allow_tables = True,
|
||||||
allow_html = False
|
allow_html = False,
|
||||||
),
|
),
|
||||||
'''# Module `module`
|
'''# Module `module`
|
||||||
|
|
||||||
@@ -591,11 +589,11 @@ A dog.'''
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_pr'
|
'tests/unit/core/python/_core/test_pr'
|
||||||
'oject_dirs/pdir_2/src/pkg/module.py'
|
'oject_dirs/pdir_2/src/pkg/module.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
allow_tables = True,
|
allow_tables = True,
|
||||||
allow_html = True
|
allow_html = True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'''# Module `module`
|
'''# Module `module`
|
||||||
@@ -761,7 +759,7 @@ Return type: `None`
|
|||||||
|
|
||||||
<details><summary><h3 style="display:inline">Docstring</h3></summary>A dog.'''
|
<details><summary><h3 style="display:inline">Docstring</h3></summary>A dog.'''
|
||||||
'</details>'
|
'</details>'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -770,11 +768,11 @@ Return type: `None`
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_pr'
|
'tests/unit/core/python/_core/test_pr'
|
||||||
'oject_dirs/pdir_2/src/pkg/module.py'
|
'oject_dirs/pdir_2/src/pkg/module.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
allow_tables = False,
|
allow_tables = False,
|
||||||
allow_html = True
|
allow_html = True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'''# Module `module`
|
'''# Module `module`
|
||||||
@@ -982,7 +980,7 @@ Return type: `None`
|
|||||||
|
|
||||||
<details><summary><h3 style="display:inline">Docstring</h3></summary>A '''
|
<details><summary><h3 style="display:inline">Docstring</h3></summary>A '''
|
||||||
'dog.</details>'
|
'dog.</details>'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -991,11 +989,11 @@ Return type: `None`
|
|||||||
(
|
(
|
||||||
'tests/unit/core/python/_core/test_pr'
|
'tests/unit/core/python/_core/test_pr'
|
||||||
'oject_dirs/pdir_2/src/pkg/module.py'
|
'oject_dirs/pdir_2/src/pkg/module.py'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
allow_tables = False,
|
allow_tables = False,
|
||||||
allow_html = False
|
allow_html = False,
|
||||||
),
|
),
|
||||||
'''# Module `module`
|
'''# Module `module`
|
||||||
|
|
||||||
@@ -1211,6 +1209,6 @@ A dog.'''
|
|||||||
])
|
])
|
||||||
def test_PythonModuleDocumentationGenerator_exceptions(
|
def test_PythonModuleDocumentationGenerator_exceptions(
|
||||||
module_documentation_generator,
|
module_documentation_generator,
|
||||||
expected
|
expected,
|
||||||
):
|
):
|
||||||
assert module_documentation_generator.generate_documentation() == expected
|
assert module_documentation_generator.generate_documentation() == expected
|
||||||
@@ -15,11 +15,11 @@
|
|||||||
from src.jcloud_docsgen.core.python._core import _collect_definitions
|
from src.jcloud_docsgen.core.python._core import _collect_definitions
|
||||||
from src.jcloud_docsgen.core.python.definitions import (
|
from src.jcloud_docsgen.core.python.definitions import (
|
||||||
PythonClassDefinition,
|
PythonClassDefinition,
|
||||||
PythonFunctionDefinition
|
PythonFunctionDefinition,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
import pytest
|
import pytest
|
||||||
@@ -49,20 +49,20 @@ def module(source_code: str) -> ast.Module:
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
module('''def add(a: int | float, b: int | float) -> int | float:
|
module('''def add(a: int | float, b: int | float) -> int | float:
|
||||||
@@ -97,18 +97,18 @@ class Something:
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int | float'
|
'int | float',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int | float'
|
'int | float',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'int | float',
|
'int | float',
|
||||||
PythonDocstring('Adds two numbers.'),
|
PythonDocstring('Adds two numbers.'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonClassDefinition(
|
PythonClassDefinition(
|
||||||
'Something',
|
'Something',
|
||||||
@@ -123,18 +123,18 @@ class Something:
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'value',
|
'value',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
'42',
|
'42',
|
||||||
'typing.Any'
|
'typing.Any',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'None',
|
'None',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
'value',
|
'value',
|
||||||
@@ -143,12 +143,12 @@ class Something:
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'typing.Any',
|
'typing.Any',
|
||||||
PythonDocstring('The value.'),
|
PythonDocstring('The value.'),
|
||||||
['property']
|
['property'],
|
||||||
),
|
),
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
'get_value',
|
'get_value',
|
||||||
@@ -157,16 +157,16 @@ class Something:
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'typing.Any',
|
'typing.Any',
|
||||||
PythonDocstring('Returns the value.'),
|
PythonDocstring('Returns the value.'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
module('''from src.jcloud_docsgen.core.python import (
|
module('''from src.jcloud_docsgen.core.python import (
|
||||||
@@ -244,13 +244,13 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
'project_directory',
|
'project_directory',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'docs_directory',
|
'docs_directory',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
@@ -263,8 +263,8 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
'''(pathlib.Path('tests/'), 1), (1, pathlib'''
|
'''(pathlib.Path('tests/'), 1), (1, pathlib'''
|
||||||
'''.Path('tests/')), (1, pathlib.Path('test'''
|
'''.Path('tests/')), (1, pathlib.Path('test'''
|
||||||
'''s')), (None, pathlib.Path('tests'))])'''
|
'''s')), (None, pathlib.Path('tests'))])'''
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
'test_PythonDocumentationGenerator_collect_modules',
|
'test_PythonDocumentationGenerator_collect_modules',
|
||||||
@@ -273,13 +273,13 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
'python_documentation_generator',
|
'python_documentation_generator',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'PythonDocumentationGenerator'
|
'PythonDocumentationGenerator',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'expected',
|
'expected',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
@@ -301,9 +301,9 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
'''r_3/docs')), [PythonPackageNamespace('pkg', [Python'''
|
'''r_3/docs')), [PythonPackageNamespace('pkg', [Python'''
|
||||||
'''ModuleNamespace(\'module'), PythonPackageNamespace('''
|
'''ModuleNamespace(\'module'), PythonPackageNamespace('''
|
||||||
'''\'pkg\', [PythonModuleNamespace(\'module2')])])])])'''
|
'''\'pkg\', [PythonModuleNamespace(\'module2')])])])])'''
|
||||||
)]
|
)],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
module(
|
module(
|
||||||
@@ -341,33 +341,33 @@ def test_PythonDocumentationGenerator_collect_modules(
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'value',
|
'value',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
'bool'
|
'bool',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'arg',
|
'arg',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
'bool',
|
'bool',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
])
|
])
|
||||||
def test___collect_definitions(module, expected):
|
def test___collect_definitions(module, expected):
|
||||||
assert list(_collect_definitions(module)) == expected
|
assert list(_collect_definitions(module)) == expected
|
||||||
@@ -14,17 +14,17 @@
|
|||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import (
|
from src.jcloud_docsgen.core.python._core import (
|
||||||
_function_params_info,
|
_function_params_info,
|
||||||
_FunctionParamInfo
|
_FunctionParamInfo,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
import docstring_parser
|
import docstring_parser
|
||||||
|
|
||||||
def docstring_args_list(
|
def docstring_args_list(
|
||||||
docstring: str
|
docstring: str,
|
||||||
) -> list[docstring_parser.DocstringParam]:
|
) -> list[docstring_parser.DocstringParam]:
|
||||||
'''
|
'''
|
||||||
Returns the parameter list of a docstring.
|
Returns the parameter list of a docstring.
|
||||||
@@ -42,68 +42,68 @@ def docstring_args_list(
|
|||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'int'),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'int'),
|
||||||
], ':param a: a\n:type a: str', {
|
], ':param a: a\n:type a: str', {
|
||||||
'a': _FunctionParamInfo('int', 'a')
|
'a': _FunctionParamInfo('int', 'a'),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
], ':param a: a\n:type a: str', {
|
], ':param a: a\n:type a: str', {
|
||||||
'a': _FunctionParamInfo('str', 'a')
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', None),
|
||||||
], ':param a: a\n:type a: str', {
|
], ':param a: a\n:type a: str', {
|
||||||
'a': _FunctionParamInfo('str', 'a'),
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
'b': _FunctionParamInfo(None, None)
|
'b': _FunctionParamInfo(None, None),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
|
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
|
||||||
], ':param a: a\n:type a: str', {
|
], ':param a: a\n:type a: str', {
|
||||||
'a': _FunctionParamInfo('str', 'a'),
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
'b': _FunctionParamInfo('int', None)
|
'b': _FunctionParamInfo('int', None),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
|
PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'),
|
||||||
], ':param a: a\n:type a: str\n:param b: b\n:type b: str', {
|
], ':param a: a\n:type a: str\n:param b: b\n:type b: str', {
|
||||||
'a': _FunctionParamInfo('str', 'a'),
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
'b': _FunctionParamInfo('int', 'b')
|
'b': _FunctionParamInfo('int', 'b'),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
], ':param a: a\n:type a: str\n:param b: b\n:type b: int', {
|
], ':param a: a\n:type a: str\n:param b: b\n:type b: int', {
|
||||||
'a': _FunctionParamInfo('str', 'a')
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
], '', {
|
], '', {
|
||||||
'a': _FunctionParamInfo(None, None)
|
'a': _FunctionParamInfo(None, None),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
||||||
], '', {
|
], '', {
|
||||||
'a': _FunctionParamInfo('str', None)
|
'a': _FunctionParamInfo('str', None),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
||||||
], ':param a:\n:type a: int', {
|
], ':param a:\n:type a: int', {
|
||||||
'a': _FunctionParamInfo('str', '')
|
'a': _FunctionParamInfo('str', ''),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
], ':param a:\n:type a: int', {
|
], ':param a:\n:type a: int', {
|
||||||
'a': _FunctionParamInfo('int', '')
|
'a': _FunctionParamInfo('int', ''),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None),
|
||||||
], ':param a: a', {
|
], ':param a: a', {
|
||||||
'a': _FunctionParamInfo(None, 'a')
|
'a': _FunctionParamInfo(None, 'a'),
|
||||||
}),
|
}),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'),
|
||||||
], ':param a: a', {
|
], ':param a: a', {
|
||||||
'a': _FunctionParamInfo('str', 'a')
|
'a': _FunctionParamInfo('str', 'a'),
|
||||||
}),
|
}),
|
||||||
([], ':param a: a\n:type a: str', {}),
|
([], ':param a: a\n:type a: str', {}),
|
||||||
([], '', {}),
|
([], '', {}),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[],
|
[],
|
||||||
@@ -37,7 +37,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -46,7 +46,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -57,7 +57,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a |
|
'''| a |
|
||||||
| --- |
|
| --- |
|
||||||
| 1 |'''
|
| 1 |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -68,7 +68,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a |
|
'''| a |
|
||||||
| --- |
|
| --- |
|
||||||
| 1 |'''
|
| 1 |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -79,7 +79,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a | b |
|
'''| a | b |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 1 | 2 |'''
|
| 1 | 2 |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -90,7 +90,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a | b |
|
'''| a | b |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 1 | -- |'''
|
| 1 | -- |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -101,7 +101,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a | b |
|
'''| a | b |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| -- | -- |'''
|
| -- | -- |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -113,7 +113,7 @@ import pytest
|
|||||||
'''| a | b |
|
'''| a | b |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 1 | 2 |
|
| 1 | 2 |
|
||||||
| 3 | 4 |'''
|
| 3 | 4 |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -124,7 +124,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a |
|
'''| a |
|
||||||
| --- |
|
| --- |
|
||||||
| line1 line2 |'''
|
| line1 line2 |''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -135,7 +135,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''| a |
|
'''| a |
|
||||||
| --- |
|
| --- |
|
||||||
| line1\nline2 |'''
|
| line1\nline2 |''',
|
||||||
),
|
),
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -145,7 +145,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[],
|
[],
|
||||||
@@ -154,7 +154,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -163,7 +163,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
''
|
'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -172,7 +172,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
'- a: 1'
|
'- a: 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -181,7 +181,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
'- a: 1'
|
'- a: 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -192,7 +192,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''- a: 1
|
'''- a: 1
|
||||||
|
|
||||||
b: 2'''
|
b: 2''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -203,7 +203,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''- a: 1
|
'''- a: 1
|
||||||
|
|
||||||
b: --'''
|
b: --''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -214,7 +214,7 @@ import pytest
|
|||||||
'--',
|
'--',
|
||||||
'''- a: --
|
'''- a: --
|
||||||
|
|
||||||
b: --'''
|
b: --''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -229,7 +229,7 @@ import pytest
|
|||||||
|
|
||||||
- a: 3
|
- a: 3
|
||||||
|
|
||||||
b: 4'''
|
b: 4''',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -238,7 +238,7 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
'- a: line1 line2'
|
'- a: line1 line2',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -247,9 +247,9 @@ import pytest
|
|||||||
False,
|
False,
|
||||||
False,
|
False,
|
||||||
'--',
|
'--',
|
||||||
'- a: line1\nline2'
|
'- a: line1\nline2',
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test__markdown_table(
|
def test__markdown_table(
|
||||||
header,
|
header,
|
||||||
@@ -258,7 +258,7 @@ def test__markdown_table(
|
|||||||
force_row_lengths,
|
force_row_lengths,
|
||||||
one_line_values,
|
one_line_values,
|
||||||
missing_value,
|
missing_value,
|
||||||
expected
|
expected,
|
||||||
):
|
):
|
||||||
assert _markdown_table(
|
assert _markdown_table(
|
||||||
header,
|
header,
|
||||||
@@ -266,7 +266,7 @@ def test__markdown_table(
|
|||||||
allow_markdown_table = allow_markdown_table,
|
allow_markdown_table = allow_markdown_table,
|
||||||
force_row_lengths = force_row_lengths,
|
force_row_lengths = force_row_lengths,
|
||||||
one_line_values = one_line_values,
|
one_line_values = one_line_values,
|
||||||
missing_value = missing_value
|
missing_value = missing_value,
|
||||||
) == expected
|
) == expected
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -283,7 +283,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 2'
|
'expected 1 value, got 2',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -293,7 +293,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 3'
|
'expected 1 value, got 3',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -303,7 +303,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 0'
|
'expected 1 value, got 0',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -313,7 +313,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 0'
|
'expected 2 values, got 0',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -323,7 +323,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 1'
|
'expected 2 values, got 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -333,7 +333,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 3'
|
'expected 2 values, got 3',
|
||||||
),
|
),
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -344,7 +344,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 2'
|
'expected 1 value, got 2',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -354,7 +354,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 3'
|
'expected 1 value, got 3',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a'],
|
['a'],
|
||||||
@@ -364,7 +364,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 1 value, got 0'
|
'expected 1 value, got 0',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -374,7 +374,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 0'
|
'expected 2 values, got 0',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -384,7 +384,7 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 1'
|
'expected 2 values, got 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
@@ -394,9 +394,9 @@ def test__markdown_table(
|
|||||||
True,
|
True,
|
||||||
'--',
|
'--',
|
||||||
ValueError,
|
ValueError,
|
||||||
'expected 2 values, got 3'
|
'expected 2 values, got 3',
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test__markdown_table_exceptions(
|
def test__markdown_table_exceptions(
|
||||||
header,
|
header,
|
||||||
@@ -406,7 +406,7 @@ def test__markdown_table_exceptions(
|
|||||||
one_line_values,
|
one_line_values,
|
||||||
missing_value,
|
missing_value,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_msg
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
_markdown_table(
|
_markdown_table(
|
||||||
@@ -415,6 +415,6 @@ def test__markdown_table_exceptions(
|
|||||||
allow_markdown_table = allow_markdown_table,
|
allow_markdown_table = allow_markdown_table,
|
||||||
force_row_lengths = force_row_lengths,
|
force_row_lengths = force_row_lengths,
|
||||||
one_line_values = one_line_values,
|
one_line_values = one_line_values,
|
||||||
missing_value = missing_value
|
missing_value = missing_value,
|
||||||
)
|
)
|
||||||
assert str(exc_info.value) == expected_exception_msg
|
assert str(exc_info.value) == expected_exception_msg
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
from src.jcloud_docsgen.core.python._core import _signature_argument_list
|
from src.jcloud_docsgen.core.python._core import _signature_argument_list
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -25,93 +25,93 @@ import pytest
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a']),
|
], ['a']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/']),
|
], ['a', '/']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/', 'b']),
|
], ['a', '/', 'b']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'c',
|
'c',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/', 'b', '*', 'c']),
|
], ['a', '/', 'b', '*', 'c']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'c',
|
'c',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['b', '*', 'c']),
|
], ['b', '*', 'c']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'c',
|
'c',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['*', 'c']),
|
], ['*', 'c']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'c',
|
'c',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['b', '/', '*', 'c']),
|
], ['b', '/', '*', 'c']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
], ['*args']),
|
], ['*args']),
|
||||||
([
|
([
|
||||||
@@ -119,164 +119,164 @@ import pytest
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '*args']),
|
], ['a', '*args']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a', PythonArgumentKind.POSITIONAL_ONLY,
|
'a', PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/', '*args']),
|
], ['a', '/', '*args']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['*args', 'a']),
|
], ['*args', 'a']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['*args', '**kwargs']),
|
], ['*args', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/', '*args', '**kwargs']),
|
], ['a', '/', '*args', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '*args', '**kwargs']),
|
], ['a', '*args', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'args',
|
'args',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['*args', 'a', '**kwargs']),
|
], ['*args', 'a', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['*', 'a', '**kwargs']),
|
], ['*', 'a', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '**kwargs']),
|
], ['a', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'kwargs',
|
'kwargs',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
], ['a', '/', '**kwargs']),
|
], ['a', '/', '**kwargs']),
|
||||||
([
|
([
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
'1',
|
'1',
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
], ['a: int = 1']),
|
], ['a: int = 1']),
|
||||||
])
|
])
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.exceptions import (
|
from src.jcloud_docsgen.exceptions import (
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
InvalidPythonAnnotationError,
|
InvalidPythonAnnotationError,
|
||||||
PythonArgumentStructureError
|
PythonArgumentStructureError,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'str\', got \'NoneType\''
|
'expected \'str\', got \'NoneType\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
@@ -40,7 +40,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'str\', got \'int\''
|
'expected \'str\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
42,
|
42,
|
||||||
@@ -48,7 +48,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'str\', got \'int\''
|
'expected \'str\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
4.2,
|
4.2,
|
||||||
@@ -56,7 +56,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'str\', got \'float\''
|
'expected \'str\', got \'float\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
4.2,
|
4.2,
|
||||||
@@ -64,7 +64,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'str\', got \'float\''
|
'expected \'str\', got \'float\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -72,7 +72,7 @@ import pytest
|
|||||||
1,
|
1,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected either \'str\' or \'NoneType\', got \'int\''
|
'expected either \'str\' or \'NoneType\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -80,7 +80,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
1,
|
1,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected either \'str\' or \'NoneType\', got \'int\''
|
'expected either \'str\' or \'NoneType\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -88,7 +88,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
TypeError,
|
TypeError,
|
||||||
'expected \'PythonArgumentKind\', got \'int\''
|
'expected \'PythonArgumentKind\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -96,7 +96,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
'',
|
'',
|
||||||
InvalidPythonAnnotationError,
|
InvalidPythonAnnotationError,
|
||||||
'invalid annotation'
|
'invalid annotation',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'',
|
'',
|
||||||
@@ -104,7 +104,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier'
|
'invalid identifier',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'.',
|
'.',
|
||||||
@@ -112,7 +112,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: .'
|
'invalid identifier: .',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'#',
|
'#',
|
||||||
@@ -120,7 +120,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: #'
|
'invalid identifier: #',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1a',
|
'1a',
|
||||||
@@ -128,7 +128,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1a'
|
'invalid identifier: 1a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1_',
|
'1_',
|
||||||
@@ -136,7 +136,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1_'
|
'invalid identifier: 1_',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1,',
|
'1,',
|
||||||
@@ -144,7 +144,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1,'
|
'invalid identifier: 1,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',',
|
',',
|
||||||
@@ -152,7 +152,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,'
|
'invalid identifier: ,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':',
|
':',
|
||||||
@@ -160,7 +160,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :'
|
'invalid identifier: :',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-',
|
'-',
|
||||||
@@ -168,7 +168,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -'
|
'invalid identifier: -',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';',
|
';',
|
||||||
@@ -176,7 +176,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;'
|
'invalid identifier: ;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|',
|
'|',
|
||||||
@@ -184,7 +184,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |'
|
'invalid identifier: |',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<',
|
'<',
|
||||||
@@ -192,7 +192,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <'
|
'invalid identifier: <',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>',
|
'>',
|
||||||
@@ -200,7 +200,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >'
|
'invalid identifier: >',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a,',
|
'a,',
|
||||||
@@ -208,7 +208,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a,'
|
'invalid identifier: a,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',a',
|
',a',
|
||||||
@@ -216,7 +216,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,a'
|
'invalid identifier: ,a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a:',
|
'a:',
|
||||||
@@ -224,7 +224,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a:'
|
'invalid identifier: a:',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':a',
|
':a',
|
||||||
@@ -232,7 +232,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :a'
|
'invalid identifier: :a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a-',
|
'a-',
|
||||||
@@ -240,7 +240,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a-'
|
'invalid identifier: a-',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-a',
|
'-a',
|
||||||
@@ -248,7 +248,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -a'
|
'invalid identifier: -a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a;',
|
'a;',
|
||||||
@@ -256,7 +256,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a;'
|
'invalid identifier: a;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';a',
|
';a',
|
||||||
@@ -264,7 +264,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;a'
|
'invalid identifier: ;a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a|',
|
'a|',
|
||||||
@@ -272,7 +272,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a|'
|
'invalid identifier: a|',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|a',
|
'|a',
|
||||||
@@ -280,7 +280,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |a'
|
'invalid identifier: |a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a<',
|
'a<',
|
||||||
@@ -288,7 +288,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a<'
|
'invalid identifier: a<',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<a',
|
'<a',
|
||||||
@@ -296,7 +296,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <a'
|
'invalid identifier: <a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a>',
|
'a>',
|
||||||
@@ -304,7 +304,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a>'
|
'invalid identifier: a>',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>a',
|
'>a',
|
||||||
@@ -312,7 +312,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >a'
|
'invalid identifier: >a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'class',
|
'class',
|
||||||
@@ -320,7 +320,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: class'
|
'invalid identifier: class',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'def',
|
'def',
|
||||||
@@ -328,7 +328,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: def'
|
'invalid identifier: def',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'lambda',
|
'lambda',
|
||||||
@@ -336,7 +336,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: lambda'
|
'invalid identifier: lambda',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'None',
|
'None',
|
||||||
@@ -344,7 +344,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: None'
|
'invalid identifier: None',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'True',
|
'True',
|
||||||
@@ -352,7 +352,7 @@ import pytest
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: True'
|
'invalid identifier: True',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -360,7 +360,7 @@ import pytest
|
|||||||
'1',
|
'1',
|
||||||
None,
|
None,
|
||||||
PythonArgumentStructureError,
|
PythonArgumentStructureError,
|
||||||
'* or ** arguments cannot have default values: *a = 1'
|
'* or ** arguments cannot have default values: *a = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a',
|
'a',
|
||||||
@@ -368,9 +368,9 @@ import pytest
|
|||||||
'1',
|
'1',
|
||||||
None,
|
None,
|
||||||
PythonArgumentStructureError,
|
PythonArgumentStructureError,
|
||||||
'* or ** arguments cannot have default values: **a = 1'
|
'* or ** arguments cannot have default values: **a = 1',
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test_PythonFunctionArgument_exceptions(
|
def test_PythonFunctionArgument_exceptions(
|
||||||
name,
|
name,
|
||||||
@@ -378,7 +378,7 @@ def test_PythonFunctionArgument_exceptions(
|
|||||||
default,
|
default,
|
||||||
annotation,
|
annotation,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_msg
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
PythonFunctionArgument(name, kind, default, annotation)
|
PythonFunctionArgument(name, kind, default, annotation)
|
||||||
@@ -459,18 +459,18 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation):
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a'
|
'a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
'1',
|
'1',
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a = 1'
|
'a = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
@@ -479,124 +479,124 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation):
|
|||||||
None,
|
None,
|
||||||
'int'
|
'int'
|
||||||
),
|
),
|
||||||
'a: int'
|
'a: int',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
'1',
|
'1',
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'a: int = 1'
|
'a: int = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a'
|
'a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
'1',
|
'1',
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a = 1'
|
'a = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'a: int'
|
'a: int',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.POSITIONAL_ONLY,
|
PythonArgumentKind.POSITIONAL_ONLY,
|
||||||
'1',
|
'1',
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'a: int = 1'
|
'a: int = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a'
|
'a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
'1',
|
'1',
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'a = 1'
|
'a = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'a: int'
|
'a: int',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KEYWORD_ONLY,
|
PythonArgumentKind.KEYWORD_ONLY,
|
||||||
'1',
|
'1',
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'a: int = 1'
|
'a: int = 1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'*a'
|
'*a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.VARARG,
|
PythonArgumentKind.VARARG,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'*a: int'
|
'*a: int',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
'**a'
|
'**a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.KWARGS,
|
PythonArgumentKind.KWARGS,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
'**a: int'
|
'**a: int',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonFunctionArgument_signature_repr(argument, expected):
|
def test_PythonFunctionArgument_signature_repr(argument, expected):
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
from src.jcloud_docsgen.core.python.definitions import (
|
from src.jcloud_docsgen.core.python.definitions import (
|
||||||
PythonFunctionDefinition,
|
PythonFunctionDefinition,
|
||||||
PythonClassDefinition
|
PythonClassDefinition,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
||||||
@@ -32,9 +32,9 @@ import pytest
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'PythonClassDefinition(\'A\', [], None, None, [])'
|
'PythonClassDefinition(\'A\', [], None, None, [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonClassDefinition(
|
PythonClassDefinition(
|
||||||
@@ -42,12 +42,12 @@ import pytest
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
PythonDocstring('Hello, World!'),
|
PythonDocstring('Hello, World!'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'PythonClassDefinition(\'A\', [], None, '
|
'PythonClassDefinition(\'A\', [], None, '
|
||||||
'PythonDocstring(\'Hello, World!\'), [])'
|
'PythonDocstring(\'Hello, World!\'), [])'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition_string_representation(definition, expected):
|
def test_PythonDefinition_string_representation(definition, expected):
|
||||||
@@ -67,7 +67,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier'
|
'invalid identifier',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'.',
|
'.',
|
||||||
@@ -76,7 +76,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: .'
|
'invalid identifier: .',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'#',
|
'#',
|
||||||
@@ -85,7 +85,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: #'
|
'invalid identifier: #',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1a',
|
'1a',
|
||||||
@@ -94,7 +94,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1a'
|
'invalid identifier: 1a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1_',
|
'1_',
|
||||||
@@ -103,7 +103,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1_'
|
'invalid identifier: 1_',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1,',
|
'1,',
|
||||||
@@ -112,7 +112,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1,'
|
'invalid identifier: 1,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',',
|
',',
|
||||||
@@ -121,7 +121,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,'
|
'invalid identifier: ,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':',
|
':',
|
||||||
@@ -130,7 +130,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :'
|
'invalid identifier: :',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-',
|
'-',
|
||||||
@@ -139,7 +139,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -'
|
'invalid identifier: -',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';',
|
';',
|
||||||
@@ -148,7 +148,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;'
|
'invalid identifier: ;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|',
|
'|',
|
||||||
@@ -157,7 +157,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |'
|
'invalid identifier: |',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<',
|
'<',
|
||||||
@@ -166,7 +166,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <'
|
'invalid identifier: <',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>',
|
'>',
|
||||||
@@ -175,7 +175,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >'
|
'invalid identifier: >',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a,',
|
'a,',
|
||||||
@@ -184,7 +184,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a,'
|
'invalid identifier: a,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',a',
|
',a',
|
||||||
@@ -193,7 +193,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,a'
|
'invalid identifier: ,a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a:',
|
'a:',
|
||||||
@@ -202,7 +202,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a:'
|
'invalid identifier: a:',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':a',
|
':a',
|
||||||
@@ -211,7 +211,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :a'
|
'invalid identifier: :a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a-',
|
'a-',
|
||||||
@@ -220,7 +220,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a-'
|
'invalid identifier: a-',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-a',
|
'-a',
|
||||||
@@ -229,7 +229,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -a'
|
'invalid identifier: -a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a;',
|
'a;',
|
||||||
@@ -238,7 +238,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a;'
|
'invalid identifier: a;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';a',
|
';a',
|
||||||
@@ -247,7 +247,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;a'
|
'invalid identifier: ;a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a|',
|
'a|',
|
||||||
@@ -256,7 +256,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a|'
|
'invalid identifier: a|',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|a',
|
'|a',
|
||||||
@@ -265,7 +265,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |a'
|
'invalid identifier: |a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a<',
|
'a<',
|
||||||
@@ -274,7 +274,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a<'
|
'invalid identifier: a<',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<a',
|
'<a',
|
||||||
@@ -283,7 +283,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <a'
|
'invalid identifier: <a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a>',
|
'a>',
|
||||||
@@ -292,7 +292,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a>'
|
'invalid identifier: a>',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>a',
|
'>a',
|
||||||
@@ -301,7 +301,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >a'
|
'invalid identifier: >a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'class',
|
'class',
|
||||||
@@ -310,7 +310,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: class'
|
'invalid identifier: class',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'def',
|
'def',
|
||||||
@@ -319,7 +319,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: def'
|
'invalid identifier: def',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'lambda',
|
'lambda',
|
||||||
@@ -328,7 +328,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: lambda'
|
'invalid identifier: lambda',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'None',
|
'None',
|
||||||
@@ -337,7 +337,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: None'
|
'invalid identifier: None',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'True',
|
'True',
|
||||||
@@ -346,9 +346,9 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: True'
|
'invalid identifier: True',
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test_PythonFunctionDefinition_exceptions(
|
def test_PythonFunctionDefinition_exceptions(
|
||||||
name,
|
name,
|
||||||
@@ -357,7 +357,7 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
doc,
|
doc,
|
||||||
decorators,
|
decorators,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_message
|
expected_exception_message,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
PythonClassDefinition(name, args, returns, doc, decorators)
|
PythonClassDefinition(name, args, returns, doc, decorators)
|
||||||
@@ -372,8 +372,7 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
':\n\tdef __init__(self, value: object) -> None:'
|
':\n\tdef __init__(self, value: object) -> None:'
|
||||||
'\n\t\tself._value = value\n\n\t@property\n\tdef'
|
'\n\t\tself._value = value\n\n\t@property\n\tdef'
|
||||||
' value(self) -> object:\n\t\treturn self._value'
|
' value(self) -> object:\n\t\treturn self._value'
|
||||||
)
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
PythonClassDefinition(
|
PythonClassDefinition(
|
||||||
'Class',
|
'Class',
|
||||||
@@ -388,18 +387,18 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'value',
|
'value',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'object'
|
'object',
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
'None',
|
'None',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
'value',
|
'value',
|
||||||
@@ -408,15 +407,15 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
'object',
|
'object',
|
||||||
None,
|
None,
|
||||||
['property']
|
['property'],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('class Class: ...'),
|
ast_node('class Class: ...'),
|
||||||
@@ -425,8 +424,8 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('class Class: \'\'\'docstring\'\'\''),
|
ast_node('class Class: \'\'\'docstring\'\'\''),
|
||||||
@@ -435,8 +434,8 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
[],
|
[],
|
||||||
PythonDocstring('docstring'),
|
PythonDocstring('docstring'),
|
||||||
[],
|
[],
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('class Class:\n\tdef __init__(self): ...'),
|
ast_node('class Class:\n\tdef __init__(self): ...'),
|
||||||
@@ -453,15 +452,15 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('class Class:\n\t\'\'\'doc\'\'\'\n\tdef __init__(self): ...'),
|
ast_node('class Class:\n\t\'\'\'doc\'\'\'\n\tdef __init__(self): ...'),
|
||||||
@@ -478,15 +477,15 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'self',
|
'self',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
None
|
None,
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition_from_node(node, expected):
|
def test_PythonDefinition_from_node(node, expected):
|
||||||
|
|||||||
@@ -22,17 +22,17 @@ import pytest
|
|||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'PythonDefinition(\'a\', None, [])'
|
'PythonDefinition(\'a\', None, [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('Hello, World!'),
|
PythonDocstring('Hello, World!'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])'
|
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition_string_representation(definition, expected):
|
def test_PythonDefinition_string_representation(definition, expected):
|
||||||
@@ -47,233 +47,233 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier'
|
'invalid identifier',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'.',
|
'.',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: .'
|
'invalid identifier: .',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'#',
|
'#',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: #'
|
'invalid identifier: #',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1a',
|
'1a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1a'
|
'invalid identifier: 1a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1_',
|
'1_',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1_'
|
'invalid identifier: 1_',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1,',
|
'1,',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1,'
|
'invalid identifier: 1,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',',
|
',',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,'
|
'invalid identifier: ,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':',
|
':',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :'
|
'invalid identifier: :',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-',
|
'-',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -'
|
'invalid identifier: -',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';',
|
';',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;'
|
'invalid identifier: ;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|',
|
'|',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |'
|
'invalid identifier: |',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<',
|
'<',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <'
|
'invalid identifier: <',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>',
|
'>',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >'
|
'invalid identifier: >',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a,',
|
'a,',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a,'
|
'invalid identifier: a,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',a',
|
',a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,a'
|
'invalid identifier: ,a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a:',
|
'a:',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a:'
|
'invalid identifier: a:',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':a',
|
':a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :a'
|
'invalid identifier: :a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a-',
|
'a-',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a-'
|
'invalid identifier: a-',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-a',
|
'-a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -a'
|
'invalid identifier: -a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a;',
|
'a;',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a;'
|
'invalid identifier: a;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';a',
|
';a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;a'
|
'invalid identifier: ;a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a|',
|
'a|',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a|'
|
'invalid identifier: a|',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|a',
|
'|a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |a'
|
'invalid identifier: |a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a<',
|
'a<',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a<'
|
'invalid identifier: a<',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<a',
|
'<a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <a'
|
'invalid identifier: <a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a>',
|
'a>',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a>'
|
'invalid identifier: a>',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>a',
|
'>a',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >a'
|
'invalid identifier: >a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'class',
|
'class',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: class'
|
'invalid identifier: class',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'def',
|
'def',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: def'
|
'invalid identifier: def',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'lambda',
|
'lambda',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: lambda'
|
'invalid identifier: lambda',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'None',
|
'None',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: None'
|
'invalid identifier: None',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'True',
|
'True',
|
||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: True'
|
'invalid identifier: True',
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test_PythonDefinition_exceptions(
|
def test_PythonDefinition_exceptions(
|
||||||
name,
|
name,
|
||||||
doc,
|
doc,
|
||||||
decorators,
|
decorators,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_message
|
expected_exception_message,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
PythonDefinition(name, doc, decorators)
|
PythonDefinition(name, doc, decorators)
|
||||||
@@ -285,157 +285,157 @@ def test_PythonDefinition_exceptions(
|
|||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
['a']
|
['a'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
['a']
|
['a'],
|
||||||
),
|
),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
['a', 'b']
|
['a', 'b'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
['a', 'b']
|
['a', 'b'],
|
||||||
),
|
),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'b',
|
'b',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('docs'),
|
PythonDocstring('docs'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['a']
|
['a'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['b']
|
['b'],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['a']
|
['a'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['a']
|
['a'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['a', 'b']
|
['a', 'b'],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['b', 'a']
|
['b', 'a'],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
None,
|
None,
|
||||||
['a', 'b']
|
['a', 'b'],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'a',
|
'a',
|
||||||
PythonDocstring('doc'),
|
PythonDocstring('doc'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
PythonDefinition(
|
PythonDefinition(
|
||||||
'b',
|
'b',
|
||||||
None,
|
None,
|
||||||
['a', 'b']
|
['a', 'b'],
|
||||||
),
|
),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition___eq__(definition1, definition2, expected):
|
def test_PythonDefinition___eq__(definition1, definition2, expected):
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
|
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind
|
PythonArgumentKind,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
||||||
@@ -29,9 +29,9 @@ import pytest
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'PythonFunctionDefinition(\'a\', [], None, None, [])'
|
'PythonFunctionDefinition(\'a\', [], None, None, [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
@@ -39,12 +39,12 @@ import pytest
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
PythonDocstring('Hello, World!'),
|
PythonDocstring('Hello, World!'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'PythonFunctionDefinition(\'a\', [], None,'
|
'PythonFunctionDefinition(\'a\', [], None,'
|
||||||
' PythonDocstring(\'Hello, World!\'), [])'
|
' PythonDocstring(\'Hello, World!\'), [])'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition_string_representation(definition, expected):
|
def test_PythonDefinition_string_representation(definition, expected):
|
||||||
@@ -64,7 +64,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier'
|
'invalid identifier',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'.',
|
'.',
|
||||||
@@ -73,7 +73,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: .'
|
'invalid identifier: .',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'#',
|
'#',
|
||||||
@@ -82,7 +82,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: #'
|
'invalid identifier: #',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1a',
|
'1a',
|
||||||
@@ -91,7 +91,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1a'
|
'invalid identifier: 1a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1_',
|
'1_',
|
||||||
@@ -100,7 +100,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1_'
|
'invalid identifier: 1_',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'1,',
|
'1,',
|
||||||
@@ -109,7 +109,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: 1,'
|
'invalid identifier: 1,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',',
|
',',
|
||||||
@@ -118,7 +118,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,'
|
'invalid identifier: ,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':',
|
':',
|
||||||
@@ -127,7 +127,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :'
|
'invalid identifier: :',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-',
|
'-',
|
||||||
@@ -136,7 +136,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -'
|
'invalid identifier: -',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';',
|
';',
|
||||||
@@ -145,7 +145,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;'
|
'invalid identifier: ;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|',
|
'|',
|
||||||
@@ -154,7 +154,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |'
|
'invalid identifier: |',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<',
|
'<',
|
||||||
@@ -163,7 +163,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <'
|
'invalid identifier: <',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>',
|
'>',
|
||||||
@@ -172,7 +172,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >'
|
'invalid identifier: >',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a,',
|
'a,',
|
||||||
@@ -181,7 +181,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a,'
|
'invalid identifier: a,',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
',a',
|
',a',
|
||||||
@@ -190,7 +190,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ,a'
|
'invalid identifier: ,a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a:',
|
'a:',
|
||||||
@@ -199,7 +199,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a:'
|
'invalid identifier: a:',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
':a',
|
':a',
|
||||||
@@ -208,7 +208,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: :a'
|
'invalid identifier: :a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a-',
|
'a-',
|
||||||
@@ -217,7 +217,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a-'
|
'invalid identifier: a-',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'-a',
|
'-a',
|
||||||
@@ -226,7 +226,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: -a'
|
'invalid identifier: -a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a;',
|
'a;',
|
||||||
@@ -235,7 +235,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a;'
|
'invalid identifier: a;',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
';a',
|
';a',
|
||||||
@@ -244,7 +244,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: ;a'
|
'invalid identifier: ;a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a|',
|
'a|',
|
||||||
@@ -253,7 +253,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a|'
|
'invalid identifier: a|',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'|a',
|
'|a',
|
||||||
@@ -262,7 +262,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: |a'
|
'invalid identifier: |a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a<',
|
'a<',
|
||||||
@@ -271,7 +271,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a<'
|
'invalid identifier: a<',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'<a',
|
'<a',
|
||||||
@@ -280,7 +280,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: <a'
|
'invalid identifier: <a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'a>',
|
'a>',
|
||||||
@@ -289,7 +289,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: a>'
|
'invalid identifier: a>',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'>a',
|
'>a',
|
||||||
@@ -298,7 +298,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: >a'
|
'invalid identifier: >a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'class',
|
'class',
|
||||||
@@ -307,7 +307,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: class'
|
'invalid identifier: class',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'def',
|
'def',
|
||||||
@@ -316,7 +316,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: def'
|
'invalid identifier: def',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'lambda',
|
'lambda',
|
||||||
@@ -325,7 +325,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: lambda'
|
'invalid identifier: lambda',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'None',
|
'None',
|
||||||
@@ -334,7 +334,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: None'
|
'invalid identifier: None',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'True',
|
'True',
|
||||||
@@ -343,7 +343,7 @@ def test_PythonDefinition_string_representation(definition, expected):
|
|||||||
None,
|
None,
|
||||||
[],
|
[],
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
'invalid identifier: True'
|
'invalid identifier: True',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonFunctionDefinition_exceptions(
|
def test_PythonFunctionDefinition_exceptions(
|
||||||
@@ -353,7 +353,7 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
doc,
|
doc,
|
||||||
decorators,
|
decorators,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_message
|
expected_exception_message,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
PythonFunctionDefinition(name, args, returns, doc, decorators)
|
PythonFunctionDefinition(name, args, returns, doc, decorators)
|
||||||
@@ -369,19 +369,19 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'int',
|
'int',
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('@decorator\ndef add(a: int, b: int) -> int: return a + b'),
|
ast_node('@decorator\ndef add(a: int, b: int) -> int: return a + b'),
|
||||||
@@ -392,26 +392,26 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'int',
|
'int',
|
||||||
None,
|
None,
|
||||||
['decorator']
|
['decorator'],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node(
|
ast_node(
|
||||||
(
|
(
|
||||||
'@decorator1\n@decorator2\ndef add(a'
|
'@decorator1\n@decorator2\ndef add(a'
|
||||||
': int, b: int) -> int: return a + b'
|
': int, b: int) -> int: return a + b'
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
PythonFunctionDefinition(
|
PythonFunctionDefinition(
|
||||||
'add',
|
'add',
|
||||||
@@ -420,19 +420,19 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
'a',
|
'a',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
PythonFunctionArgument(
|
PythonFunctionArgument(
|
||||||
'b',
|
'b',
|
||||||
PythonArgumentKind.NORMAL,
|
PythonArgumentKind.NORMAL,
|
||||||
None,
|
None,
|
||||||
'int'
|
'int',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'int',
|
'int',
|
||||||
None,
|
None,
|
||||||
['decorator1', 'decorator2']
|
['decorator1', 'decorator2'],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('def func(): ...'),
|
ast_node('def func(): ...'),
|
||||||
@@ -441,8 +441,8 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
[]
|
[],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ast_node('@decorator\ndef func(): ...'),
|
ast_node('@decorator\ndef func(): ...'),
|
||||||
@@ -451,8 +451,8 @@ def test_PythonFunctionDefinition_exceptions(
|
|||||||
[],
|
[],
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
['decorator']
|
['decorator'],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonDefinition_from_node(node, expected):
|
def test_PythonDefinition_from_node(node, expected):
|
||||||
|
|||||||
@@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
from src.jcloud_docsgen.core.python.namespaces import (
|
from src.jcloud_docsgen.core.python.namespaces import (
|
||||||
PythonPackageNamespace,
|
PythonPackageNamespace,
|
||||||
PythonModuleNamespace
|
PythonModuleNamespace,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
from src.jcloud_docsgen.exceptions import (
|
from src.jcloud_docsgen.exceptions import (
|
||||||
NamespaceNotFoundError,
|
NamespaceNotFoundError,
|
||||||
InvalidNamespaceError
|
InvalidNamespaceError,
|
||||||
)
|
)
|
||||||
|
|
||||||
class StrSubclass(str): ...
|
class StrSubclass(str): ...
|
||||||
@@ -28,23 +28,23 @@ class StrSubclass(str): ...
|
|||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'a'
|
'a',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'1',
|
'1',
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
'1'
|
'1',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
StrSubclass('a'),
|
StrSubclass('a'),
|
||||||
[]
|
[],
|
||||||
),
|
),
|
||||||
StrSubclass('a')
|
StrSubclass('a'),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
|
def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
|
||||||
@@ -52,7 +52,7 @@ def test_PythonPackageNamespace_name_attribute(namespace, expected_name):
|
|||||||
|
|
||||||
namespace_b = PythonModuleNamespace('b')
|
namespace_b = PythonModuleNamespace('b')
|
||||||
namespace_a = PythonPackageNamespace('a', [
|
namespace_a = PythonPackageNamespace('a', [
|
||||||
namespace_b
|
namespace_b,
|
||||||
])
|
])
|
||||||
namespace_c = PythonModuleNamespace('c')
|
namespace_c = PythonModuleNamespace('c')
|
||||||
namespace_k = PythonModuleNamespace('k')
|
namespace_k = PythonModuleNamespace('k')
|
||||||
@@ -68,47 +68,47 @@ namespace_d = PythonPackageNamespace('d', [namespace_e])
|
|||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'name',
|
'name',
|
||||||
[namespace_a, namespace_c]
|
[namespace_a, namespace_c],
|
||||||
),
|
),
|
||||||
['c'],
|
['c'],
|
||||||
namespace_c
|
namespace_c,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'name',
|
'name',
|
||||||
[namespace_a, namespace_c]
|
[namespace_a, namespace_c],
|
||||||
),
|
),
|
||||||
['a'],
|
['a'],
|
||||||
namespace_a
|
namespace_a,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'name',
|
'name',
|
||||||
[namespace_a, namespace_c]
|
[namespace_a, namespace_c],
|
||||||
),
|
),
|
||||||
['a', 'b'],
|
['a', 'b'],
|
||||||
namespace_b
|
namespace_b,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_d,
|
namespace_d,
|
||||||
['e', 'f', 'g', 'h', 'i'],
|
['e', 'f', 'g', 'h', 'i'],
|
||||||
namespace_i
|
namespace_i,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_d,
|
namespace_d,
|
||||||
['e', 'f', 'g', 'h', 'i', 'j'],
|
['e', 'f', 'g', 'h', 'i', 'j'],
|
||||||
namespace_j
|
namespace_j,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_d,
|
namespace_d,
|
||||||
['e', 'f', 'g', 'h', 'i', 'j', 'k'],
|
['e', 'f', 'g', 'h', 'i', 'j', 'k'],
|
||||||
namespace_k
|
namespace_k,
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace_namespace(
|
def test_PythonPackageNamespace_namespace(
|
||||||
namespace: PythonPackageNamespace,
|
namespace: PythonPackageNamespace,
|
||||||
sub_namespaces,
|
sub_namespaces,
|
||||||
expected
|
expected,
|
||||||
):
|
):
|
||||||
assert namespace.namespace(sub_namespaces) == expected
|
assert namespace.namespace(sub_namespaces) == expected
|
||||||
|
|
||||||
@@ -119,39 +119,39 @@ def test_PythonPackageNamespace_namespace(
|
|||||||
namespace_a,
|
namespace_a,
|
||||||
['c'],
|
['c'],
|
||||||
NamespaceNotFoundError,
|
NamespaceNotFoundError,
|
||||||
'no such namespace: c'
|
'no such namespace: c',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_h,
|
namespace_h,
|
||||||
['i', 'k'],
|
['i', 'k'],
|
||||||
NamespaceNotFoundError,
|
NamespaceNotFoundError,
|
||||||
'no such namespace: k'
|
'no such namespace: k',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_a,
|
namespace_a,
|
||||||
['b', ''],
|
['b', ''],
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'invalid namespace'
|
'invalid namespace',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_a,
|
namespace_a,
|
||||||
['', 'b'],
|
['', 'b'],
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'invalid namespace'
|
'invalid namespace',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_a,
|
namespace_a,
|
||||||
['b', '', 'b'],
|
['b', '', 'b'],
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
'invalid namespace'
|
'invalid namespace',
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
)
|
)
|
||||||
def test_PythonPackageNamespace_namespace_exceptions(
|
def test_PythonPackageNamespace_namespace_exceptions(
|
||||||
namespace,
|
namespace,
|
||||||
sub_namespaces,
|
sub_namespaces,
|
||||||
expected_exception,
|
expected_exception,
|
||||||
expected_exception_msg
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(expected_exception) as exc_info:
|
with pytest.raises(expected_exception) as exc_info:
|
||||||
namespace.namespace(sub_namespaces)
|
namespace.namespace(sub_namespaces)
|
||||||
@@ -161,9 +161,9 @@ def test_PythonPackageNamespace_namespace_exceptions(
|
|||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
[PythonModuleNamespace('b')]
|
[PythonModuleNamespace('b')],
|
||||||
),
|
),
|
||||||
{'b': 'b'}
|
{'b': 'b'},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
@@ -172,19 +172,19 @@ def test_PythonPackageNamespace_namespace_exceptions(
|
|||||||
PythonModuleNamespace('b'),
|
PythonModuleNamespace('b'),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'c',
|
'c',
|
||||||
[PythonModuleNamespace('d')]
|
[PythonModuleNamespace('d')],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
'b': 'b',
|
'b': 'b',
|
||||||
'c': {'d': 'd'}
|
'c': {'d': 'd'},
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace('a', []),
|
PythonPackageNamespace('a', []),
|
||||||
{}
|
{},
|
||||||
)
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
||||||
assert namespace.sub_namespace_names() == expected
|
assert namespace.sub_namespace_names() == expected
|
||||||
@@ -193,13 +193,13 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
|||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
[PythonModuleNamespace('b')]
|
[PythonModuleNamespace('b')],
|
||||||
),
|
),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
[PythonModuleNamespace('b')]
|
[PythonModuleNamespace('b')],
|
||||||
),
|
),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
@@ -208,9 +208,9 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
|||||||
PythonModuleNamespace('b'),
|
PythonModuleNamespace('b'),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'c',
|
'c',
|
||||||
[PythonModuleNamespace('d')]
|
[PythonModuleNamespace('d')],
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
),
|
),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
@@ -218,21 +218,21 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected):
|
|||||||
PythonModuleNamespace('b'),
|
PythonModuleNamespace('b'),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'c',
|
'c',
|
||||||
[PythonModuleNamespace('d')]
|
[PythonModuleNamespace('d')],
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
True
|
],
|
||||||
|
),
|
||||||
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace('a', []),
|
PythonPackageNamespace('a', []),
|
||||||
PythonPackageNamespace('a', []),
|
PythonPackageNamespace('a', []),
|
||||||
True
|
True,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace('a', []),
|
PythonPackageNamespace('a', []),
|
||||||
PythonPackageNamespace('b', []),
|
PythonPackageNamespace('b', []),
|
||||||
False
|
False,
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
|
def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
|
||||||
@@ -242,19 +242,19 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
|
|||||||
@pytest.mark.parametrize('namespace,expected', [
|
@pytest.mark.parametrize('namespace,expected', [
|
||||||
(
|
(
|
||||||
PythonPackageNamespace('a', []),
|
PythonPackageNamespace('a', []),
|
||||||
'PythonPackageNamespace(\'a\', [])'
|
'PythonPackageNamespace(\'a\', [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace('1', []),
|
PythonPackageNamespace('1', []),
|
||||||
'PythonPackageNamespace(\'1\', [])'
|
'PythonPackageNamespace(\'1\', [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
PythonPackageNamespace(StrSubclass('a'), []),
|
PythonPackageNamespace(StrSubclass('a'), []),
|
||||||
'PythonPackageNamespace(\'a\', [])'
|
'PythonPackageNamespace(\'a\', [])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_a,
|
namespace_a,
|
||||||
'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])'
|
'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
namespace_d,
|
namespace_d,
|
||||||
@@ -264,8 +264,8 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected):
|
|||||||
'geNamespace(\'g\', [PythonPackageNamespace(\'h\', [P'
|
'geNamespace(\'g\', [PythonPackageNamespace(\'h\', [P'
|
||||||
'ythonPackageNamespace(\'i\', [PythonPackageNamespace'
|
'ythonPackageNamespace(\'i\', [PythonPackageNamespace'
|
||||||
'(\'j\', [PythonModuleNamespace(\'k\')])])])])])])])'
|
'(\'j\', [PythonModuleNamespace(\'k\')])])])])])])])'
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace_string_representation(namespace, expected):
|
def test_PythonPackageNamespace_string_representation(namespace, expected):
|
||||||
assert repr(namespace) == expected
|
assert repr(namespace) == expected
|
||||||
@@ -276,14 +276,14 @@ def test_PythonPackageNamespace_string_representation(namespace, expected):
|
|||||||
PythonModuleNamespace('b'),
|
PythonModuleNamespace('b'),
|
||||||
PythonPackageNamespace(
|
PythonPackageNamespace(
|
||||||
'a',
|
'a',
|
||||||
[PythonModuleNamespace('b')]
|
[PythonModuleNamespace('b')],
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
])
|
])
|
||||||
def test_PythonPackageNamespace___getitem__(
|
def test_PythonPackageNamespace___getitem__(
|
||||||
namespace,
|
namespace,
|
||||||
new_namespace,
|
new_namespace,
|
||||||
expected
|
expected,
|
||||||
):
|
):
|
||||||
namespace.add(new_namespace)
|
namespace.add(new_namespace)
|
||||||
assert namespace == expected
|
assert namespace == expected
|
||||||
@@ -34,33 +34,33 @@ def test_assert_that_is_instance(obj, class_or_tuple):
|
|||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
str,
|
str,
|
||||||
'expected \'str\', got \'int\''
|
'expected \'str\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
(str,),
|
(str,),
|
||||||
'expected \'str\', got \'int\''
|
'expected \'str\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
str | float,
|
str | float,
|
||||||
'expected either \'str\' or \'float\', got \'int\''
|
'expected either \'str\' or \'float\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
str | float | list,
|
str | float | list,
|
||||||
'expected either \'str\', \'float\' or \'list\', got \'int\''
|
'expected either \'str\', \'float\' or \'list\', got \'int\'',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
TestType,
|
TestType,
|
||||||
'expected \'NOT TestType\', got \'int\''
|
'expected \'NOT TestType\', got \'int\'',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_assert_that_is_instance_exceptions(
|
def test_assert_that_is_instance_exceptions(
|
||||||
obj,
|
obj,
|
||||||
class_or_tuple,
|
class_or_tuple,
|
||||||
expected_exception_msg
|
expected_exception_msg,
|
||||||
):
|
):
|
||||||
with pytest.raises(TypeError) as exc_info:
|
with pytest.raises(TypeError) as exc_info:
|
||||||
assert_that_is_instance(obj, class_or_tuple)
|
assert_that_is_instance(obj, class_or_tuple)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import pytest
|
|||||||
[1, 2, 3, 42, 'a', 23],
|
[1, 2, 3, 42, 'a', 23],
|
||||||
'and',
|
'and',
|
||||||
'\'',
|
'\'',
|
||||||
'\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\''
|
'\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\'',
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_human_readable_list(ls, final_separator, quotation_mark, expected):
|
def test_human_readable_list(ls, final_separator, quotation_mark, expected):
|
||||||
|
|||||||
Reference in new issue
Block a user