From ad7b9273a0e78c9a232c5d0ccf1f17edf3bac4a5 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Wed, 31 Jan 2024 00:26:15 -0800 Subject: [PATCH] doc work --- README.rst | 2 +- django_typer/__init__.py | 27 ++++++++-------- doc/source/_static/commands.css | 3 ++ doc/source/_static/style.css | 0 doc/source/changelog.rst | 25 +++++++++++++-- doc/source/commands.rst | 9 ++++++ doc/source/conf.py | 16 ++++++++- doc/source/index.rst | 1 + doc/source/reference.rst | 57 +++++++++++++++++++++++++++++++-- doc/source/refs.rst | 1 + pyproject.toml | 2 +- 11 files changed, 123 insertions(+), 20 deletions(-) create mode 100644 doc/source/_static/commands.css create mode 100644 doc/source/_static/style.css create mode 100644 doc/source/commands.rst diff --git a/README.rst b/README.rst index 523f6c94..5116b3ed 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ All of the BaseCommand functionality is preserved, so that TyperCommand can be a .. warning:: - This is an early beta release. Expect rapid changes. + This is a late beta release. The interface is mostly stable but there may be lingering issues. .. code-block:: python diff --git a/django_typer/__init__.py b/django_typer/__init__.py index b6480692..31e7ec95 100644 --- a/django_typer/__init__.py +++ b/django_typer/__init__.py @@ -1,18 +1,20 @@ r""" - ___ _ _____ - / (_) __ _ _ __ __ _ ___ /__ \_ _ _ __ ___ _ __ - / /\ / |/ _` | '_ \ / _` |/ _ \ / /\/ | | | '_ \ / _ \ '__| - / /_//| | (_| | | | | (_| | (_) | / / | |_| | |_) | __/ | -/___,'_/ |\__,_|_| |_|\__, |\___/ \/ \__, | .__/ \___|_| - |__/ |___/ |___/|_| +:: + + ___ _ _____ + / (_) __ _ _ __ __ _ ___ /__ \_ _ _ __ ___ _ __ + / /\ / |/ _` | '_ \ / _` |/ _ \ / /\/ | | | '_ \ / _ \ '__| + / /_//| | (_| | | | | (_| | (_) | / / | |_| | |_) | __/ | + /___,'_/ |\__,_|_| |_|\__, |\___/ \/ \__, | .__/ \___|_| + |__/ |___/ |___/|_| django-typer provides an extension to the base django management command class that melds the typer/click infrastructure with the django infrastructure. The result is all the ease of specifying commands, groups and options and arguments using typer and -click in a way that feels like and is interface compatible with django's base -management commands This should enable a smooth transition for existing django -commands and an intuitive feel for implementing new commands. +click in a way that feels like and is interface compatible with django's BaseCommand_ +This should enable a smooth transition for existing django commands and an intuitive +feel for implementing new commands. django-typer also supports shell completion for bash, zsh, fish and powershell and extends that support to native django management commands as well. @@ -46,7 +48,6 @@ import contextlib import inspect -import os import sys import typing as t from copy import deepcopy @@ -78,7 +79,7 @@ from .types import Style as ColorStyle from .types import Traceback, Verbosity, Version -VERSION = (0, 4, "0b") +VERSION = (0, 5, "0b") __title__ = "Django Typer" __version__ = ".".join(str(i) for i in VERSION) @@ -1288,7 +1289,7 @@ class definition time (i.e. on module load). When the TyperCommand is instantiat the command tree is built thats used for subcommand resolution in django-typer's get_command method and for help output. - All of the documented BaseCommand functionality works as expected. call_command() + All of the documented BaseCommand_ functionality works as expected. call_command() also works as expected. TyperCommands however add a few extra features: - Simple TyperCommands implemented only using handle() can be invoked directly @@ -1520,7 +1521,7 @@ def execute(self, *args, **options): below this call may use get_current_command() to get a reference to the command instance. - *args and **options are passed to handle(). + args and options are passed to handle(). :param args: the arguments to pass to the command :param options: the options to pass to the command diff --git a/doc/source/_static/commands.css b/doc/source/_static/commands.css new file mode 100644 index 00000000..92562f48 --- /dev/null +++ b/doc/source/_static/commands.css @@ -0,0 +1,3 @@ +.wy-nav-content { + max-width: 100%; +} diff --git a/doc/source/_static/style.css b/doc/source/_static/style.css new file mode 100644 index 00000000..e69de29b diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 80f3a774..5d0d69e6 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,7 +2,28 @@ Change Log ========== -v0.1.0 -====== +v0.5.0b +======= + +* Incremental Beta Release + +v0.4.0b +======= + +* Incremental Beta Release + +v0.3.0b +======= + +* Incremental Beta Release + +v0.2.0b +======= + +* Incremental Beta Release + + +v0.1.0b +======= * Initial Release (Beta) diff --git a/doc/source/commands.rst b/doc/source/commands.rst new file mode 100644 index 00000000..02f316ce --- /dev/null +++ b/doc/source/commands.rst @@ -0,0 +1,9 @@ +======== +Commands +======== + +.. typer:: django_typer.management.commands.shellcompletion.Command:typer_app + :prog: shellcompletion + :width: 100 + :show-nested: + :make-sections: diff --git a/doc/source/conf.py b/doc/source/conf.py index fc042edf..b142173c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,7 +1,12 @@ from datetime import datetime import sys +import os from pathlib import Path from sphinx.ext.autodoc import between +import django + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_typer.tests.settings') +django.setup() sys.path.append(str(Path(__file__).parent.parent.parent)) import django_typer @@ -64,10 +69,18 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] +html_static_path = [ + '_static', +] +html_css_files = [ + 'style.css', +] todo_include_todos = True +def add_page_class(app, pagename, templatename, context, doctree): + from sphinx.builders.html._assets import _CascadingStyleSheet + context['css_files'] += [_CascadingStyleSheet(f'_static/{pagename}.css')] def setup(app): # Register a sphinx.ext.autodoc.between listener to ignore everything @@ -76,4 +89,5 @@ def setup(app): 'autodoc-process-docstring', between('^.*[*]{79}.*$', exclude=True) ) + app.connect('html-page-context', add_page_class) return app diff --git a/doc/source/index.rst b/doc/source/index.rst index 91427e09..8cdd250f 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -21,5 +21,6 @@ Installation :maxdepth: 2 :caption: Contents: + commands reference changelog diff --git a/doc/source/reference.rst b/doc/source/reference.rst index 76649c09..321f4c47 100644 --- a/doc/source/reference.rst +++ b/doc/source/reference.rst @@ -8,7 +8,7 @@ Reference .. _base: -Base Classes +django_typer ------------ .. automodule:: django_typer @@ -20,8 +20,61 @@ Base Classes .. _types: -Types +types ----- .. automodule:: django_typer.types :members: + + +.. _parsers: + +parsers +------- + +.. automodule:: django_typer.parsers + :members: + +.. _completers: + +completers +---------- + +.. automodule:: django_typer.completers + :members: + +.. _utils: + +utils +----- + +.. automodule:: django_typer.utils + :members: + + +.. _patch: + +patch +----- + +.. automodule:: django_typer.patch + :members: + + +.. _apps: + +apps +---- + +.. automodule:: django_typer.apps + :members: + + +.. _shellcompletion: + +shellcompletion +--------------- + +.. automodule:: django_typer.management.commands.shellcompletion + :members: + \ No newline at end of file diff --git a/doc/source/refs.rst b/doc/source/refs.rst index 692b62fc..57ec68a1 100644 --- a/doc/source/refs.rst +++ b/doc/source/refs.rst @@ -4,3 +4,4 @@ .. _PyPI: https://pypi.python.org/pypi/django-typer .. _Typer: https://typer.tiangolo.com/ .. _DRY: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself +.. _BaseCommand: https://docs.djangoproject.com/en/stable/howto/custom-management-commands/#command-objects diff --git a/pyproject.toml b/pyproject.toml index bfcd1311..7a268a8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-typer" -version = "0.4.0b" +version = "0.5.0b" description = "Use Typer to define the CLI for your Django management commands." authors = ["Brian Kohan "] license = "MIT"