generated from jCloud/repository-template
Add internal function to generate the documentation of a package namespace
This commit is contained in:
@@ -835,6 +835,35 @@ class PythonModuleDocumentationGenerator:
|
||||
|
||||
return md.strip()
|
||||
|
||||
def _generate_package_namespace_documentation(namespace: PythonPackageNamespace, documentation_directory: ExistingDirectory, root_directory: ExistingDirectory) -> None:
|
||||
'''
|
||||
Generates the documentation for a package namespace and writes it to
|
||||
the documentation directory.
|
||||
|
||||
:param namespace: The namespace.
|
||||
:type namespace: PythonPackageNamespace
|
||||
:param documentation_directory: The directory for the documentation.
|
||||
:type documentation_directory: ExistingDirectory
|
||||
:param root_directory: The root directory.
|
||||
:type root_directory: ExistingDirectory
|
||||
'''
|
||||
|
||||
assert_that_is_instance(documentation_directory, ExistingDirectory)
|
||||
|
||||
documentation_directory = pathlib.Path(str(documentation_directory))
|
||||
|
||||
for sub_namespace in namespace.sub_namespaces:
|
||||
if isinstance(sub_namespace, PythonPackageNamespace):
|
||||
_generate_package_namespace_documentation(sub_namespace, documentation_directory / sub_namespace.name, root_directory)
|
||||
elif isinstance(sub_namespace, PythonModuleNamespace):
|
||||
(
|
||||
documentation_directory / (sub_namespace.name + '.py')
|
||||
).write_text(
|
||||
PythonModuleDocumentationGenerator(
|
||||
documentation_directory / sub_namespace.name,
|
||||
root_directory
|
||||
).generate_documentation()
|
||||
)
|
||||
|
||||
class PythonDocumentationGenerator:
|
||||
'''
|
||||
@@ -878,3 +907,16 @@ class PythonDocumentationGenerator:
|
||||
self._namespace(dir)
|
||||
for dir in src_dir.iterdir() if dir.is_dir()
|
||||
]
|
||||
|
||||
def generate_documentation(self) -> None:
|
||||
'''
|
||||
Generates the full project documentation and writes it to the
|
||||
documentation directory.
|
||||
'''
|
||||
|
||||
namespaces = self.namespace()
|
||||
|
||||
for namespace in namespaces:
|
||||
namespace_documentation_directory = self.docs_directory / namespace.name
|
||||
namespace_documentation_directory.mkdir()
|
||||
_generate_package_namespace_documentation(namespace, namespace_documentation_directory, self.project_directory / 'src' / namespace.name)
|
||||
Reference in New Issue
Block a user