From c3c22ff3a67764d459f041ff5b69b0cc3e985e9b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 18 Jan 2021 11:10:31 +0100 Subject: [PATCH] minor fixes --- pdoc/__main__.py | 35 ++++++++++++++------------- pdoc/templates/error.html.jinja2 | 2 +- pdoc/templates/index.html.jinja2 | 2 +- pdoc/templates/module.html.jinja2 | 2 +- test/snapshots/demo.html | 2 +- test/snapshots/demo_eager.html | 2 +- test/snapshots/demo_long.html | 2 +- test/snapshots/demopackage.html | 2 +- test/snapshots/indent.html | 2 +- test/snapshots/submodules_in_all.html | 2 +- test/test_main.py | 6 ++--- 11 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pdoc/__main__.py b/pdoc/__main__.py index 691dd161..37141d5b 100644 --- a/pdoc/__main__.py +++ b/pdoc/__main__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import argparse import platform import subprocess @@ -73,11 +75,11 @@ help="Don't start a browser, even if no output directory is set.", ) parser.add_argument( - '--help', action='help', default=argparse.SUPPRESS, + '--help', action='help', help="Show this help message and exit.") parser.add_argument( "--version", - action="store_true", default=argparse.SUPPRESS, + action="store_true", help="Show version information and exit.", ) @@ -118,11 +120,10 @@ def get_dev_version() -> str: return pdoc_version -def cli(args=None): +def cli(args: list[str] = None) -> None: """ Command-line entry point """ - args = parser.parse_args(args) - - if args.version: + opts = parser.parse_args(args) + if opts.version: print( f"pdoc: {get_dev_version()}\n" f"Python: {platform.python_version()}\n" @@ -131,27 +132,27 @@ def cli(args=None): return render.configure( - edit_url_map=dict(x.split("=", 1) for x in args.edit_url), - template_directory=args.template_directory, + edit_url_map=dict(x.split("=", 1) for x in opts.edit_url), + template_directory=opts.template_directory, ) - if args.output_directory: + if opts.output_directory: pdoc.pdoc( - *args.modules, - output_directory=args.output_directory, - format=args.format or "html", + *opts.modules, + output_directory=opts.output_directory, + format="html", # opts.format or ) return else: - all_modules = extract.parse_specs(args.modules) + all_modules = extract.parse_specs(opts.modules) with pdoc.web.DocServer( - (args.host, args.port), all_modules, + (opts.host, opts.port), all_modules, ) as httpd: - url = f"http://{args.host}:{args.port}" + url = f"http://{opts.host}:{opts.port}" print(f"pdoc server ready at {url}") - if not args.no_browser: - if len(args.modules) == 1: + if not opts.no_browser: + if len(opts.modules) == 1: mod = next(iter(all_modules)) url += f"/{mod.replace('.', '/')}.html" pdoc.web.open_browser(url) diff --git a/pdoc/templates/error.html.jinja2 b/pdoc/templates/error.html.jinja2 index dba487b6..921f920c 100644 --- a/pdoc/templates/error.html.jinja2 +++ b/pdoc/templates/error.html.jinja2 @@ -30,5 +30,5 @@
{{ details }}

+ href="https://pdoc.dev">{% include 'logo.svg' %} {% endblock %} diff --git a/pdoc/templates/index.html.jinja2 b/pdoc/templates/index.html.jinja2 index 8ab97da8..b3aa51d8 100644 --- a/pdoc/templates/index.html.jinja2 +++ b/pdoc/templates/index.html.jinja2 @@ -65,7 +65,7 @@ {% endblock %} {% block body %} - +
Available Modules
diff --git a/pdoc/templates/module.html.jinja2 b/pdoc/templates/module.html.jinja2 index 5bd39ec2..ef4dbb95 100644 --- a/pdoc/templates/module.html.jinja2 +++ b/pdoc/templates/module.html.jinja2 @@ -454,7 +454,7 @@ {{ nav_members(module.members.values()) }} {% endif %} -
diff --git a/test/snapshots/demo.html b/test/snapshots/demo.html index 9dea5857..57aebd23 100644 --- a/test/snapshots/demo.html +++ b/test/snapshots/demo.html @@ -75,7 +75,7 @@

Contents

- diff --git a/test/snapshots/demo_eager.html b/test/snapshots/demo_eager.html index fa2bb979..04eba0a7 100644 --- a/test/snapshots/demo_eager.html +++ b/test/snapshots/demo_eager.html @@ -53,7 +53,7 @@

Contents

- diff --git a/test/snapshots/demo_long.html b/test/snapshots/demo_long.html index e55969c3..716e41d1 100644 --- a/test/snapshots/demo_long.html +++ b/test/snapshots/demo_long.html @@ -250,7 +250,7 @@

Contents

- diff --git a/test/snapshots/demopackage.html b/test/snapshots/demopackage.html index decfc899..cbd0bc21 100644 --- a/test/snapshots/demopackage.html +++ b/test/snapshots/demopackage.html @@ -66,7 +66,7 @@

Contents

- diff --git a/test/snapshots/indent.html b/test/snapshots/indent.html index 1f526f0a..26c1f45c 100644 --- a/test/snapshots/indent.html +++ b/test/snapshots/indent.html @@ -129,7 +129,7 @@

Contents

- diff --git a/test/snapshots/submodules_in_all.html b/test/snapshots/submodules_in_all.html index 17822670..c032ac58 100644 --- a/test/snapshots/submodules_in_all.html +++ b/test/snapshots/submodules_in_all.html @@ -53,7 +53,7 @@

Contents

- diff --git a/test/test_main.py b/test/test_main.py index cf6a73f2..13b76bd0 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -10,13 +10,13 @@ def test_cli(tmp_path): - cli(args=[str(here / "snapshots" / "demo_long.py"), "-o", str(tmp_path)]) + cli([str(here / "snapshots" / "demo_long.py"), "-o", str(tmp_path)]) assert (tmp_path / "demo_long.html").read_text().startswith("") assert (tmp_path / "index.html").read_text().startswith("") def test_cli_version(capsys): - cli(args=["--version"]) + cli(["--version"]) assert "pdoc:" in capsys.readouterr().out @@ -26,7 +26,7 @@ def test_cli_web(monkeypatch): "pdoc.web.DocServer.serve_forever", side_effect=KeyboardInterrupt ) as serve_forever: with pytest.raises(KeyboardInterrupt): - cli(args=[str(here / "snapshots" / "demopackage" / "_child.py")]) + cli([str(here / "snapshots" / "demopackage" / "_child.py")]) assert open_browser.call_args == call("http://localhost:8080/demopackage/_child.html") assert serve_forever.call_args == call()