From 114e12f1510c8b7a86be88e8e94314ec702cbfd1 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 25 Mar 2021 13:12:28 +0100 Subject: [PATCH] [setup] Added build documentation target --- .gitignore | 1 + run_flaschengeist | 18 +++++++++--------- setup.py | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 7718450..886770a 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/ # PyBuilder target/ diff --git a/run_flaschengeist b/run_flaschengeist index ce06a1c..610b9eb 100644 --- a/run_flaschengeist +++ b/run_flaschengeist @@ -17,7 +17,7 @@ class PrefixMiddleware(object): def __call__(self, environ, start_response): if environ["PATH_INFO"].startswith(self.prefix): - environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix) :] + environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix):] environ["SCRIPT_NAME"] = self.prefix return self.app(environ, start_response) else: @@ -83,19 +83,19 @@ class InterfaceGenerator: import typing if ( - inspect.ismodule(module[1]) - and module[1].__name__.startswith(self.basename) - and module[1].__name__ not in self.known + inspect.ismodule(module[1]) + and module[1].__name__.startswith(self.basename) + and module[1].__name__ not in self.known ): self.known.append(module[1].__name__) for cls in inspect.getmembers(module[1], lambda x: inspect.isclass(x) or inspect.ismodule(x)): self.walker(cls) elif ( - inspect.isclass(module[1]) - and module[1].__module__.startswith(self.basename) - and module[0] not in self.classes - and not module[0].startswith("_") - and hasattr(module[1], "__annotations__") + inspect.isclass(module[1]) + and module[1].__module__.startswith(self.basename) + and module[0] not in self.classes + and not module[0].startswith("_") + and hasattr(module[1], "__annotations__") ): self.this_type = module[0] print("\n\n" + module[0] + "\n") diff --git a/setup.py b/setup.py index d28760d..c1c2847 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,35 @@ -from setuptools import setup, find_packages +from setuptools import setup, find_packages, Command +import subprocess import os mysql_driver = "PyMySQL" if os.name == "nt" else "mysqlclient" + +class DocsCommand(Command): + description = "Generate and export API documentation" + user_options = [ + # The format is (long option, short option, description). + ("output=", "o", "Documentation output path"), + ] + + def initialize_options(self): + self.output = "./docs" + + def finalize_options(self): + pass + + def run(self): + """Run command.""" + command = ["python", "-m", "pdoc", "--skip-errors", "--html", "--output-dir", self.output, "flaschengeist"] + self.announce( + "Running command: %s" % str(command), + ) + subprocess.check_call(command) + + setup( name="flaschengeist", - version="2.0.0-dev", + version="2.0.0.dev0", url="https://wu5.de/redmine/projects/geruecht", author="WU5 + Friends", author_email="tim@groeger-clan.de", @@ -23,7 +47,7 @@ setup( "werkzeug", mysql_driver, ], - extras_require={"ldap": ["flask_ldapconn", "ldap3"], "pricelist": ["pillow"],"test": ["pytest", "coverage"]}, + extras_require={"ldap": ["flask_ldapconn", "ldap3"], "pricelist": ["pillow"], "test": ["pytest", "coverage"]}, entry_points={ "flaschengeist.plugin": [ # Authentication providers @@ -39,4 +63,7 @@ setup( "pricelist = flaschengeist.plugins.pricelist:PriceListPlugin [pricelist]", ], }, + cmdclass={ + "docs": DocsCommand, + }, )