autodocument argparser

This commit is contained in:
Patrick Kanzler 2023-09-25 00:18:27 +02:00
parent 486f4a50dc
commit ca450d667a
6 changed files with 27 additions and 6 deletions

View File

@ -43,6 +43,7 @@ extensions = [
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.imgconverter",
"sphinxarg.ext",
"sphinxcontrib.datatemplates",
"sphinxcontrib.spelling",
]

View File

@ -24,6 +24,7 @@ are relevant to the user of this library.
user/printers
user/raspi
user/usage
user/cli-user
user/barcode
Printer profiles

View File

@ -11,5 +11,6 @@ python-barcode>=0.11.0,<1
importlib-metadata
importlib_resources
sphinxcontrib.datatemplates
sphinx-argparse
sphinx-autodoc-typehints
pycups

10
doc/user/cli-user.rst Normal file
View File

@ -0,0 +1,10 @@
CLI
===
:Last Reviewed: 2023-09-25
Documentation of the command line interface, callable with ``python-escpos``.
.. argparse::
:ref: escpos.cli.generate_parser
:prog: python-escpos

View File

@ -487,12 +487,8 @@ def print_extended_information() -> None:
)
def main():
"""Handle main entry point of CLI script.
Handles loading of configuration and creating and processing of command
line arguments. Called when run from a CLI.
"""
def generate_parser() -> argparse.ArgumentParser:
"""Generate an argparse parser."""
parser = argparse.ArgumentParser(
description="CLI for python-escpos",
epilog="Printer configuration is defined in the python-escpos config"
@ -563,6 +559,17 @@ def main():
)
parser_command_version_extended.set_defaults(version_extended=True)
return parser
def main():
"""Handle main entry point of CLI script.
Handles loading of configuration and creating and processing of command
line arguments. Called when run from a CLI.
"""
parser = generate_parser()
# hook in argcomplete
if "argcomplete" in globals():
argcomplete.autocomplete(parser)

View File

@ -33,6 +33,7 @@ changedir = doc
deps = sphinx>=7.2.3
setuptools_scm
python-barcode
sphinx-argparse
sphinxcontrib-spelling>=8.0.0
sphinxcontrib.datatemplates
sphinx-autodoc-typehints