Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-sphinx-click for openSUSE:Factory checked in at 2022-11-01 13:42:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-sphinx-click (Old) and /work/SRC/openSUSE:Factory/.python-sphinx-click.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sphinx-click" Tue Nov 1 13:42:06 2022 rev:2 rq:1032478 version:4.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-sphinx-click/python-sphinx-click.changes 2022-04-13 21:06:49.456668041 +0200 +++ /work/SRC/openSUSE:Factory/.python-sphinx-click.new.2275/python-sphinx-click.changes 2022-11-01 13:42:14.719793018 +0100 @@ -1,0 +2,42 @@ +Fri Oct 7 16:22:14 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> + +- Update to version 4.3.0 + * Fix typo + * Add release note for auto_envvar_prefix support + * add functionality to also render env-variables that are created via the ???auto_envvar_prefix??? option + +- Update to version 4.2.0 + * Extend pre-wrapped text support to options + * tests: Use Command tests, not Group tests + * tests: Add test for boolean options + +- Update to version 4.1.0 + * docs: Don???t recommend using ???setup.py??? + * docs: Indicate support for asyncclick + * asyncclick target + * docs: Remove ???language??? configuration + * docs: Add root directory to PATH for docs build + * docs: Remove noise from conf.py + * tox: Enable nitpicky mode for docs builds + +- Update to version 4.0.3 + * Correct ???get_command??? argument type error + +- Update to version 4.0.2 + * Correctly ignore empty ???commands??? parameter + +- Update to version 4.0.1 + * docs: Correct typo + * Configure mypy + * Add typing hints + * Pass Context, not self, to MultiCommand + * Add test for truncation + +- Update to version 4.0.0 + * Add Python 3.10 support, drop Python 3.6 support + * Uncap coverage, remove test-requirements.txt + * Update pre-commit hooks + * Add support for click 8.1.x + * setup: Update URL + +------------------------------------------------------------------- Old: ---- sphinx-click-3.1.0.tar.gz New: ---- sphinx-click-4.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-sphinx-click.spec ++++++ --- /var/tmp/diff_new_pack.iU9Nbd/_old 2022-11-01 13:42:15.175795443 +0100 +++ /var/tmp/diff_new_pack.iU9Nbd/_new 2022-11-01 13:42:15.183795486 +0100 @@ -18,18 +18,18 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-sphinx-click -Version: 3.1.0 +Version: 4.3.0 Release: 0 Summary: Sphinx extension that automatically documents click applications License: MIT URL: https://github.com/stephenfin/sphinx-click Source: https://files.pythonhosted.org/packages/source/s/sphinx_click/sphinx-click-%{version}.tar.gz -BuildRequires: python-rpm-macros -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module pbr} BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} -BuildRequires: %{python_module pbr} BuildRequires: fdupes +BuildRequires: python-rpm-macros BuildArch: noarch BuildRequires: python-rpm-generators %{?python_enable_dependency_generator} ++++++ sphinx-click-3.1.0.tar.gz -> sphinx-click-4.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/.github/workflows/ci.yaml new/sphinx-click-4.3.0/.github/workflows/ci.yaml --- old/sphinx-click-3.1.0/.github/workflows/ci.yaml 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/.github/workflows/ci.yaml 2022-07-04 13:00:24.000000000 +0200 @@ -10,10 +10,10 @@ steps: - name: Checkout source code uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install dependencies run: python -m pip install tox - name: Run tox @@ -23,7 +23,7 @@ runs-on: ubuntu-latest strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9] + python: ["3.7", "3.8", "3.9", "3.10"] steps: - name: Checkout source code uses: actions/checkout@v2 @@ -44,10 +44,10 @@ uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install dependencies run: python -m pip install tox - name: Build docs (via tox) @@ -68,10 +68,10 @@ uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install dependencies run: python -m pip install build - name: Build a binary wheel and a source tarball diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/.pre-commit-config.yaml new/sphinx-click-4.3.0/.pre-commit-config.yaml --- old/sphinx-click-3.1.0/.pre-commit-config.yaml 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/.pre-commit-config.yaml 2022-07-04 13:00:24.000000000 +0200 @@ -6,11 +6,11 @@ python: python3 repos: - repo: https://github.com/ambv/black - rev: 21.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.2.0 hooks: - id: trailing-whitespace - id: mixed-line-ending diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/AUTHORS new/sphinx-click-4.3.0/AUTHORS --- old/sphinx-click-3.1.0/AUTHORS 2022-02-02 13:23:20.000000000 +0100 +++ new/sphinx-click-4.3.0/AUTHORS 2022-07-04 13:00:34.000000000 +0200 @@ -12,10 +12,13 @@ JeremyB <jeremybillhei...@gmail.com> Jiri Kuncar <jiri.kun...@gmail.com> Jos?? S??nchez-Gallego <galle...@uw.edu> +Lev Gorodetskiy <github@droserasprout.space> Maarten ter Huurne <maar...@treewalker.org> Miro Hron??ok <m...@hroncok.cz> Omer Cohen <g...@omerc.net> +Patrik.Hlobil <patrik.hlo...@dm.de> Phillip Smyth <phillip.sm...@codethink.co.uk> +R??gis Behmo <git...@behmo.com> Stephen Finucane <step...@that.guru> Tim Abramson <tim.abram...@code42.com> William Jamir Silva <williamja...@gmail.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/ChangeLog new/sphinx-click-4.3.0/ChangeLog --- old/sphinx-click-3.1.0/ChangeLog 2022-02-02 13:23:20.000000000 +0100 +++ new/sphinx-click-4.3.0/ChangeLog 2022-07-04 13:00:34.000000000 +0200 @@ -1,6 +1,59 @@ CHANGES ======= +4.3.0 +----- + +* Fix typo +* Add release note for auto\_envvar\_prefix support +* add functionality to also render env-variables that are created via the 'auto\_envvar\_prefix' option + +4.2.0 +----- + +* Extend pre-wrapped text support to options +* tests: Use Command tests, not Group tests +* tests: Add test for boolean options + +4.1.0 +----- + +* docs: Don't recommend using 'setup.py' +* docs: Indicate support for asyncclick +* asyncclick target +* docs: Remove 'language' configuration +* docs: Add root directory to PATH for docs build +* docs: Remove noise from conf.py +* tox: Enable nitpicky mode for docs builds + +4.0.3 +----- + +* Correct 'get\_command' argument type error + +4.0.2 +----- + +* Correctly ignore empty 'commands' parameter + +4.0.1 +----- + +* docs: Correct typo +* Configure mypy +* Add typing hints +* Pass Context, not self, to MultiCommand +* Add test for truncation + +4.0.0 +----- + +* Add Python 3.10 support, drop Python 3.6 support +* Uncap coverage, remove test-requirements.txt +* Update pre-commit hooks +* Add support for click 8.1.x +* setup: Update URL + 3.1.0 ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/PKG-INFO new/sphinx-click-4.3.0/PKG-INFO --- old/sphinx-click-3.1.0/PKG-INFO 2022-02-02 13:23:20.146028000 +0100 +++ new/sphinx-click-4.3.0/PKG-INFO 2022-07-04 13:00:34.414166000 +0200 @@ -1,8 +1,8 @@ Metadata-Version: 2.1 Name: sphinx-click -Version: 3.1.0 +Version: 4.3.0 Summary: Sphinx extension that automatically documents click applications -Home-page: https://github.com/stephenfin/sphinx-click +Home-page: https://github.com/click-contrib/sphinx-click Author: Stephen Finucane Author-email: step...@that.guru License: MIT License @@ -10,7 +10,6 @@ Project-URL: Documentation, https://sphinx-click.readthedocs.io/en/latest Project-URL: Source Code, https://github.com/click-contrib/sphinx-click Keywords: sphinx -Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers @@ -20,7 +19,7 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only -Requires-Python: >=3.6 +Requires-Python: >=3.7 Description-Content-Type: text/x-rst; charset=UTF-8 License-File: LICENSE @@ -51,12 +50,12 @@ $ pip install sphinx-click -Alternatively, install from source by cloning this repo then running -`setup.py`: +Alternatively, install from source by cloning this repo then running `pip` +locally: .. code-block:: shell - $ python setup.py install + $ pip install . Usage ----- @@ -84,5 +83,3 @@ Detailed information on the various options available is provided in the `documentation <https://sphinx-click.readthedocs.io>`_. - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/README.rst new/sphinx-click-4.3.0/README.rst --- old/sphinx-click-3.1.0/README.rst 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/README.rst 2022-07-04 13:00:24.000000000 +0200 @@ -25,12 +25,12 @@ $ pip install sphinx-click -Alternatively, install from source by cloning this repo then running -`setup.py`: +Alternatively, install from source by cloning this repo then running `pip` +locally: .. code-block:: shell - $ python setup.py install + $ pip install . Usage ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/docs/conf.py new/sphinx-click-4.3.0/docs/conf.py --- old/sphinx-click-3.1.0/docs/conf.py 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/docs/conf.py 2022-07-04 13:00:24.000000000 +0200 @@ -2,20 +2,22 @@ # # sphinx-click documentation build configuration file -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) +import os +import sys + +sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('../examples')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # -needs_sphinx = '1.5' +needs_sphinx = '2.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx_click"] +extensions = ['sphinx_click'] # Add any paths that contain templates here, relative to this directory. templates_path = [] @@ -30,25 +32,18 @@ master_doc = 'index' # General information about the project. -project = u'sphinx-click' -copyright = u'2017, Stephen Finucane' -author = u'Stephen Finucane' +project = 'sphinx-click' +copyright = '2017-, Stephen Finucane' +author = 'Stephen Finucane' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'' +version = '' # The full version, including alpha/beta/rc tags. -release = u'' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None +release = '' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -69,17 +64,6 @@ # html_theme = 'alabaster' -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# 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 = [] - # -- Options for manual page output --------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/docs/index.rst new/sphinx-click-4.3.0/docs/index.rst --- old/sphinx-click-3.1.0/docs/index.rst 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/docs/index.rst 2022-07-04 13:00:24.000000000 +0200 @@ -1,9 +1,9 @@ sphinx-click ============ -:mod:`sphinx-click <sphinx_click>` is a `Sphinx`__ plugin that allows you to -automatically extract documentation from a `click-based`__ application and -include it in your docs. +``sphinx-click`` is a `Sphinx`__ plugin that allows you to automatically +extract documentation from a `click-based`__ application and include it in +your docs. __ http://www.sphinx-doc.org/ __ http://click.pocoo.org/ @@ -19,9 +19,9 @@ .. seealso:: - Module :mod:`click` - This extension assumes you are using :mod:`click` to create your command + Module ``click`` + This extension assumes you are using ``click`` to create your command line application. - Module :mod:`sphinxcontrib.autoprogram` - An equivalent library for use with :mod:`argparse`. + Module ``sphinxcontrib.autoprogram`` + An equivalent library for use with ``argparse``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/docs/installation.rst new/sphinx-click-4.3.0/docs/installation.rst --- old/sphinx-click-3.1.0/docs/installation.rst 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/docs/installation.rst 2022-07-04 13:00:24.000000000 +0200 @@ -7,14 +7,20 @@ $ pip install sphinx-click -Alternatively, install from source by cloning this repo then running -`setup.py`: +Alternatively, install from source by cloning this repo then running `pip` +locally: .. code-block:: shell - $ python setup.py install + $ pip install . + +*sphinx-click* supports both `click`__ and `asyncclick`__. If *asyncclick* is +found, it will be preferred. .. important:: Both the package you're referencing and any dependencies **must be installed**. + +.. __: https://pypi.org/project/click/ +.. __: https://pypi.org/project/asyncclick/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/docs/usage.rst new/sphinx-click-4.3.0/docs/usage.rst --- old/sphinx-click-3.1.0/docs/usage.rst 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/docs/usage.rst 2022-07-04 13:00:24.000000000 +0200 @@ -245,9 +245,9 @@ .. _CommandCollection: https://click.palletsprojects.com/en/7.x/api/#click.CommandCollection .. |program directive| replace:: ``program`` .. _program directive: https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#directive-program -.. |option directive| replace:: ``program`` +.. |option directive| replace:: ``option`` .. _option directive: https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#directive-option -.. |envvar directive| replace:: ``program`` +.. |envvar directive| replace:: ``envvar`` .. _envvar directive: https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#directive-envvar .. |option role| replace:: ``:option:`` .. _option role: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-option diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/releasenotes/notes/add-auto_envvar_prefix-support-a08e68aba792ee26.yaml new/sphinx-click-4.3.0/releasenotes/notes/add-auto_envvar_prefix-support-a08e68aba792ee26.yaml --- old/sphinx-click-3.1.0/releasenotes/notes/add-auto_envvar_prefix-support-a08e68aba792ee26.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-click-4.3.0/releasenotes/notes/add-auto_envvar_prefix-support-a08e68aba792ee26.yaml 2022-07-04 13:00:24.000000000 +0200 @@ -0,0 +1,8 @@ +--- +features: + - | + The ``auto_envvar_prefix`` parameter, which enables automatic environment + variables for all parameters in a click application, is now supported. For + more information on this feature, refer to the `click documentation`__. + + .. __: https://click.palletsprojects.com/en/8.1.x/options/#values-from-environment-variables diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/setup.cfg new/sphinx-click-4.3.0/setup.cfg --- old/sphinx-click-3.1.0/setup.cfg 2022-02-02 13:23:20.146028000 +0100 +++ new/sphinx-click-4.3.0/setup.cfg 2022-07-04 13:00:34.418166000 +0200 @@ -5,7 +5,7 @@ description_content_type = text/x-rst; charset=UTF-8 author = Stephen Finucane author_email = step...@that.guru -url = https://github.com/stephenfin/sphinx-click +url = https://github.com/click-contrib/sphinx-click project_urls = Bug Tracker = https://github.com/click-contrib/sphinx-click/issues Documentation = https://sphinx-click.readthedocs.io/en/latest @@ -21,7 +21,7 @@ Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only -python_requires = >=3.6 +python_requires = >=3.7 keywords = sphinx [files] @@ -32,6 +32,19 @@ max-line-length = 88 ignore = E203,E501,E741,W503 +[mypy] +disallow_untyped_defs = true +disallow_incomplete_defs = true +no_implicit_optional = true +show_column_numbers = true +show_error_context = true +ignore_missing_imports = true +follow_imports = skip +check_untyped_defs = true +warn_unused_ignores = true +warn_return_any = true +strict_optional = false + [egg_info] tag_build = tag_date = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/sphinx_click/ext.py new/sphinx-click-4.3.0/sphinx_click/ext.py --- old/sphinx-click-3.1.0/sphinx_click/ext.py 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/sphinx_click/ext.py 2022-07-04 13:00:24.000000000 +0200 @@ -1,12 +1,18 @@ +import inspect import re import traceback +import typing as ty import warnings -import click +try: + import asyncclick as click +except ImportError: + import click from docutils import nodes from docutils.parsers import rst from docutils.parsers.rst import directives from docutils import statemachine +from sphinx import application from sphinx.util import logging from sphinx.util import nodes as sphinx_nodes @@ -19,25 +25,25 @@ ANSI_ESC_SEQ_RE = re.compile(r'\x1B\[\d+(;\d+){0,2}m', flags=re.MULTILINE) -def _indent(text, level=1): +def _indent(text: str, level: int = 1) -> str: prefix = ' ' * (4 * level) - def prefixed_lines(): + def prefixed_lines() -> ty.Generator[str, None, None]: for line in text.splitlines(True): yield (prefix + line if line.strip() else line) return ''.join(prefixed_lines()) -def _get_usage(ctx): +def _get_usage(ctx: click.Context) -> str: """Alternative, non-prefixed version of 'get_usage'.""" formatter = ctx.make_formatter() pieces = ctx.command.collect_usage_pieces(ctx) formatter.write_usage(ctx.command_path, ' '.join(pieces), prefix='') - return formatter.getvalue().rstrip('\n') + return formatter.getvalue().rstrip('\n') # type: ignore -def _get_help_record(opt): +def _get_help_record(opt: click.Option) -> ty.Tuple[str, str]: """Re-implementation of click.Opt.get_help_record. The variant of 'get_help_record' found in Click makes uses of slashes to @@ -48,14 +54,14 @@ [1] http://www.sphinx-doc.org/en/stable/domains.html#directive-option """ - def _write_opts(opts): + def _write_opts(opts: ty.List[str]) -> str: rv, _ = click.formatting.join_options(opts) if not opt.is_flag and not opt.count: name = opt.name if opt.metavar: name = opt.metavar.lstrip('<[{($').rstrip('>]})$') rv += ' <{}>'.format(name) - return rv + return rv # type: ignore rv = [_write_opts(opt.opts)] if opt.secondary_opts: @@ -100,8 +106,8 @@ return ', '.join(rv), '\n'.join(out) -def _format_help(help_string): - help_string = ANSI_ESC_SEQ_RE.sub('', help_string) +def _format_help(help_string: str) -> ty.Generator[str, None, None]: + help_string = inspect.cleandoc(ANSI_ESC_SEQ_RE.sub('', help_string)) bar_enabled = False for line in statemachine.string2lines( @@ -117,7 +123,7 @@ yield '' -def _format_description(ctx): +def _format_description(ctx: click.Context) -> ty.Generator[str, None, None]: """Format the description for a given `click.Command`. We parse this as reStructuredText, allowing users to embed rich @@ -128,7 +134,7 @@ yield from _format_help(help_string) -def _format_usage(ctx): +def _format_usage(ctx: click.Context) -> ty.Generator[str, None, None]: """Format the usage for a `click.Command`.""" yield '.. code-block:: shell' yield '' @@ -137,20 +143,27 @@ yield '' -def _format_option(opt): +def _format_option(opt: click.Option) -> ty.Generator[str, None, None]: """Format the output for a `click.Option`.""" - opt = _get_help_record(opt) + opt_help = _get_help_record(opt) - yield '.. option:: {}'.format(opt[0]) - if opt[1]: + yield '.. option:: {}'.format(opt_help[0]) + if opt_help[1]: yield '' + bar_enabled = False for line in statemachine.string2lines( - ANSI_ESC_SEQ_RE.sub('', opt[1]), tab_width=4, convert_whitespace=True + ANSI_ESC_SEQ_RE.sub('', opt_help[1]), tab_width=4, convert_whitespace=True ): + if line == '\b': + bar_enabled = True + continue + if line == '': + bar_enabled = False + line = '| ' + line if bar_enabled else line yield _indent(line) -def _format_options(ctx): +def _format_options(ctx: click.Context) -> ty.Generator[str, None, None]: """Format all `click.Option` for a `click.Command`.""" # the hidden attribute is part of click 7.x only hence use of getattr params = [ @@ -165,7 +178,7 @@ yield '' -def _format_argument(arg): +def _format_argument(arg: click.Argument) -> ty.Generator[str, None, None]: """Format the output of a `click.Argument`.""" yield '.. option:: {}'.format(arg.human_readable_name) yield '' @@ -176,7 +189,7 @@ ) -def _format_arguments(ctx): +def _format_arguments(ctx: click.Context) -> ty.Generator[str, None, None]: """Format all `click.Argument` for a `click.Command`.""" params = [x for x in ctx.command.params if isinstance(x, click.Argument)] @@ -186,7 +199,9 @@ yield '' -def _format_envvar(param): +def _format_envvar( + param: ty.Union[click.Option, click.Argument] +) -> ty.Generator[str, None, None]: """Format the envvars of a `click.Option` or `click.Argument`.""" yield '.. envvar:: {}'.format(param.envvar) yield ' :noindex:' @@ -201,9 +216,18 @@ yield _indent('Provide a default for :option:`{}`'.format(param_ref)) -def _format_envvars(ctx): +def _format_envvars(ctx: click.Context) -> ty.Generator[str, None, None]: """Format all envvars for a `click.Command`.""" - params = [x for x in ctx.command.params if getattr(x, 'envvar')] + + auto_envvar_prefix = ctx.auto_envvar_prefix + if auto_envvar_prefix is not None: + params = [] + for param in ctx.command.params: + if not param.envvar: + param.envvar = f"{auto_envvar_prefix}_{param.name.upper()}" + params.append(param) + else: + params = [x for x in ctx.command.params if x.envvar] for param in params: yield '.. _{command_name}-{param_name}-{envvar}:'.format( @@ -217,7 +241,7 @@ yield '' -def _format_subcommand(command): +def _format_subcommand(command: click.Command) -> ty.Generator[str, None, None]: """Format a sub-command of a `click.Command` or `click.Group`.""" yield '.. object:: {}'.format(command.name) @@ -231,7 +255,7 @@ yield _indent(line) -def _format_epilog(ctx): +def _format_epilog(ctx: click.Context) -> ty.Generator[str, None, None]: """Format the epilog for a given `click.Command`. We parse this as reStructuredText, allowing users to embed rich @@ -241,31 +265,37 @@ yield from _format_help(ctx.command.epilog) -def _get_lazyload_commands(multicommand): +def _get_lazyload_commands(ctx: click.Context) -> ty.Dict[str, click.Command]: commands = {} - for command in multicommand.list_commands(multicommand): - commands[command] = multicommand.get_command(multicommand, command) + for command in ctx.command.list_commands(ctx): + commands[command] = ctx.command.get_command(ctx, command) return commands -def _filter_commands(ctx, commands=None): +def _filter_commands( + ctx: click.Context, + commands: ty.Optional[ty.List[str]] = None, +) -> ty.List[click.Command]: """Return list of used commands.""" lookup = getattr(ctx.command, 'commands', {}) if not lookup and isinstance(ctx.command, click.MultiCommand): - lookup = _get_lazyload_commands(ctx.command) + lookup = _get_lazyload_commands(ctx) if commands is None: return sorted(lookup.values(), key=lambda item: item.name) - names = [name.strip() for name in commands.split(',')] - return [lookup[name] for name in names if name in lookup] + return [lookup[command] for command in commands if command in lookup] -def _format_command(ctx, nested, commands=None): +def _format_command( + ctx: click.Context, + nested: str, + commands: ty.Optional[ty.List[str]] = None, +) -> ty.Generator[str, None, None]: """Format the output of `click.Command`.""" if ctx.command.hidden: - return + return None # description @@ -320,26 +350,24 @@ if nested in (NESTED_FULL, NESTED_NONE): return - commands = _filter_commands(ctx, commands) + command_objs = _filter_commands(ctx, commands) - if commands: + if command_objs: yield '.. rubric:: Commands' yield '' - for command in commands: + for command_obj in command_objs: # Don't show hidden subcommands - if command.hidden: + if command_obj.hidden: continue - for line in _format_subcommand(command): + for line in _format_subcommand(command_obj): yield line yield '' -def nested(argument): - values = (NESTED_FULL, NESTED_SHORT, NESTED_NONE) - if not argument: - return None +def nested(argument: ty.Optional[str]) -> ty.Optional[str]: + values = (NESTED_FULL, NESTED_SHORT, NESTED_NONE, None) if argument not in values: raise ValueError( @@ -361,11 +389,8 @@ 'show-nested': directives.flag, } - def _load_module(self, module_path): + def _load_module(self, module_path: str) -> ty.Union[click.Command, click.Group]: """Load the module.""" - # __import__ will fail on unicode, - # so we ensure module path is a string here. - module_path = str(module_path) try: module_name, attr_name = module_path.split(':', 1) @@ -394,16 +419,22 @@ parser = getattr(mod, attr_name) - if not isinstance(parser, click.BaseCommand): + if not isinstance(parser, (click.Command, click.Group)): raise self.error( - '"{}" of type "{}" is not derived from ' + '"{}" of type "{}" is not click.Command or click.Group.' '"click.BaseCommand"'.format(type(parser), module_path) ) return parser def _generate_nodes( - self, name, command, parent, nested, commands=None, semantic_group=False - ): + self, + name: str, + command: click.Command, + parent: ty.Optional[click.Context], + nested: str, + commands: ty.Optional[ty.List[str]] = None, + semantic_group: bool = False, + ) -> ty.List[nodes.section]: """Generate the relevant Sphinx nodes. Format a `click.Group` or `click.Command`. @@ -415,7 +446,7 @@ :param commands: Display only listed commands or skip the section if empty :param semantic_group: Display command as title and description for - CommandCollection. + `click.CommandCollection`. :returns: A list of nested docutil nodes """ ctx = click.Context(command, info_name=name, parent=parent) @@ -473,7 +504,7 @@ return [section] - def run(self): + def run(self) -> ty.Iterable[nodes.section]: self.env = self.state.document.settings.env command = self._load_module(self.arguments[0]) @@ -497,12 +528,16 @@ ) nested = NESTED_FULL if show_nested else NESTED_SHORT - commands = self.options.get('commands') + commands = None + if self.options.get('commands'): + commands = [ + command.strip() for command in self.options.get('commands').split(',') + ] return self._generate_nodes(prog_name, command, None, nested, commands) -def setup(app): +def setup(app: application.Sphinx) -> ty.Dict[str, ty.Any]: app.add_directive('click', ClickDirective) return { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/sphinx_click.egg-info/PKG-INFO new/sphinx-click-4.3.0/sphinx_click.egg-info/PKG-INFO --- old/sphinx-click-3.1.0/sphinx_click.egg-info/PKG-INFO 2022-02-02 13:23:20.000000000 +0100 +++ new/sphinx-click-4.3.0/sphinx_click.egg-info/PKG-INFO 2022-07-04 13:00:34.000000000 +0200 @@ -1,8 +1,8 @@ Metadata-Version: 2.1 Name: sphinx-click -Version: 3.1.0 +Version: 4.3.0 Summary: Sphinx extension that automatically documents click applications -Home-page: https://github.com/stephenfin/sphinx-click +Home-page: https://github.com/click-contrib/sphinx-click Author: Stephen Finucane Author-email: step...@that.guru License: MIT License @@ -10,7 +10,6 @@ Project-URL: Documentation, https://sphinx-click.readthedocs.io/en/latest Project-URL: Source Code, https://github.com/click-contrib/sphinx-click Keywords: sphinx -Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Intended Audience :: Developers @@ -20,7 +19,7 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only -Requires-Python: >=3.6 +Requires-Python: >=3.7 Description-Content-Type: text/x-rst; charset=UTF-8 License-File: LICENSE @@ -51,12 +50,12 @@ $ pip install sphinx-click -Alternatively, install from source by cloning this repo then running -`setup.py`: +Alternatively, install from source by cloning this repo then running `pip` +locally: .. code-block:: shell - $ python setup.py install + $ pip install . Usage ----- @@ -84,5 +83,3 @@ Detailed information on the various options available is provided in the `documentation <https://sphinx-click.readthedocs.io>`_. - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/sphinx_click.egg-info/SOURCES.txt new/sphinx-click-4.3.0/sphinx_click.egg-info/SOURCES.txt --- old/sphinx-click-3.1.0/sphinx_click.egg-info/SOURCES.txt 2022-02-02 13:23:20.000000000 +0100 +++ new/sphinx-click-4.3.0/sphinx_click.egg-info/SOURCES.txt 2022-07-04 13:00:34.000000000 +0200 @@ -8,7 +8,6 @@ requirements.txt setup.cfg setup.py -test-requirements.txt tox.ini .github/workflows/ci.yaml docs/changelog.rst @@ -22,12 +21,14 @@ examples/setup.py examples/commandcollections/__init__.py examples/commandcollections/cli.py +releasenotes/notes/add-auto_envvar_prefix-support-a08e68aba792ee26.yaml sphinx_click/__init__.py sphinx_click/ext.py sphinx_click.egg-info/PKG-INFO sphinx_click.egg-info/SOURCES.txt sphinx_click.egg-info/dependency_links.txt sphinx_click.egg-info/not-zip-safe +sphinx_click.egg-info/pbr.json sphinx_click.egg-info/requires.txt sphinx_click.egg-info/top_level.txt tests/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/sphinx_click.egg-info/pbr.json new/sphinx-click-4.3.0/sphinx_click.egg-info/pbr.json --- old/sphinx-click-3.1.0/sphinx_click.egg-info/pbr.json 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-click-4.3.0/sphinx_click.egg-info/pbr.json 2022-07-04 13:00:34.000000000 +0200 @@ -0,0 +1 @@ +{"git_version": "3ff77a7", "is_release": false} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/test-requirements.txt new/sphinx-click-4.3.0/test-requirements.txt --- old/sphinx-click-3.1.0/test-requirements.txt 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/test-requirements.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -click>=5.0,<8.0 -coverage>4.3,<5.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/tests/test_formatter.py new/sphinx-click-4.3.0/tests/test_formatter.py --- old/sphinx-click-3.1.0/tests/test_formatter.py 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/tests/test_formatter.py 2022-07-04 13:00:24.000000000 +0200 @@ -4,6 +4,8 @@ import click from sphinx_click import ext +CLICK_VERSION = tuple(int(x) for x in click.__version__.split('.')[0:2]) + class CommandTestCase(unittest.TestCase): """Validate basic ``click.Command`` instances.""" @@ -60,6 +62,11 @@ help='A sample option with numeric choices', type=click.Choice([1, 2, 3]), ) + @click.option( + '--flag', + is_flag=True, + help='A boolean flag', + ) @click.argument('ARG', envvar='ARG') def foobar(bar): """A sample command.""" @@ -100,6 +107,10 @@ :options: 1 | 2 | 3 + .. option:: --flag + + A boolean flag + .. rubric:: Arguments .. option:: ARG @@ -345,8 +356,60 @@ '\n'.join(output), ) - def test_no_line_wrapping_epilog(self): - r"""Validate behavior of the \b character in an epilog.""" + @unittest.skipIf( + CLICK_VERSION < (8, 1), 'Click < 8.1.0 stores the modified help string' + ) + def test_no_truncation(self): + r"""Validate behavior when a \f character is present. + + https://click.palletsprojects.com/en/8.1.x/documentation/#truncating-help-texts + """ + + @click.command() + def cli(): + """First paragraph. + + This is a very long second + paragraph and not correctly + wrapped but it will be rewrapped. + \f + + :param click.core.Context ctx: Click context. + """ + pass + + ctx = click.Context(cli, info_name='cli') + output = list(ext._format_command(ctx, nested='short')) + + # note that we have an extra newline because we're using + # docutils.statemachine.string2lines under the hood, which is + # converting the form feed to a newline + self.assertEqual( + textwrap.dedent( + """ + First paragraph. + + This is a very long second + paragraph and not correctly + wrapped but it will be rewrapped. + + + :param click.core.Context ctx: Click context. + + .. program:: cli + .. code-block:: shell + + cli [OPTIONS] + """ + ).lstrip(), + '\n'.join(output), + ) + + def test_no_line_wrapping(self): + r"""Validate behavior when a \b character is present. + + https://click.palletsprojects.com/en/8.1.x/documentation/#preventing-rewrapping + """ @click.command( epilog=""" @@ -361,22 +424,64 @@ that will be rewrapped again. """ ) - def foobar(): - """A sample command.""" + @click.option( + '--param', + help="""An option containing pre-wrapped text. - ctx = click.Context(foobar, info_name='foobar') + \b + This is + a paragraph + without rewrapping. + + And this is a paragraph + that will be rewrapped again. + """, + ) + def cli(): + """A command containing pre-wrapped text. + + \b + This is + a paragraph + without rewrapping. + + And this is a paragraph + that will be rewrapped again. + """ + pass + + ctx = click.Context(cli, info_name='cli') output = list(ext._format_command(ctx, nested='short')) self.assertEqual( textwrap.dedent( """ - A sample command. + A command containing pre-wrapped text. - .. program:: foobar + | This is + | a paragraph + | without rewrapping. + + And this is a paragraph + that will be rewrapped again. + + .. program:: cli .. code-block:: shell - foobar [OPTIONS] + cli [OPTIONS] + .. rubric:: Options + + .. option:: --param <param> + + An option containing pre-wrapped text. + + | This is + | a paragraph + | without rewrapping. + + And this is a paragraph + that will be rewrapped again. An epilog containing pre-wrapped text. @@ -483,50 +588,6 @@ '\n'.join(output), ) - def test_no_line_wrapping(self): - r"""Validate behavior when a \b character is present. - - https://click.palletsprojects.com/en/7.x/documentation/#preventing-rewrapping - """ - - @click.group() - def cli(): - """A sample command group. - - \b - This is - a paragraph - without rewrapping. - - And this is a paragraph - that will be rewrapped again. - """ - pass - - ctx = click.Context(cli, info_name='cli') - output = list(ext._format_command(ctx, nested='short')) - - self.assertEqual( - textwrap.dedent( - """ - A sample command group. - - | This is - | a paragraph - | without rewrapping. - - And this is a paragraph - that will be rewrapped again. - - .. program:: cli - .. code-block:: shell - - cli [OPTIONS] COMMAND [ARGS]... - """ - ).lstrip(), - '\n'.join(output), - ) - class NestedCommandsTestCase(unittest.TestCase): """Validate ``click.Command`` instances inside ``click.Group`` instances.""" @@ -645,7 +706,7 @@ """Validate an empty command group.""" ctx = self._get_ctx() - output = list(ext._format_command(ctx, nested='short', commands='')) + output = list(ext._format_command(ctx, nested='short', commands=[])) self.assertEqual( textwrap.dedent( @@ -665,7 +726,9 @@ """Validate the order of commands.""" ctx = self._get_ctx() - output = list(ext._format_command(ctx, nested='short', commands='world, hello')) + output = list( + ext._format_command(ctx, nested='short', commands=['world', 'hello']) + ) self.assertEqual( textwrap.dedent( @@ -876,4 +939,79 @@ """ ).lstrip(), '\n'.join(output), + ) + + +class AutoEnvvarPrefixTestCase(unittest.TestCase): + """Validate ``click auto_envvar_prefix``-setup instances.""" + + def test_basics(self): + """Validate a click application with ``auto_envvar_prefix`` option enabled.""" + + @click.command( + context_settings={"auto_envvar_prefix": "PREFIX"}, + ) + @click.option('--param', help='Help for param') + @click.option('--other-param', help='Help for other-param') + @click.option( + '--param-with-explicit-envvar', + help='Help for param-with-explicit-envvar', + envvar="EXPLICIT_ENVVAR", + ) + def cli_with_auto_envvars(): + """A simple CLI with auto-env vars .""" + + cli = cli_with_auto_envvars + ctx = click.Context(cli, info_name='cli', auto_envvar_prefix="PREFIX") + output = list(ext._format_command(ctx, nested='full')) + + self.assertEqual( + textwrap.dedent( + """ + A simple CLI with auto-env vars . + + .. program:: cli + .. code-block:: shell + + cli [OPTIONS] + + .. rubric:: Options + + .. option:: --param <param> + + Help for param + + .. option:: --other-param <other_param> + + Help for other-param + + .. option:: --param-with-explicit-envvar <param_with_explicit_envvar> + + Help for param-with-explicit-envvar + + .. rubric:: Environment variables + + .. _cli-param-PREFIX_PARAM: + + .. envvar:: PREFIX_PARAM + :noindex: + + Provide a default for :option:`--param` + + .. _cli-other_param-PREFIX_OTHER_PARAM: + + .. envvar:: PREFIX_OTHER_PARAM + :noindex: + + Provide a default for :option:`--other-param` + + .. _cli-param_with_explicit_envvar-EXPLICIT_ENVVAR: + + .. envvar:: EXPLICIT_ENVVAR + :noindex: + + Provide a default for :option:`--param-with-explicit-envvar` + """ + ).lstrip(), + '\n'.join(output), ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-click-3.1.0/tox.ini new/sphinx-click-4.3.0/tox.ini --- old/sphinx-click-3.1.0/tox.ini 2022-02-02 13:23:10.000000000 +0100 +++ new/sphinx-click-4.3.0/tox.ini 2022-07-04 13:00:24.000000000 +0200 @@ -1,12 +1,13 @@ [tox] minversion = 2.0 -envlist = py{36,37,38,39}-click{7,8},style,docs +envlist = py{37,38,39}-click{7,8,8-async},py{310}-click{8,8-async},style,docs [testenv] deps = - coverage>4.3,<5.0 + coverage click7: click>=7.0,<8.0 click8: click>=8.0,<9.0 + click8-async: asyncclick>=8.0,<9.0 commands = coverage run --source={toxinidir}/sphinx_click -m unittest {posargs} coverage report @@ -24,10 +25,16 @@ commands = flake8 {toxinidir}/sphinx_click/ -[coverage:run] -branch = True +[testenv:mypy] +deps = + mypy + types-docutils +commands = + mypy sphinx_click [testenv:docs] commands = - pip install -e {toxinidir}/examples/ - sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html + sphinx-build -Wn -b html -d docs/_build/doctrees docs docs/_build/html + +[coverage:run] +branch = True