Merge pull request 'Feat(python-generator): remove implicit assumptions of project directory structure' (#39) from feature/no-src-dir-need into main

Reviewed-on: #39
This commit was merged in pull request #39.
This commit is contained in:
jakob.scheid authored and Gitea committed 2026-09-22 19:28:50 +02:00
commit 2fe342cbc6
12 files changed
+13 -18

No files matched your search

+1
View File
@@ -12,6 +12,7 @@
- Replaced the installation instructions, which used the old registry, with a reference to the Gitea Package Registry in README
- Made Python function signatures (argument default values) compliant with PEP 8
- Removed implicit Python project directory structure assumptions
### Deprecated
+1 -3
View File
@@ -78,6 +78,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
'-o',
'--output-dir',
type=pathlib.Path,
default='docs/reference',
help='the output directory the documentation will be written to',
)
@@ -138,9 +139,6 @@ def main(argv=None) -> int:
argument_parser = create_argument_parser()
args = argument_parser.parse_args(argv)
if args.output_dir is None:
args.output_dir = args.project_directory / 'docs/reference'
try:
if args.language == _LANG_PYTHON:
from .languages.python import generate
+6 -10
View File
@@ -1104,19 +1104,15 @@ class PythonDocumentationGenerator:
return namespace
def namespace(self) -> list[PythonPackageNamespace]:
def namespace(self) -> PythonPackageNamespace:
"""
Returns 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(dir) for dir in src_dir.iterdir() if dir.is_dir()
]
return self._namespace(self.project_directory)
def generate_documentation(self) -> None:
"""
@@ -1127,10 +1123,10 @@ class PythonDocumentationGenerator:
self.docs_directory.mkdir(parents=True, exist_ok=True)
_generate_package_namespace_documentation(
PythonPackageNamespace('src', self.namespace()),
self.namespace(),
self.docs_directory,
self.project_directory / 'src',
self.project_directory / 'src',
self.project_directory,
self.project_directory,
self.include_sections,
self.kwargs,
)
@@ -31,7 +31,7 @@ from src.jcloud_docsgen.core.python.namespaces import (
(
PythonDocumentationGenerator(
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_1'
'tests/unit/core/python/_core/test_project_dirs/pdir_1/src'
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_1/docs'
@@ -42,7 +42,7 @@ from src.jcloud_docsgen.core.python.namespaces import (
(
PythonDocumentationGenerator(
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_2'
'tests/unit/core/python/_core/test_project_dirs/pdir_2/src'
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_2/docs'
@@ -58,7 +58,7 @@ from src.jcloud_docsgen.core.python.namespaces import (
(
PythonDocumentationGenerator(
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_3'
'tests/unit/core/python/_core/test_project_dirs/pdir_3/src'
),
pathlib.Path(
'tests/unit/core/python/_core/test_project_dirs/pdir_3/docs'
@@ -85,7 +85,7 @@ def test_PythonDocumentationGenerator_collect_modules(
python_documentation_generator: PythonDocumentationGenerator,
expected,
):
assert python_documentation_generator.namespace() == expected
assert python_documentation_generator.namespace().sub_namespaces == expected
@pytest.mark.parametrize(
@@ -130,7 +130,7 @@ def test_creates_directory():
project_dir = pathlib.Path(project_dir)
# The directory of the package
package_dir = project_dir / 'src' / 'pkg'
package_dir = project_dir / 'pkg'
assert not package_dir.exists()
package_dir.mkdir(parents=True, exist_ok=True)