Feat(cli): add base command-line interface #16

Merged
jakob.scheid merged 21 commits from feature/cli into main 2026-09-13 20:11:00 +02:00
Showing only changes of commit 089cf5f2ff - Show all commits
+37 -18
View File
@@ -18,11 +18,47 @@ from typing import Optional
__all__ = [ __all__ = [
'VALID_SECTIONS', 'VALID_SECTIONS',
'parse_sections_list',
'generate' 'generate'
] ]
VALID_SECTIONS = list(PythonDefinitionDocumentationIncludeSections()._args.keys()) VALID_SECTIONS = list(PythonDefinitionDocumentationIncludeSections()._args.keys())
def parse_sections_list(include_sections: Optional[list[str]] = None, exclude_sections: list[str] = []) -> PythonDefinitionDocumentationIncludeSections:
'''
Returns a Python definition documentation sections list from the
sections list to be included and the sections list to be excluded.
These lists both consist of the sections as strings which contain
the section name.
:param include_sections: The list of sections to be included.
:type include_sections: Optional[list[str]]
:param exclude_sections: The list of sections to be excluded.
:type exclude_sections: list[str]
:return: The Python definition documentation sections object.
:rtype: PythonDefinitionDocumentationIncludeSections
'''
if include_sections is None:
include_sections = VALID_SECTIONS
for section in exclude_sections:
while section in include_sections:
del include_sections[include_sections.index(section)]
return PythonDefinitionDocumentationIncludeSections(
signature = 'signature' in include_sections,
returns = 'returns' in include_sections,
params = 'params' in include_sections,
exceptions = 'exceptions' in include_sections,
examples = 'examples' in include_sections,
docstring = 'docstring' in include_sections,
bases = 'bases' in include_sections,
decorators = 'decorators' in include_sections,
class_body = 'class_body' in include_sections
)
def _generate( def _generate(
project_directory: pathlib.Path, project_directory: pathlib.Path,
output_directory: pathlib.Path, output_directory: pathlib.Path,
@@ -86,24 +122,7 @@ def generate(
Warning: Markdown tables are not CommonMark. Warning: Markdown tables are not CommonMark.
''' '''
if include_sections is None: sections = parse_sections_list(include_sections, exclude_sections)
include_sections = VALID_SECTIONS
for section in exclude_sections:
while section in include_sections:
del include_sections[include_sections.index(section)]
sections = PythonDefinitionDocumentationIncludeSections(
signature = 'signature' in include_sections,
returns = 'returns' in include_sections,
params = 'params' in include_sections,
exceptions = 'exceptions' in include_sections,
examples = 'examples' in include_sections,
docstring = 'docstring' in include_sections,
bases = 'bases' in include_sections,
decorators = 'decorators' in include_sections,
class_body = 'class_body' in include_sections
) if include_sections else PythonDefinitionDocumentationIncludeSections()
_generate( _generate(
project_directory, project_directory,