feat(python-generator)!: do not require specific structure

Removed all implicit assumptions of a project structure:
  - no 'src/' directory is required
  - top-level modules are no longer ignored
This commit is contained in:
jakob.scheid committed 2026-09-22 18:28:35 +02:00
1 parent d0ea392f62
commit 0fbfe84657
2 files changed
+7 -13

No files matched your search

+1 -3
View File
@@ -78,6 +78,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
'-o', '-o',
'--output-dir', '--output-dir',
type=pathlib.Path, type=pathlib.Path,
default='docs/reference',
help='the output directory the documentation will be written to', help='the output directory the documentation will be written to',
) )
@@ -138,9 +139,6 @@ def main(argv=None) -> int:
argument_parser = create_argument_parser() argument_parser = create_argument_parser()
args = argument_parser.parse_args(argv) args = argument_parser.parse_args(argv)
if args.output_dir is None:
args.output_dir = args.project_directory / 'docs/reference'
try: try:
if args.language == _LANG_PYTHON: if args.language == _LANG_PYTHON:
from .languages.python import generate from .languages.python import generate
+6 -10
View File
@@ -1104,19 +1104,15 @@ class PythonDocumentationGenerator:
return namespace return namespace
def namespace(self) -> list[PythonPackageNamespace]: def namespace(self) -> PythonPackageNamespace:
""" """
Returns the project as a namespace. Returns the project as a namespace.
:return: The project as a namespace. :return: The project as a namespace.
:rtype: list[PythonPackageNamespace] :rtype: PythonPackageNamespace:
""" """
src_dir = self.project_directory / 'src' return self._namespace(self.project_directory)
return [
self._namespace(dir) for dir in src_dir.iterdir() if dir.is_dir()
]
def generate_documentation(self) -> None: def generate_documentation(self) -> None:
""" """
@@ -1127,10 +1123,10 @@ class PythonDocumentationGenerator:
self.docs_directory.mkdir(parents=True, exist_ok=True) self.docs_directory.mkdir(parents=True, exist_ok=True)
_generate_package_namespace_documentation( _generate_package_namespace_documentation(
PythonPackageNamespace('src', self.namespace()), self.namespace(),
self.docs_directory, self.docs_directory,
self.project_directory / 'src', self.project_directory,
self.project_directory / 'src', self.project_directory,
self.include_sections, self.include_sections,
self.kwargs, self.kwargs,
) )