generated from jCloud/repository-template
refactor(cli): rename 'parsers' package to 'languages'
This commit is contained in:
3 files changed
+2
-2
No files matched your search
@@ -0,0 +1,114 @@
|
||||
# Copyright 2026 jCloud
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import pathlib
|
||||
from ...core.python import PythonDefinitionDocumentationIncludeSections, PythonDocumentationGenerator
|
||||
from typing import Optional
|
||||
|
||||
__all__ = [
|
||||
'VALID_SECTIONS',
|
||||
'generate'
|
||||
]
|
||||
|
||||
VALID_SECTIONS = list(PythonDefinitionDocumentationIncludeSections()._args.keys())
|
||||
|
||||
def _generate(
|
||||
project_directory: pathlib.Path,
|
||||
output_directory: pathlib.Path,
|
||||
*,
|
||||
include_sections: PythonDefinitionDocumentationIncludeSections = PythonDefinitionDocumentationIncludeSections(),
|
||||
allow_html: bool = False,
|
||||
allow_tables: bool = False
|
||||
) -> None:
|
||||
'''
|
||||
Generates the documentation for a Python project.
|
||||
|
||||
:param project_directory: The project directory.
|
||||
:type project_directory: pathlib.Path
|
||||
:param output_directory: The output directory.
|
||||
:type output_directory: pathlib.Path
|
||||
:param include_sections: The sections to be included in the
|
||||
documentation.
|
||||
:type include_sections: PythonDefinitionDocumentationIncludeSections
|
||||
:param allow_html: Indicates whether HTML is allowed to appear in
|
||||
the generated documentation.
|
||||
:type allow_html: bool
|
||||
:param allow_tables: Indicates whether Markdown tables are allowed.
|
||||
Warning: Markdown tables are not CommonMark.
|
||||
'''
|
||||
|
||||
docs_generator = PythonDocumentationGenerator(
|
||||
project_directory,
|
||||
output_directory,
|
||||
include_sections = include_sections,
|
||||
allow_html = allow_html,
|
||||
allow_tables = allow_tables
|
||||
)
|
||||
docs_generator.generate_documentation()
|
||||
|
||||
def generate(
|
||||
project_directory: pathlib.Path,
|
||||
output_directory: pathlib.Path,
|
||||
*,
|
||||
include_sections: Optional[list[str]] = None,
|
||||
exclude_sections: list[str] = [],
|
||||
allow_html: bool = False,
|
||||
allow_tables: bool = False
|
||||
) -> None:
|
||||
'''
|
||||
Generates the documentation for a Python project.
|
||||
|
||||
:param project_directory: The project directory.
|
||||
:type project_directory: pathlib.Path
|
||||
:param output_directory: The output directory.
|
||||
:type output_directory: pathlib.Path
|
||||
:param include_sections: The sections to be included in the
|
||||
documentation.
|
||||
:type include_sections: Optional[list[str]]
|
||||
:param exclude_sections: The sections to be excluded in the
|
||||
documentation.
|
||||
:type exclude_sections: list[str]
|
||||
:param allow_html: Indicates whether HTML is allowed to appear in
|
||||
the generated documentation.
|
||||
:type allow_html: bool
|
||||
:param allow_tables: Indicates whether Markdown tables are allowed.
|
||||
Warning: Markdown tables are not CommonMark.
|
||||
'''
|
||||
|
||||
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)]
|
||||
|
||||
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(
|
||||
project_directory,
|
||||
output_directory,
|
||||
include_sections = sections,
|
||||
allow_html = allow_html,
|
||||
allow_tables = allow_tables
|
||||
)
|
||||
Reference in new issue
Block a user