generated from jCloud/repository-template
feat(cli): add Python generator force argument
This commit is contained in:
2 files changed
+20
-1
No files matched your search
@@ -82,6 +82,15 @@ def create_argument_parser() -> argparse.ArgumentParser:
|
|||||||
default='docs/reference',
|
default='docs/reference',
|
||||||
help='the output directory the documentation will be written to',
|
help='the output directory the documentation will be written to',
|
||||||
)
|
)
|
||||||
|
common_parser.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--force',
|
||||||
|
action='store_true',
|
||||||
|
help=(
|
||||||
|
'generate documentation even if the output directory is not '
|
||||||
|
'empty. Warning: data can be lost when setting this flag.'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
argument_parser = argparse.ArgumentParser()
|
argument_parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
@@ -151,6 +160,7 @@ def main(argv=None) -> int:
|
|||||||
exclude_sections=args.sections_exclude,
|
exclude_sections=args.sections_exclude,
|
||||||
allow_html=args.allow_html,
|
allow_html=args.allow_html,
|
||||||
allow_tables=args.allow_tables,
|
allow_tables=args.allow_tables,
|
||||||
|
force=args.force,
|
||||||
)
|
)
|
||||||
except FileNotFoundError as exc:
|
except FileNotFoundError as exc:
|
||||||
return error(f'{exc.filename}: no such file or directory')
|
return error(f'{exc.filename}: no such file or directory')
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ def _generate(
|
|||||||
),
|
),
|
||||||
allow_html: bool = False,
|
allow_html: bool = False,
|
||||||
allow_tables: bool = False,
|
allow_tables: bool = False,
|
||||||
|
force: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Generates the documentation for a Python project.
|
Generates the documentation for a Python project.
|
||||||
@@ -94,6 +95,9 @@ def _generate(
|
|||||||
:type allow_html: bool
|
:type allow_html: bool
|
||||||
:param allow_tables: Indicates whether Markdown tables are allowed.
|
:param allow_tables: Indicates whether Markdown tables are allowed.
|
||||||
Warning: Markdown tables are not CommonMark.
|
Warning: Markdown tables are not CommonMark.
|
||||||
|
:param force: Indicates whether the output directory shall be
|
||||||
|
overwritten if it is not empty.
|
||||||
|
:type force: bool
|
||||||
"""
|
"""
|
||||||
|
|
||||||
docs_generator = PythonDocumentationGenerator(
|
docs_generator = PythonDocumentationGenerator(
|
||||||
@@ -103,7 +107,7 @@ def _generate(
|
|||||||
allow_html=allow_html,
|
allow_html=allow_html,
|
||||||
allow_tables=allow_tables,
|
allow_tables=allow_tables,
|
||||||
)
|
)
|
||||||
docs_generator.generate_documentation()
|
docs_generator.generate_documentation(force)
|
||||||
|
|
||||||
|
|
||||||
def generate(
|
def generate(
|
||||||
@@ -114,6 +118,7 @@ def generate(
|
|||||||
exclude_sections: list[str] = [],
|
exclude_sections: list[str] = [],
|
||||||
allow_html: bool = False,
|
allow_html: bool = False,
|
||||||
allow_tables: bool = False,
|
allow_tables: bool = False,
|
||||||
|
force: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Generates the documentation for a Python project.
|
Generates the documentation for a Python project.
|
||||||
@@ -133,6 +138,9 @@ def generate(
|
|||||||
:type allow_html: bool
|
:type allow_html: bool
|
||||||
:param allow_tables: Indicates whether Markdown tables are allowed.
|
:param allow_tables: Indicates whether Markdown tables are allowed.
|
||||||
Warning: Markdown tables are not CommonMark.
|
Warning: Markdown tables are not CommonMark.
|
||||||
|
:param force: Indicates whether the output directory shall be
|
||||||
|
overwritten if it is not empty.
|
||||||
|
:type force: bool
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sections = parse_sections_list(include_sections, exclude_sections)
|
sections = parse_sections_list(include_sections, exclude_sections)
|
||||||
@@ -143,4 +151,5 @@ def generate(
|
|||||||
include_sections=sections,
|
include_sections=sections,
|
||||||
allow_html=allow_html,
|
allow_html=allow_html,
|
||||||
allow_tables=allow_tables,
|
allow_tables=allow_tables,
|
||||||
|
force=force,
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user