pax_global_header00006660000000000000000000000064147054441650014524gustar00rootroot0000000000000052 comment=f81147eff409d6de19564752c1e6182362b23e04 python-autodocsumm-0.2.14/000077500000000000000000000000001470544416500154675ustar00rootroot00000000000000python-autodocsumm-0.2.14/.gitattributes000066400000000000000000000000451470544416500203610ustar00rootroot00000000000000autodocsumm/_version.py export-subst python-autodocsumm-0.2.14/.github/000077500000000000000000000000001470544416500170275ustar00rootroot00000000000000python-autodocsumm-0.2.14/.github/workflows/000077500000000000000000000000001470544416500210645ustar00rootroot00000000000000python-autodocsumm-0.2.14/.github/workflows/build.yml000066400000000000000000000021731470544416500227110ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Tests on: workflow_call: inputs: python-version: required: true type: string extra-requirements: required: false type: string jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ inputs.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" - name: Install dependencies run: | python -m pip install --upgrade pip pip install pytest pytest-cov codecov beautifulsoup4 ${{ inputs.extra-requirements }} -e . - name: Test with pytest run: | pytest --cov=autodocsumm --cov-report=xml tests - name: Upload codecov env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: | codecov python-autodocsumm-0.2.14/.github/workflows/python-app.yml000066400000000000000000000043651470544416500237160ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Tests on: push: pull_request: jobs: build-sphinx-80plus: name: Build strategy: fail-fast: false matrix: python-version: [ "3.10", "3.11", "3.12" ] sphinx-version: [ "8.0.*", "8.*" # 8.0.x and latest ] uses: ./.github/workflows/build.yml with: python-version: ${{ matrix.python-version }} extra-requirements: '\ "sphinx==${{ matrix.sphinx-version }}"' build-legacy-sphinx-45plus: name: Build strategy: fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] sphinx-version: [ "7.0.*", # possible range: 7.0.0 - 7.4.7 "6.0.*", # possible range: 6.0.0 - 6.2.1 "5.0.*", # possible range: 5.0.0 - 5.3.0 "4.5.*" # possible range: 4.5.0, also latest that supports py3.8 ] include: - python-version: "3.9" sphinx-version: "7.2.*" # latest version that supports py3.9 uses: ./.github/workflows/build.yml with: python-version: ${{ matrix.python-version }} extra-requirements: '\ "sphinx==${{ matrix.sphinx-version }}" "sphinxcontrib-applehelp<1.0.8" "sphinxcontrib-devhelp<1.0.6" "sphinxcontrib-htmlhelp<2.0.5" "sphinxcontrib-jsmath<1.0.1" "sphinxcontrib-qthelp<1.0.7" "sphinxcontrib-serializinghtml<1.1.10"' build-legacy-sphinx-40plus: name: Build strategy: fail-fast: false matrix: python-version: [ "3.8", "3.9" ] sphinx-version: [ "4.0.*" # possible range: 4.0.0 - 4.4.0 ] uses: ./.github/workflows/build.yml with: python-version: ${{ matrix.python-version }} extra-requirements: '\ "sphinx==${{ matrix.sphinx-version }}" "sphinxcontrib-applehelp<1.0.8" "sphinxcontrib-devhelp<1.0.6" "sphinxcontrib-htmlhelp<2.0.5" "sphinxcontrib-jsmath<1.0.1" "sphinxcontrib-qthelp<1.0.7" "sphinxcontrib-serializinghtml<1.1.10"' python-autodocsumm-0.2.14/.gitignore000066400000000000000000000015021470544416500174550ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *,cover # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ docs/index.doctree # PyBuilder target/ # Spyder project .spyderproject # Example ipython notebook checkpoints *.ipynb_checkpoints/ .mypy_cache venv/ python-autodocsumm-0.2.14/.readthedocs.yml000066400000000000000000000004051470544416500205540ustar00rootroot00000000000000version: 2 # Set the OS, Python version and other tools you might need build: os: ubuntu-22.04 tools: python: "3.11" sphinx: configuration: docs/conf.py python: install: - method: pip path: . - requirements: docs/requirements.txt python-autodocsumm-0.2.14/LICENSE000066400000000000000000000261351470544416500165030ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. python-autodocsumm-0.2.14/MANIFEST.in000066400000000000000000000000431470544416500172220ustar00rootroot00000000000000include README.rst include LICENSE python-autodocsumm-0.2.14/README.rst000066400000000000000000000102061470544416500171550ustar00rootroot00000000000000============================================== Extending your autodoc API docs with a summary ============================================== .. start-badges .. list-table:: :stub-columns: 1 :widths: 10 90 * - docs - |docs| * - tests - |github-action| |codecov| * - package - |version| |supported-versions| |supported-implementations| .. |docs| image:: http://readthedocs.org/projects/autodocsumm/badge/?version=latest :alt: Documentation Status :target: http://autodocsumm.readthedocs.io/en/latest/?badge=latest .. |github-action| image:: https://github.com/Chilipp/autodocsumm/workflows/Tests/badge.svg :alt: Tests :target: https://github.com/Chilipp/autodocsumm/actions?query=workflow%3A%22Tests%22 .. |codecov| image:: https://codecov.io/gh/Chilipp/autodocsumm/branch/master/graph/badge.svg?token=I9wlZyhI4Y :alt: Codecov :target: https://codecov.io/gh/Chilipp/autodocsumm .. |version| image:: https://img.shields.io/pypi/v/autodocsumm.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/autodocsumm .. |supported-versions| image:: https://img.shields.io/pypi/pyversions/autodocsumm.svg?style=flat :alt: Supported versions :target: https://pypi.python.org/pypi/autodocsumm .. |supported-implementations| image:: https://img.shields.io/pypi/implementation/autodocsumm.svg?style=flat :alt: Supported implementations :target: https://pypi.python.org/pypi/autodocsumm .. end-badges Welcome! This sphinx extension provides some useful extensions to the Sphinxs autodoc_ extension. Those are 1. It creates a *Table of Contents* in the style of the autosummary_ extension with methods, classes, functions and attributes 2. As you can include the ``__init__`` method documentation for via the autoclass_content_ configuration value, we provide the *autodata_content* configuration value to include the documentation from the ``__call__`` method 3. You can exclude the string representation of specific objects. E.g. if you have a large dictionary using the *not_document_data* configuration value. See the `Documentation on Readthedocs`_ for more details. .. _autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html .. _autoclass_content: http://www.sphinx-doc.org/en/stable/ext/autodoc.html#confval-autoclass_content .. _autosummary: http://www.sphinx-doc.org/en/stable/ext/autosummary.html .. _Documentation on Readthedocs: http://autodocsumm.readthedocs.io/en/latest/ Installation ============ Simply install it via ``pip``:: $ pip install autodocsumm Local development ^^^^^^^^^^^^^^^^^ Use ``pip`` on the `source on GitHub`_:: $ pip install . .. _source on GitHub: https://github.com/Chilipp/autodocsumm Requirements ============ The package only requires Sphinx_ to be installed. It has been tested for versions higher than 1.3. .. _Sphinx: http://www.sphinx-doc.org/en/master Quickstart ========== In order to activate the autodocsumm extension, you have to list it in your ``conf.py``: .. code-block:: python extensions = [ 'sphinx.ext.autodoc', ..., 'autodocsumm', ] Once this is done, you can use the ``:autosummary:`` option for autodoc directives to generate a table at the top, e.g.: .. code-block:: rst .. automodule:: my.awesome.module :autosummary: Optionally, you can make autodocsumm active by default for all autodoc directives by adding in ``conf.py``: .. code-block:: python autodoc_default_options = { 'autosummary': True, } Disclaimer ========== Copyright 2016-2019, Philipp S. Sommer Copyright 2020-2021, Helmholtz-Zentrum Hereon Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. python-autodocsumm-0.2.14/autodocsumm/000077500000000000000000000000001470544416500200275ustar00rootroot00000000000000python-autodocsumm-0.2.14/autodocsumm/__init__.py000077500000000000000000000676431470544416500221630ustar00rootroot00000000000000"""Sphinx extension that defines new auto documenters with autosummary. The :class:`AutoSummModuleDocumenter` and :class:`AutoSummClassDocumenter` classes defined here enable an autosummary-style listing of the corresponding members. This extension gives also the possibility to choose which data shall be shown and to include the docstring of the ``'__call__'`` attribute. **Disclaimer** Copyright 2016-2019, Philipp S. Sommer Copyright 2020-2021, Helmholtz-Zentrum Hereon Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ __author__ = "Philipp S. Sommer" __copyright__ = ( "2016 - 2019, Philipp S. Sommer\n" "2020 - 2021, Helmholtz-Zentrum Hereon" ) __credits__ = ["Philipp S. Sommer"] __license__ = "Apache-2.0" __maintainer__ = "Philipp S. Sommer" __email__ = "philipp.sommer@hereon.de" __status__ = "Production" from itertools import chain from typing import TYPE_CHECKING from sphinx.util import logging import re from docutils import nodes import sphinx from sphinx.util.docutils import SphinxDirective from sphinx.ext.autodoc import ( ClassDocumenter, ModuleDocumenter, ALL, PycodeError, ModuleAnalyzer, AttributeDocumenter, DataDocumenter, Options, ExceptionDocumenter, Documenter, prepare_docstring) import sphinx.ext.autodoc as ad signature = Signature = None from sphinx.ext.autodoc.directive import ( AutodocDirective, AUTODOC_DEFAULT_OPTIONS, process_documenter_options, DocumenterBridge ) try: from sphinx.util.inspect import signature, stringify_signature except ImportError: from sphinx.ext.autodoc import Signature sphinx_version = list(map(float, re.findall(r'\d+', sphinx.__version__)[:3])) try: from sphinx.util import force_decode except ImportError: # force_decode has been removed with sphinx 4.0 def force_decode(string: str, encoding: str) -> str: return string from . import _version __version__ = _version.get_versions()['version'] if TYPE_CHECKING: # pragma: no cover DOCUMENTER_MIXIN_BASE = Documenter else: DOCUMENTER_MIXIN_BASE = object logger = logging.getLogger(__name__) #: Options of the :class:`sphinx.ext.autodoc.ModuleDocumenter` that have an #: effect on the selection of members for the documentation member_options = { 'members', 'undoc-members', 'inherited-members', 'exclude-members', 'private-members', 'special-members', 'imported-members', 'ignore-module-all'} if signature is not None: # sphinx >= 2.4.0 def process_signature(obj): sig = signature(obj) return stringify_signature(sig) elif Signature is not None: # sphinx >= 1.7 def process_signature(obj): try: args = Signature(obj).format_args() except TypeError: return None else: args = args.replace('\\', '\\\\') return args def list_option(option): """Transform a string to a list by splitting at ;;.""" return [s.strip() for s in option.split(";;")] def bool_option(*args): return "True" def _get_arg(param, pos, default, *args, **kwargs): if param in kwargs: return kwargs[param] elif len(args) > pos: return args[pos] else: return default class AutosummaryDocumenter(DOCUMENTER_MIXIN_BASE): """Abstract class for for extending Documenter methods This classed is used as a base class for Documenters in order to provide the necessary methods for generating the autosummary.""" #: List of functions that may filter the members filter_funcs = [] #: Grouper functions grouper_funcs = [] member_sections: dict def __init__(self): raise NotImplementedError def get_grouped_documenters(self, all_members=False): """Method to return the member documenters This method is somewhat like a combination of the :meth:`sphinx.ext.autodoc.ModuleDocumenter.generate` method and the :meth:`sphinx.ext.autodoc.ModuleDocumenter.document_members` method. Hence it initializes this instance by importing the object, etc. and it finds the documenters to use for the autosummary option in the same style as the document_members does it. Returns ------- dict dictionary whose keys are determined by the :attr:`member_sections` dictionary and whose values are lists of tuples. Each tuple consists of a documenter and a boolean to identify whether a module check should be made describes an attribute or not. Notes ----- If a :class:`sphinx.ext.autodoc.Documenter.member_order` value is not in the :attr:`member_sections` dictionary, it will be put into an additional `Miscellaneous` section.""" use_sections = self.options.autosummary_sections self.parse_name() self.import_object() # If there is no real module defined, figure out which to use. # The real module is used in the module analyzer to look up the module # where the attribute documentation would actually be found in. # This is used for situations where you have a module that collects the # functions and classes of internal submodules. self.real_modname = None or self.get_real_modname() # try to also get a source code analyzer for attribute docs if sphinx_version < [4, 0]: record_dependencies = self.directive.filename_set else: record_dependencies = self.directive.record_dependencies try: self.analyzer = ModuleAnalyzer.for_module(self.real_modname) # parse right now, to get PycodeErrors on parsing (results will # be cached anyway) self.analyzer.find_attr_docs() except PycodeError as err: logger.debug('[autodocsumm] module analyzer failed: %s', err) # no source file -- e.g. for builtin and C modules self.analyzer = None # at least add the module.__file__ as a dependency if hasattr(self.module, '__file__') and self.module.__file__: record_dependencies.add(self.module.__file__) else: record_dependencies.add(self.analyzer.srcname) self.env.temp_data['autodoc:module'] = self.modname if self.objpath: self.env.temp_data['autodoc:class'] = self.objpath[0] if not self.options.autosummary_force_inline: docstring = self.get_doc() or [] autodocsumm_directive = '.. auto%ssumm::' % self.objtype for s in chain.from_iterable(docstring): if autodocsumm_directive in s: return {} # set the members from the autosummary member options options_save = {} for option in member_options.intersection(self.option_spec): autopt = 'autosummary-' + option if getattr(self.options, autopt): options_save[option] = getattr(self.options, option) self.options[option] = getattr(self.options, autopt) want_all = all_members or self.options.inherited_members or \ self.options.members is ALL # find out which members are documentable members_check_module, members = self.get_object_members(want_all) # remove members given by exclude-members if self.options.exclude_members: try: members = [ member for member in members if member.__name__ not in self.options.exclude_members ] except AttributeError: # Sphinx<3.4.0 members = [ (membername, member) for (membername, member) in members if membername not in self.options.exclude_members ] # document non-skipped members memberdocumenters = [] registry = self.env.app.registry.documenters for (mname, member, isattr) in self.filter_members(members, want_all): classes = [cls for cls in registry.values() if cls.can_document_member(member, mname, isattr, self)] if not classes: # don't know how to document this member continue # prefer the documenter with the highest priority classes.sort(key=lambda cls: cls.priority) # give explicitly separated module name, so that members # of inner classes can be documented full_mname = self.modname + '::' + \ '.'.join(self.objpath + [mname]) documenter = classes[-1](self.directive, full_mname, self.indent) memberdocumenters.append((documenter, members_check_module and not isattr)) member_order = ( self.options.member_order or self.env.config.autodoc_member_order ) try: memberdocumenters = self.sort_members( memberdocumenters, member_order ) except AttributeError: # sphinx<3.0 pass documenters = {} for e in memberdocumenters: section = self.member_sections.get( e[0].member_order, 'Miscellaneous') if self.env.app: e[0].parse_name() e[0].import_object() if members_check_module and not e[0].check_module(): continue user_section = self.env.app.emit_firstresult( 'autodocsumm-grouper', self.objtype, e[0].object_name, e[0].object, section, self.object) section = user_section or section if not use_sections or section in use_sections: documenters.setdefault(section, []).append(e) self.options.update(options_save) sort_option = self.env.config.autodocsumm_section_sorter if sort_option is True: return {k: documenters[k] for k in sorted(documenters)} elif callable(sort_option): return {k: documenters[k] for k in sorted(documenters, key=sort_option)} else: return documenters def add_autosummary(self, relative_ref_paths=False): """Add the autosammary table of this documenter. Parameters ========== relative_ref_paths: bool Use paths relative to the current module instead of absolute import paths for each object """ if ( self.options.get("autosummary") and not self.options.get("no-autosummary") ): grouped_documenters = self.get_grouped_documenters() sourcename = self.get_sourcename() for section, documenters in grouped_documenters.items(): if not self.options.autosummary_no_titles: self.add_line('**%s:**' % section, sourcename) self.add_line('', sourcename) self.add_line('.. autosummary::', sourcename) if self.options.autosummary_nosignatures: self.add_line(' :nosignatures:', sourcename) self.add_line('', sourcename) indent = ' ' for (documenter, _) in documenters: obj_ref_path = documenter.fullname if relative_ref_paths: modname = self.modname + "." if documenter.fullname.startswith(modname): obj_ref_path = documenter.fullname[len(modname):] self.add_line(indent + '~' + obj_ref_path, sourcename) self.add_line('', sourcename) class AutoSummModuleDocumenter(ModuleDocumenter, AutosummaryDocumenter): """Module documentor with autosummary tables of its members. This class has the same functionality as the base :class:`sphinx.ext.autodoc.ModuleDocumenter` class but with an additional `autosummary`. It's priority is slightly higher than the one of the ModuleDocumenter. """ #: slightly higher priority than #: :class:`sphinx.ext.autodoc.ModuleDocumenter` priority = ModuleDocumenter.priority + 0.1 # type: ignore[assignment] #: original option_spec from :class:`sphinx.ext.autodoc.ModuleDocumenter` #: but with additional autosummary boolean option option_spec = ModuleDocumenter.option_spec.copy() option_spec['autosummary'] = bool_option option_spec['autosummary-no-nesting'] = bool_option option_spec['autosummary-sections'] = list_option option_spec['autosummary-no-titles'] = bool_option option_spec['autosummary-force-inline'] = bool_option option_spec['autosummary-nosignatures'] = bool_option #: Add options for members for the autosummary for _option in member_options.intersection(option_spec): option_spec['autosummary-' + _option] = option_spec[_option] del _option member_sections = { ad.ClassDocumenter.member_order: 'Classes', ad.ExceptionDocumenter.member_order: 'Exceptions', ad.FunctionDocumenter.member_order: 'Functions', ad.DataDocumenter.member_order: 'Data', } """:class:`dict` that includes the autosummary sections This dictionary defines the sections for the autosummmary option. The values correspond to the :attr:`sphinx.ext.autodoc.Documenter.member_order` attribute that shall be used for each section.""" def add_content(self, *args, **kwargs): super().add_content(*args, **kwargs) self.add_autosummary(relative_ref_paths=True) if self.options.get("autosummary-no-nesting"): self.options["no-autosummary"] = "True" class AutoSummClassDocumenter(ClassDocumenter, AutosummaryDocumenter): """Class documentor with autosummary tables for its members. This class has the same functionality as the base :class:`sphinx.ext.autodoc.ClassDocumenter` class but with an additional `autosummary` option to provide the ability to provide a summary of all methods and attributes. It's priority is slightly higher than the one of the ClassDocumenter """ #: slightly higher priority than #: :class:`sphinx.ext.autodoc.ClassDocumenter` priority = ClassDocumenter.priority + 0.1 # type: ignore[assignment] #: original option_spec from :class:`sphinx.ext.autodoc.ClassDocumenter` #: but with additional autosummary boolean option option_spec = ClassDocumenter.option_spec.copy() option_spec['autosummary'] = bool_option option_spec['autosummary-no-nesting'] = bool_option option_spec['autosummary-sections'] = list_option option_spec['autosummary-no-titles'] = bool_option option_spec['autosummary-force-inline'] = bool_option option_spec['autosummary-nosignatures'] = bool_option #: Add options for members for the autosummary for _option in member_options.intersection(option_spec): option_spec['autosummary-' + _option] = option_spec[_option] del _option member_sections = { ad.ClassDocumenter.member_order: 'Classes', ad.MethodDocumenter.member_order: 'Methods', ad.AttributeDocumenter.member_order: 'Attributes', } """:class:`dict` that includes the autosummary sections This dictionary defines the sections for the autosummmary option. The values correspond to the :attr:`sphinx.ext.autodoc.Documenter.member_order` attribute that shall be used for each section.""" def add_content(self, *args, **kwargs): super().add_content(*args, **kwargs) # If the class is already documented under another name, Sphinx # documents it as data/attribute. In this case, we do not want to # generate an autosummary of the class for the attribute (see #69). if not self.doc_as_attr: self.add_autosummary(relative_ref_paths=True) class AutoSummExceptionDocumenter(ExceptionDocumenter, AutosummaryDocumenter): """Exception Documenter with autosummary tables for its members. This class has the same functionality as the base :class:`sphinx.ext.autodoc.ExceptionDocumenter` class but with an additional `autosummary` option to provide the ability to provide a summary of all methods and attributes. It's priority is slightly higher than the one of the ExceptionDocumenter """ #: slightly higher priority than #: :class:`sphinx.ext.autodoc.ExceptionDocumenter` priority = ExceptionDocumenter.priority + 0.1 # type: ignore[assignment] #: original option_spec from #: :class:`sphinx.ext.autodoc.ExceptionDocumenter` but with additional #: autosummary boolean option option_spec = ExceptionDocumenter.option_spec.copy() option_spec['autosummary'] = bool_option option_spec['autosummary-no-nesting'] = bool_option option_spec['autosummary-sections'] = list_option option_spec['autosummary-no-titles'] = bool_option option_spec['autosummary-force-inline'] = bool_option option_spec['autosummary-nosignatures'] = bool_option #: Add options for members for the autosummary for _option in member_options.intersection(option_spec): option_spec['autosummary-' + _option] = option_spec[_option] del _option member_sections = { ad.ExceptionDocumenter.member_order: 'Classes', ad.MethodDocumenter.member_order: 'Methods', ad.AttributeDocumenter.member_order: 'Attributes', } """:class:`dict` that includes the autosummary sections This dictionary defines the sections for the autosummmary option. The values correspond to the :attr:`sphinx.ext.autodoc.Documenter.member_order` attribute that shall be used for each section.""" def add_content(self, *args, **kwargs): super().add_content(*args, **kwargs) # If the class is already documented under another name, Sphinx # documents it as data/attribute. In this case, we do not want to # generate an autosummary of the class for the attribute (see #69). if not self.doc_as_attr: self.add_autosummary(relative_ref_paths=True) class CallableDataDocumenter(DataDocumenter): """:class:`sphinx.ext.autodoc.DataDocumenter` that uses the __call__ attr """ #: slightly higher priority than #: :class:`sphinx.ext.autodoc.DataDocumenter` priority = DataDocumenter.priority + 0.1 # type: ignore[assignment] def format_args(self): # for classes, the relevant signature is the __init__ method's callmeth = self.get_attr(self.object, '__call__', None) if callmeth is None: return None return process_signature(callmeth) def get_doc(self, *args, **kwargs): """Reimplemented to include data from the call method""" content = self.env.config.autodata_content if content not in ('both', 'call') or not self.get_attr( self.get_attr(self.object, '__call__', None), '__doc__'): return super(CallableDataDocumenter, self).get_doc( *args, **kwargs ) # for classes, what the "docstring" is can be controlled via a # config value; the default is both docstrings docstrings = [] if content != 'call': docstring = self.get_attr(self.object, '__doc__', None) docstrings = [docstring + '\n'] if docstring else [] calldocstring = self.get_attr( self.get_attr(self.object, '__call__', None), '__doc__') if docstrings: docstrings[0] += calldocstring else: docstrings.append(calldocstring + '\n') doc = [] for docstring in docstrings: encoding = _get_arg("encoding", 0, None, *args, **kwargs) ignore = _get_arg("ignore", 1, 1, *args, **kwargs) if not isinstance(docstring, str): docstring = force_decode(docstring, encoding) doc.append(prepare_docstring(docstring, ignore)) return doc class CallableAttributeDocumenter(AttributeDocumenter): """:class:`sphinx.ext.autodoc.AttributeDocumenter` that uses the __call__ attr """ #: slightly higher priority than #: :class:`sphinx.ext.autodoc.AttributeDocumenter` priority = AttributeDocumenter.priority + 0.1 # type: ignore[assignment] def format_args(self): # for classes, the relevant signature is the __init__ method's callmeth = self.get_attr(self.object, '__call__', None) if callmeth is None: return None return process_signature(callmeth) def get_doc(self, *args, **kwargs): """Reimplemented to include data from the call method""" content = self.env.config.autodata_content if content not in ('both', 'call') or not self.get_attr( self.get_attr(self.object, '__call__', None), '__doc__'): return super(CallableAttributeDocumenter, self).get_doc( *args, **kwargs ) # for classes, what the "docstring" is can be controlled via a # config value; the default is both docstrings docstrings = [] if content != 'call': docstring = self.get_attr(self.object, '__doc__', None) docstrings = [docstring + '\n'] if docstring else [] calldocstring = self.get_attr( self.get_attr(self.object, '__call__', None), '__doc__') if docstrings: docstrings[0] += calldocstring else: docstrings.append(calldocstring + '\n') doc = [] if sphinx_version < [4, 0]: encoding = _get_arg("encoding", 0, None, *args, **kwargs) ignore = _get_arg("ignore", 1, 1, *args, **kwargs) for docstring in docstrings: if not isinstance(docstring, str): docstring = force_decode(docstring, encoding) doc.append(prepare_docstring(docstring, ignore)) else: for docstring in docstrings: doc.append(prepare_docstring(docstring)) return doc def dont_document_data(config, fullname): """Check whether the given object should be documented Parameters ---------- config: sphinx.Options The configuration fullname: str The name of the object Returns ------- bool Whether the data of `fullname` should be excluded or not""" if config.document_data is True: document_data = [re.compile('.*')] else: document_data = config.document_data if config.not_document_data is True: not_document_data = [re.compile('.*')] else: not_document_data = config.not_document_data return ( # data should not be documented (any(re.match(p, fullname) for p in not_document_data)) or # or data is not included in what should be documented (not any(re.match(p, fullname) for p in document_data))) class NoDataDataDocumenter(CallableDataDocumenter): """DataDocumenter that prevents the displaying of large data""" #: slightly higher priority as the one of the CallableDataDocumenter priority = CallableDataDocumenter.priority + 0.1 # type: ignore[assignment] def __init__(self, *args, **kwargs): super(NoDataDataDocumenter, self).__init__(*args, **kwargs) fullname = '.'.join(self.name.rsplit('::', 1)) if hasattr(self.env, 'config') and dont_document_data( self.env.config, fullname): self.options = Options(self.options) self.options.annotation = ' ' class NoDataAttributeDocumenter(CallableAttributeDocumenter): """AttributeDocumenter that prevents the displaying of large data""" #: slightly higher priority as the one of the CallableAttributeDocumenter priority = CallableAttributeDocumenter.priority + 0.1 # type: ignore[assignment] def __init__(self, *args, **kwargs): super(NoDataAttributeDocumenter, self).__init__(*args, **kwargs) fullname = '.'.join(self.name.rsplit('::', 1)) if hasattr(self.env, 'config') and dont_document_data( self.env.config, fullname): self.options = Options(self.options) self.options.annotation = ' ' class AutoDocSummDirective(SphinxDirective): """A directive to generate an autosummary. Usage:: .. autoclasssumm:: .. automodsumm:: .. autoexceptionsumm:: The directive additionally supports all options of the ``autoclass``, ``automod``, or ``autoexception`` directive respectively. Sections can be a list of section titles to be included. If ommitted, all sections are used. """ has_content = False option_spec = AutodocDirective.option_spec required_arguments = 1 optional_arguments = 0 def run(self): reporter = self.state.document.reporter try: _, lineno = reporter.get_source_and_line(self.lineno) except AttributeError: _, lineno = (None, None) # look up target Documenter objtype = self.name[4:-4] # strip prefix (auto-) and suffix (-summ). doccls = self.env.app.registry.documenters[objtype] self.options['autosummary-force-inline'] = "True" self.options['autosummary'] = "True" if 'no-members' not in self.options: self.options['members'] = "" # process the options with the selected documenter's option_spec try: documenter_options = process_documenter_options(doccls, self.config, self.options) except (KeyError, ValueError, TypeError) as exc: # an option is either unknown or has a wrong type logger.error( 'An option to %s is either unknown or has an invalid ' 'value: %s', self.name, exc, location=(self.env.docname, lineno)) return [] # generate the output params = DocumenterBridge(self.env, reporter, documenter_options, lineno, self.state) documenter = doccls(params, self.arguments[0]) documenter.add_autosummary() node = nodes.paragraph() node.document = self.state.document self.state.nested_parse(params.result, 0, node) return node.children def setup(app): """setup function for using this module as a sphinx extension""" app.setup_extension('sphinx.ext.autosummary') app.setup_extension('sphinx.ext.autodoc') app.add_directive('autoclasssumm', AutoDocSummDirective) app.add_directive('autoexceptionsumm', AutoDocSummDirective) app.add_directive('automodulesumm', AutoDocSummDirective) AUTODOC_DEFAULT_OPTIONS.extend( [option for option in AutoSummModuleDocumenter.option_spec if option not in AUTODOC_DEFAULT_OPTIONS]) AUTODOC_DEFAULT_OPTIONS.extend( [option for option in AutoSummClassDocumenter.option_spec if option not in AUTODOC_DEFAULT_OPTIONS]) # make sure to allow inheritance when registering new documenters registry = app.registry.documenters for cls in [AutoSummClassDocumenter, AutoSummModuleDocumenter, CallableAttributeDocumenter, NoDataDataDocumenter, NoDataAttributeDocumenter, AutoSummExceptionDocumenter]: if not issubclass(registry.get(cls.objtype), cls): app.add_autodocumenter(cls, override=True) # group event app.add_event('autodocsumm-grouper') # config value app.add_config_value('autodata_content', 'class', True) app.add_config_value('document_data', True, True) app.add_config_value('not_document_data', [], True) app.add_config_value('autodocsumm_section_sorter', None, True) return {'version': sphinx.__display_version__, 'parallel_read_safe': True} python-autodocsumm-0.2.14/autodocsumm/_version.py000066400000000000000000000562161470544416500222370ustar00rootroot00000000000000 # This file helps to compute a version number in source trees obtained from # git-archive tarball (such as those provided by githubs download-from-tag # feature). Distribution tarballs (built by setup.py sdist) and build # directories (produced by setup.py build) will contain a much shorter file # that just contains the computed version number. # This file is released into the public domain. # Generated by versioneer-0.28 # https://github.com/python-versioneer/python-versioneer """Git implementation of _version.py.""" import errno import os import re import subprocess import sys from typing import Callable, Dict import functools def get_keywords(): """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. # setup.py/versioneer.py will grep for the variable names, so they must # each be defined on a line of their own. _version.py will just call # get_keywords(). git_refnames = " (grafted, HEAD, tag: v0.2.14)" git_full = "f81147eff409d6de19564752c1e6182362b23e04" git_date = "2024-10-21 14:26:29 +0200" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords class VersioneerConfig: """Container for Versioneer configuration parameters.""" def get_config(): """Create, populate and return the VersioneerConfig() object.""" # these strings are filled in when 'setup.py versioneer' creates # _version.py cfg = VersioneerConfig() cfg.VCS = "git" cfg.style = "pep440" cfg.tag_prefix = "v" cfg.parentdir_prefix = "autodocsumm-" cfg.versionfile_source = "autodocsumm/_version.py" cfg.verbose = False return cfg class NotThisMethod(Exception): """Exception raised if a method is not valid for the current scenario.""" LONG_VERSION_PY: Dict[str, str] = {} HANDLERS: Dict[str, Dict[str, Callable]] = {} def register_vcs_handler(vcs, method): # decorator """Create decorator to mark a method as the handler of a VCS.""" def decorate(f): """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} HANDLERS[vcs][method] = f return f return decorate def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): """Call the given command(s).""" assert isinstance(commands, list) process = None popen_kwargs = {} if sys.platform == "win32": # This hides the console window if pythonw.exe is used startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW popen_kwargs["startupinfo"] = startupinfo for command in commands: try: dispcmd = str([command] + args) # remember shell=False, so use git.cmd on windows, not just git process = subprocess.Popen([command] + args, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=(subprocess.PIPE if hide_stderr else None), **popen_kwargs) break except OSError: e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: print("unable to run %s" % dispcmd) print(e) return None, None else: if verbose: print("unable to find command, tried %s" % (commands,)) return None, None stdout = process.communicate()[0].strip().decode() if process.returncode != 0: if verbose: print("unable to run %s (error)" % dispcmd) print("stdout was %s" % stdout) return None, process.returncode return stdout, process.returncode def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both the project name and a version string. We will also support searching up two directory levels for an appropriately named parent directory """ rootdirs = [] for _ in range(3): dirname = os.path.basename(root) if dirname.startswith(parentdir_prefix): return {"version": dirname[len(parentdir_prefix):], "full-revisionid": None, "dirty": False, "error": None, "date": None} rootdirs.append(root) root = os.path.dirname(root) # up a level if verbose: print("Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix)) raise NotThisMethod("rootdir doesn't start with parentdir_prefix") @register_vcs_handler("git", "get_keywords") def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. keywords = {} try: with open(versionfile_abs, "r") as fobj: for line in fobj: if line.strip().startswith("git_refnames ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["refnames"] = mo.group(1) if line.strip().startswith("git_full ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["full"] = mo.group(1) if line.strip().startswith("git_date ="): mo = re.search(r'=\s*"(.*)"', line) if mo: keywords["date"] = mo.group(1) except OSError: pass return keywords @register_vcs_handler("git", "keywords") def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" if "refnames" not in keywords: raise NotThisMethod("Short version file found") date = keywords.get("date") if date is not None: # Use only the last line. Previous lines may contain GPG signature # information. date = date.splitlines()[-1] # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 # -like" string, which we must then edit to make compliant), because # it's been around since git-1.5.3, and it's too difficult to # discover which version we're using, or to work around using an # older one. date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) refnames = keywords["refnames"].strip() if refnames.startswith("$Format"): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") refs = {r.strip() for r in refnames.strip("()").split(",")} # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d # expansion behaves like git log --decorate=short and strips out the # refs/heads/ and refs/tags/ prefixes that would let us distinguish # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". tags = {r for r in refs if re.search(r'\d', r)} if verbose: print("discarding '%s', no digits" % ",".join(refs - tags)) if verbose: print("likely tags: %s" % ",".join(sorted(tags))) for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix):] # Filter out refs that exactly match prefix or that don't start # with a number once the prefix is stripped (mostly a concern # when prefix is '') if not re.match(r'\d', r): continue if verbose: print("picking %s" % r) return {"version": r, "full-revisionid": keywords["full"].strip(), "dirty": False, "error": None, "date": date} # no suitable tags, so version is "0+unknown", but full hex is still there if verbose: print("no suitable tags, using unknown + full revision id") return {"version": "0+unknown", "full-revisionid": keywords["full"].strip(), "dirty": False, "error": "no suitable tags", "date": None} @register_vcs_handler("git", "pieces_from_vcs") def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* expanded, and _version.py hasn't already been rewritten with a short version string, meaning we're inside a checked out source tree. """ GITS = ["git"] if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] # GIT_DIR can interfere with correct operation of Versioneer. # It may be intended to be passed to the Versioneer-versioned project, # but that should not change where we get our version from. env = os.environ.copy() env.pop("GIT_DIR", None) runner = functools.partial(runner, env=env) _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=not verbose) if rc != 0: if verbose: print("Directory %s not under git control" % root) raise NotThisMethod("'git rev-parse --git-dir' returned error") # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] # if there isn't one, this yields HEX[-dirty] (no NUM) describe_out, rc = runner(GITS, [ "describe", "--tags", "--dirty", "--always", "--long", "--match", f"{tag_prefix}[[:digit:]]*" ], cwd=root) # --long was added in git-1.5.5 if describe_out is None: raise NotThisMethod("'git describe' failed") describe_out = describe_out.strip() full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) if full_out is None: raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root) # --abbrev-ref was added in git-1.6.3 if rc != 0 or branch_name is None: raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") branch_name = branch_name.strip() if branch_name == "HEAD": # If we aren't exactly on a branch, pick a branch which represents # the current commit. If all else fails, we are on a branchless # commit. branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) # --contains was added in git-1.5.4 if rc != 0 or branches is None: raise NotThisMethod("'git branch --contains' returned error") branches = branches.split("\n") # Remove the first line if we're running detached if "(" in branches[0]: branches.pop(0) # Strip off the leading "* " from the list of branches. branches = [branch[2:] for branch in branches] if "master" in branches: branch_name = "master" elif not branches: branch_name = None else: # Pick the first branch that is returned. Good or bad. branch_name = branches[0] pieces["branch"] = branch_name # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] # TAG might have hyphens. git_describe = describe_out # look for -dirty suffix dirty = git_describe.endswith("-dirty") pieces["dirty"] = dirty if dirty: git_describe = git_describe[:git_describe.rindex("-dirty")] # now we have TAG-NUM-gHEX or HEX if "-" in git_describe: # TAG-NUM-gHEX mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) if not mo: # unparsable. Maybe git-describe is misbehaving? pieces["error"] = ("unable to parse git-describe output: '%s'" % describe_out) return pieces # tag full_tag = mo.group(1) if not full_tag.startswith(tag_prefix): if verbose: fmt = "tag '%s' doesn't start with prefix '%s'" print(fmt % (full_tag, tag_prefix)) pieces["error"] = ("tag '%s' doesn't start with prefix '%s'" % (full_tag, tag_prefix)) return pieces pieces["closest-tag"] = full_tag[len(tag_prefix):] # distance: number of commits since tag pieces["distance"] = int(mo.group(2)) # commit: short hex revision ID pieces["short"] = mo.group(3) else: # HEX: no tags pieces["closest-tag"] = None out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) pieces["distance"] = len(out.split()) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() # Use only the last line. Previous lines may contain GPG signature # information. date = date.splitlines()[-1] pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty Exceptions: 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += plus_or_dot(pieces) rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" else: # exception #1 rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" return rendered def render_pep440_branch(pieces): """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . The ".dev0" means not master branch. Note that .dev0 sorts backwards (a feature branch will appear "older" than the master branch). Exceptions: 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: if pieces["branch"] != "master": rendered += ".dev0" rendered += plus_or_dot(pieces) rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" else: # exception #1 rendered = "0" if pieces["branch"] != "master": rendered += ".dev0" rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) if pieces["dirty"]: rendered += ".dirty" return rendered def pep440_split_post(ver): """Split pep440 version string at the post-release segment. Returns the release segments before the post-release and the post-release version number (or -1 if no post-release segment is present). """ vc = str.split(ver, ".post") return vc[0], int(vc[1] or 0) if len(vc) == 2 else None def render_pep440_pre(pieces): """TAG[.postN.devDISTANCE] -- No -dirty. Exceptions: 1: no tags. 0.post0.devDISTANCE """ if pieces["closest-tag"]: if pieces["distance"]: # update the post release segment tag_version, post_version = pep440_split_post(pieces["closest-tag"]) rendered = tag_version if post_version is not None: rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) else: rendered += ".post0.dev%d" % (pieces["distance"]) else: # no commits, use the tag as the version rendered = pieces["closest-tag"] else: # exception #1 rendered = "0.post0.dev%d" % pieces["distance"] return rendered def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards (a dirty tree will appear "older" than the corresponding clean one), but you shouldn't be releasing software with -dirty anyways. Exceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" rendered += plus_or_dot(pieces) rendered += "g%s" % pieces["short"] else: # exception #1 rendered = "0.post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" rendered += "+g%s" % pieces["short"] return rendered def render_pep440_post_branch(pieces): """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . The ".dev0" means not master branch. Exceptions: 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pieces["distance"] if pieces["branch"] != "master": rendered += ".dev0" rendered += plus_or_dot(pieces) rendered += "g%s" % pieces["short"] if pieces["dirty"]: rendered += ".dirty" else: # exception #1 rendered = "0.post%d" % pieces["distance"] if pieces["branch"] != "master": rendered += ".dev0" rendered += "+g%s" % pieces["short"] if pieces["dirty"]: rendered += ".dirty" return rendered def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. Exceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: rendered += ".post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" else: # exception #1 rendered = "0.post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" return rendered def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"]: rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) else: # exception #1 rendered = pieces["short"] if pieces["dirty"]: rendered += "-dirty" return rendered def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. The distance/hash is unconditional. Exceptions: 1: no tags. HEX[-dirty] (note: no 'g' prefix) """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) else: # exception #1 rendered = pieces["short"] if pieces["dirty"]: rendered += "-dirty" return rendered def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", "full-revisionid": pieces.get("long"), "dirty": None, "error": pieces["error"], "date": None} if not style or style == "default": style = "pep440" # the default if style == "pep440": rendered = render_pep440(pieces) elif style == "pep440-branch": rendered = render_pep440_branch(pieces) elif style == "pep440-pre": rendered = render_pep440_pre(pieces) elif style == "pep440-post": rendered = render_pep440_post(pieces) elif style == "pep440-post-branch": rendered = render_pep440_post_branch(pieces) elif style == "pep440-old": rendered = render_pep440_old(pieces) elif style == "git-describe": rendered = render_git_describe(pieces) elif style == "git-describe-long": rendered = render_git_describe_long(pieces) else: raise ValueError("unknown style '%s'" % style) return {"version": rendered, "full-revisionid": pieces["long"], "dirty": pieces["dirty"], "error": None, "date": pieces.get("date")} def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which # case we can only use expanded keywords. cfg = get_config() verbose = cfg.verbose try: return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose) except NotThisMethod: pass try: root = os.path.realpath(__file__) # versionfile_source is the relative path from the top of the source # tree (where the .git directory might live) to this file. Invert # this to find the root from __file__. for _ in cfg.versionfile_source.split('/'): root = os.path.dirname(root) except NameError: return {"version": "0+unknown", "full-revisionid": None, "dirty": None, "error": "unable to find root of source tree", "date": None} try: pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) return render(pieces, cfg.style) except NotThisMethod: pass try: if cfg.parentdir_prefix: return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) except NotThisMethod: pass return {"version": "0+unknown", "full-revisionid": None, "dirty": None, "error": "unable to compute version", "date": None} python-autodocsumm-0.2.14/conftest.py000066400000000000000000000007451470544416500176740ustar00rootroot00000000000000import os.path as osp import pytest import sphinx import sys from packaging.version import Version if Version(sphinx.__version__) < Version("8.0.0"): from sphinx.testing.path import path else: from pathlib import Path as path pytest_plugins = 'sphinx.testing.fixtures' sphinx_supp = osp.abspath(osp.join(osp.dirname(__file__), "tests")) @pytest.fixture(scope='session') def rootdir(): return path(sphinx_supp) sys.path.insert(0, osp.join(sphinx_supp, "test-root")) python-autodocsumm-0.2.14/docs/000077500000000000000000000000001470544416500164175ustar00rootroot00000000000000python-autodocsumm-0.2.14/docs/Makefile000066400000000000000000000163611470544416500200660ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " coverage to run coverage check of the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/syplot.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/syplot.qhc" applehelp: $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp @echo @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." @echo "N.B. You won't be able to view it unless you put it in" \ "~/Library/Documentation/Help or install it in your application" \ "bundle." devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/syplot" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/syplot" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." coverage: $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage @echo "Testing of coverage in the sources finished, look at the " \ "results in $(BUILDDIR)/coverage/python.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." python-autodocsumm-0.2.14/docs/api/000077500000000000000000000000001470544416500171705ustar00rootroot00000000000000python-autodocsumm-0.2.14/docs/api/autodocsumm.rst000066400000000000000000000001371470544416500222630ustar00rootroot00000000000000API Reference ============= .. automodule:: autodocsumm :members: :show-inheritance: python-autodocsumm-0.2.14/docs/apigen.bash000077500000000000000000000005001470544416500205170ustar00rootroot00000000000000#!/bin/bash # script to automatically generate the autodocsumm api documentation using # sphinx-apidoc and sed sphinx-apidoc -f -M -e -T -o api ../autodocsumm/ # replace chapter title in autodocsumm.rst sed -i '' -e 1,1s/.*/'API Reference'/ api/autodocsumm.rst sed -i '' -e 2,2s/.*/'============='/ api/autodocsumm.rst python-autodocsumm-0.2.14/docs/call_demo.py000066400000000000000000000013561470544416500207150ustar00rootroot00000000000000""" Some module ----------- Just a dummy module with some class definition """ class CallableDescriptor(object): """A class defining a __call__ method""" def __get__(self, instance, owner): return self def __set__(self, instance, value): """Actually not required. We just implement it to ensure the python "help" function works well""" pass def __call__(self, a, b): """ Caller docstring for class attribute Parameters ---------- a: any dummy parameter b: anything else second dummy parameter""" pass class MyClass(object): """Some class With some description""" do_something = CallableDescriptor() python-autodocsumm-0.2.14/docs/conf.py000066400000000000000000000320131470544416500177150ustar00rootroot00000000000000# autodocsumm documentation build configuration file, created by # sphinx-quickstart on Mon Jul 20 18:01:33 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os import os.path as osp import re import autodocsumm # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath(osp.dirname(__file__))) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.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 = [ 'autodocsumm', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # on_rtd is whether we are on readthedocs.org, this line of code grabbed from # docs.readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' napoleon_use_admonition_for_examples = True # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' autodoc_default_options = {'show_inheritance': True, 'autosummary': True} autoclass_content = 'both' autodata_content = 'call' not_document_data = ['no_data_demo.d'] add_module_names = False # General information about the project. project = 'autodocsumm' copyright = '2016-2019, Philipp S. Sommer; 2020-2021, Helmholtz-Zentrum Hereon' author = 'Philipp S. Sommer' # 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 = re.match('\d+\.\d+\.\d+', autodocsumm.__version__).group() # The full version, including alpha/beta/rc tags. release = autodocsumm.__version__ # 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 # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'sphinx_rtd_theme' # otherwise, readthedocs.org uses their theme by default, so no need to specify # 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 themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' #html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value #html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'autodocsummdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', 'preamble': '\setcounter{tocdepth}{10}' # Latex figure (float) alignment #'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'autodocsumm.tex', u'autodocsumm Documentation', u'Philipp Sommer', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'autodocsumm', u'autodocsumm Documentation', [author], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'autodocsumm', u'autodocsumm Documentation', author, 'autodocsumm', 'Extending your autodoc API docs with a summary', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. epub_title = project epub_author = author epub_publisher = author epub_copyright = copyright # The basename for the epub file. It defaults to the project name. #epub_basename = project # The HTML theme for the epub output. Since the default themes are not optimized # for small screen space, using the same theme for HTML and epub output is # usually not wise. This defaults to 'epub', a theme designed to save visual # space. #epub_theme = 'epub' # The language of the text. It defaults to the language option # or 'en' if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # A tuple containing the cover image and cover page html template filenames. #epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. #epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # The depth of the table of contents in toc.ncx. #epub_tocdepth = 3 # Allow duplicate toc entries. #epub_tocdup = True # Choose between 'default' and 'includehidden'. #epub_tocscope = 'default' # Fix unsupported image types using the Pillow. #epub_fix_images = False # Scale large images. #epub_max_image_width = 0 # How to display URL addresses: 'footnote', 'no', or 'inline'. #epub_show_urls = 'inline' # If false, no index is generated. #epub_use_index = True # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'sphinx': ('https://www.sphinx-doc.org/en/master/', None), 'python': ('https://docs.python.org/3.9/', None), } def example_grouper(app, what, name, obj, section, parent): import dummy2 if parent is dummy2.MyClass and name == 'some_other_attr': return 'Alternative Section' # -- Extension interface ------------------------------------------------------ # taken from sphinx conf.py from sphinx import addnodes # noqa event_sig_re = re.compile(r'([a-zA-Z-]+)\s*\((.*)\)') def parse_event(env, sig, signode): m = event_sig_re.match(sig) if not m: signode += addnodes.desc_name(sig, sig) return sig name, args = m.groups() signode += addnodes.desc_name(name, name) plist = addnodes.desc_parameterlist() for arg in args.split(','): arg = arg.strip() plist += addnodes.desc_parameter(arg, arg) signode += plist return name def setup(app): from sphinx.util.docfields import GroupedField app.connect('autodocsumm-grouper', example_grouper) app.add_object_type('confval', 'confval', objname='configuration value', indextemplate='pair: %s; configuration value') fdesc = GroupedField('parameter', label='Parameters', names=['param'], can_collapse=True) app.add_object_type('event', 'event', 'pair: %s; event', parse_event, doc_field_types=[fdesc]) python-autodocsumm-0.2.14/docs/conf_settings.rst000066400000000000000000000132531470544416500220220ustar00rootroot00000000000000.. highlight:: rest Configuration of the sphinx extension ===================================== The module provides 3 additional configuration values, one event and new flags for the autodoc directives :rst:dir:`autoclass` and :rst:dir:`automodule`. .. _autodoc-flags: Additional flags for autodoc directives --------------------------------------- The most important new flag for the :rst:dir:`autoclass` and :rst:dir:`automodule` directives is the ``autosummary`` flag. If you want to have an automatically generated summary to your class or module, you have to add this flag, e.g. via:: .. autodoc:: MyClass :autosummary: or in the :confval:`autodoc_default_options` configuration value of sphinx via .. code-block:: python autodoc_default_options = {'autosummary': True} See also the usage in the :ref:`examples` section. The other additional flags lets you control what should be in the autosummary table: these are - ``autosummary-private-members`` - ``autosummary-undoc-members`` - ``autosummary-inherited-members`` - ``autosummary-special-members`` - ``autosummary-exlude-members`` - ``autosummary-imported-members`` - ``autosummary-ignore-module-all`` - ``autosummary-members`` They are essentially the same as the options for :mod:`~sphinx.ext.autodoc` (i.e. ``private-members`` or ``members``), but they only affect the autosummary table (see the example in :ref:`summary-table-example`). ``autosummary-no-nesting`` The new additional flag ``autosummary-no-nesting`` only generates autosummary tables for a module, but not for members within. See example about :ref:`no-nesting-example`. ``autosummary-sections`` Select which sections to generate the autosummary for. Usage is like ``:autosummary-sections: Methods ;; Attributes``. When omitted, all sections are generated. See the example about :ref:`select-sections-example` ``autosummary-no-titles`` Do not add section titles above each autosummary table ``autosummary-force-inline`` Force adding the autosummary, even it is already contained in the class or module docstring. See the example about :ref:`autosummary-position-example` ``autosummary-nosignatures`` Do not show function signatures in the summary table. .. _directives: Directives ---------- .. rst:directive:: autoclasssumm This class generates the autosummary tables for the given class. You can use the same options as for the ``autoclass`` directive. You can select a specific section and omit the title via:: .. autoclasssumm:: MyClass :autosummary-sections: Methods :autosummary-no-titles: By default, this directives also sets the `:members:` option unless you specify `:no-members`. .. rst:directive:: autoexceptionsumm The same as the ``autoclasssumm`` directive, just for an ``Exception`` subclass. .. rst:directive:: automodulesumm The same as the ``autoclasssumm`` directive, just for a module. .. _confvals: Configuration values and events ------------------------------- .. event:: autodocsumm-grouper (app, what, name, obj, section, parent) Emitted when autodocsumm has to determine the section for a member in the table of contents. If the return value is None, the given `section` will be used. :param app: the :class:`~sphinx.application.Sphinx` application object :param what: the type of the object which the docstring belongs to (one of ``"module"``, ``"class"``, ``"exception"``, ``"function"``, ``"method"``, ``"attribute"``) :param name: the fully qualified name of the object :param obj: the member object :param section: The section title that would be given to the object automatically (one of ``"Classes"``, ``"Exceptions"``, ``"Functions"``, ``"Methods"``, ``"Attributes"``, ``"Data"``) :param parent: The parent object holding the member `obj` .. confval:: autodata_content As you can include the ``__init__`` method documentation for via the :confval:`autoclass_content ` configuration value, this configuration value lets you include the documentation from the ``__call__`` method. Possible values are class To only use the class documentation call To only use the documentation from the ``__call__`` method both To use the documentation from all. The default is ``'call'`` .. confval:: document_data To include the string representation of specific data objects. You may provide a list of fully qualified object names (e.g. in the form of ``'zipfile.ZipFile'``) or ``True`` or ``False`` .. confval:: not_document_data To exclude the string representation of specific data objects. You may provide a list of fully qualified object names (e.g. in the form of ``'zipfile.ZipFile'``) or ``True`` or ``False`` .. confval:: autodocsumm_section_sorter When ``True`` the summarizing sections will be sorted alphanumerically by their section title. Alternatively a callable can be set that is passed to :func:`sorted` as key argument to sort the the summary sections by their name. The default value is ``None``. Example usage with a tuple that defines an arbitrary order: .. code-block:: python sections_order = ("Public methods", "Attributes", "Private methods") autodocsumm_section_sorter = lambda title: sections_order.index(title) An example for cases that only ensures that "Constructors" are always listed first and "Attributes" while not failing when encountering undefined section weights: .. code-block:: python section_weights = {"Attributes": 100, "Constructors": -100} autodocsumm_section_sorter = lambda title: sections_weights.get(title, 0) python-autodocsumm-0.2.14/docs/demo_class.rst000066400000000000000000000001401470544416500212550ustar00rootroot00000000000000.. _demo_class: Demo Class ========== .. autoclass:: dummy.MyClass :members: :noindex:python-autodocsumm-0.2.14/docs/demo_exception.rst000066400000000000000000000001641470544416500221540ustar00rootroot00000000000000.. _demo_exception: Demo Exception ============== .. autoexception:: dummy.MyException :members: :noindex:python-autodocsumm-0.2.14/docs/demo_grouper.rst000066400000000000000000000001471470544416500216420ustar00rootroot00000000000000.. _demo_grouper: Demo Grouper ============ .. autoclass:: dummy2.MyClass :members: :noindex:python-autodocsumm-0.2.14/docs/demo_module.rst000066400000000000000000000001031470544416500214340ustar00rootroot00000000000000.. _demo_module: .. automodule:: dummy :members: :noindex:python-autodocsumm-0.2.14/docs/dummy.py000066400000000000000000000011541470544416500201250ustar00rootroot00000000000000""" Some module ----------- Just a dummy module with some class definition """ class MyClass(object): """Some class With some description""" def do_something(self): """Do something""" pass #: Any instance attribute some_attr = None #: Any other instance attribute some_other_attr = None class MyException(object): """Some Exception With some description""" def do_something_exceptional(self): """Do something exceptional""" pass #: Any instance attribute some_exception_attr = None #: Some module data large_data = 'Whatever' python-autodocsumm-0.2.14/docs/dummy2.py000077700000000000000000000000001470544416500217062dummy.pyustar00rootroot00000000000000python-autodocsumm-0.2.14/docs/examples.rst000066400000000000000000000144331470544416500207740ustar00rootroot00000000000000.. _examples: Examples ======== .. toctree:: :hidden: Demo Module Demo Class Demo Exception Demo Grouper Including a table of contents ----------------------------- Consider for example the following module in ``dummy.py``: .. literalinclude:: dummy.py The *autosummary* flag introduces a small table of contents. So:: .. automodule:: dummy :members: :autosummary: produces :ref:`this `. And:: .. autoclass:: dummy.MyClass :members: :autosummary: produces :ref:`this `, and for exceptions:: .. autoexception:: dummy.MyException :members: :autosummary: produces :ref:`this `. By default, module members are (mainly) grouped according into *Functions*, *Classes* and *Data*, class members are grouped into *Methods* and *Attributes*. But you can also provide alternative section names by connecting to the :event:`autodocsumm-grouper` event. For example, if you include:: def example_grouper(app, what, name, obj, section, options, parent): import dummy if parent is dummy.MyClass and name == 'some_other_attr': return 'Alternative Section' def setup(app): app.connect('autodocsumm-grouper', example_grouper) in your *conf.py*, you get :ref:`this `. Note that you can also include the *autosummary* flag in the :confval:`autodoc_default_options` configuration value Including the ``__call__`` method --------------------------------- Suppose you have a descriptor with a ``__call__`` method (i.e. somewhat like a method with additional features). .. literalinclude:: call_demo.py Then, if you set ``autodata_content = 'both'`` in your *conf.py* you get via:: .. autoclass:: call_demo.MyClass :noindex: :members: :undoc-members: .. autoclass:: call_demo.MyClass :noindex: :members: :undoc-members: Skip large data representations ------------------------------- You can exclude large data representations via the :confval:`not_document_data` and :confval:`document_data` configuration values. Suppose you have a dictionary with a very large representation, e.g. in the file `no_data_demo.py` .. literalinclude:: no_data_demo.py which you convert to .. autodata:: keep_data_demo.d :noindex: You can skip this if you specify ``not_document_data = ['no_data_demo.d']`` in your *conf.py*. Then you get .. autodata:: no_data_demo.d :noindex: .. _summary-table-example: Generating a summary table without the full documentation --------------------------------------------------------- Using one of the ``autosummary-...`` options (e.g. ``autosummary-members``, see :ref:`autodoc-flags`) let's you create a summary table that points to the documentation in another point of the documentation. You should, however make sure to add the ``noindex`` flag and to add a ``no-members`` flag. For our :mod:`autodocsumm` module this for example then looks like:: .. automodule:: autodocsumm :noindex: :no-members: :autosummary: :autosummary-members: which gives us .. automodule:: autodocsumm :noindex: :no-members: :autosummary: :autosummary-members: .. _no-nesting-example: Generating a summary table for the module without nesting --------------------------------------------------------- Using the ``autosummary-no-nesting`` option, you can generate the autosummary table for a module without generating autosummary tables for members within that module. This is useful when you only want to use the autosummary table as a table of contents for a given page. For the :doc:`demo module `, here's an example:: .. automodule:: dummy :autosummary: :members: :autosummary-no-nesting: which gives us .. automodule:: dummy :noindex: :members: :autosummary: :autosummary-no-nesting: .. _nosignatures-example: Generating a summary table without signatures --------------------------------------------- Using the ``autosummary-nosignatures`` option, you can generate the autosummary table for a module that will not include function signatures. This is useful for giving a high-level overview of the function name and description. For the :doc:`demo module `, here's an example:: .. automodule:: dummy :members: :autosummary: :autosummary-nosignatures: which gives us .. automodule:: dummy :members: :autosummary: :autosummary-nosignatures: .. _select-sections-example: Select the sections to document ------------------------------- You can select, which sections to document. If you only want the *Methods* section of a class, you can specify:: .. autoclass:: dummy.MyClass :members: :autosummary: :autosummary-sections: Methods Multiple sections might be separated by `;;`, e.g. ``:autosummary-sections: Methods ;; Attributes``. This also works for the ``autoclasssumm``, ``autoexceptionsumm`` and ``automodulesumm`` directives, e.g.:: .. autoclasssumm:: dummy.SomeClass :autosummary-sections: Methods .. autoclasssumm:: dummy.MyClass :autosummary-sections: Methods .. _autosummary-position-example: Positioning of the autosummary table ------------------------------------ By default, the autosummary tables are put at the end of the docstring sections for classes and methods, i.e. something like:: class-name class-docstring autosummary-tables class-members You can customize this positioning by calling the ``.. autoclasssumm::`` directive inside the class docstring, e.g. .. literalinclude:: inline_autoclasssumm.py Documenting this, with ``.. autoclass:: MyClass`` creates .. autoclass:: inline_autoclasssumm.MyClass :noindex: :members: Note that this omits the `Attributes` section as we specified the ``:autosummary-sections:`` options here. If you want to list this section anyway at the end of the docstring, you can use the ``autosummary-force-inline`` option, e.g.:: .. autoclass:: inline_autoclasssumm.MyClass :members: :autosummary-force-inline: :autosummary-sections: Attributes .. autoclass:: inline_autoclasssumm.MyClass :members: :noindex: :autosummary-force-inline: :autosummary-sections: Attributes python-autodocsumm-0.2.14/docs/index.rst000066400000000000000000000110651470544416500202630ustar00rootroot00000000000000.. autodocsumm documentation master file, created by sphinx-quickstart on Mon Jul 20 18:01:33 2015. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. ============================================== Extending your autodoc API docs with a summary ============================================== .. start-badges .. only:: html and not epub .. list-table:: :stub-columns: 1 :widths: 10 90 * - docs - |docs| * - tests - |github-action| |codecov| * - package - |version| |supported-versions| |supported-implementations| .. |docs| image:: http://readthedocs.org/projects/autodocsumm/badge/?version=latest :alt: Documentation Status :target: http://autodocsumm.readthedocs.io/en/latest/?badge=latest .. |github-action| image:: https://github.com/Chilipp/autodocsumm/workflows/Tests/badge.svg :alt: Tests :target: https://github.com/Chilipp/autodocsumm/actions?query=workflow%3A%22Tests%22 .. |codecov| image:: https://codecov.io/gh/Chilipp/autodocsumm/branch/master/graph/badge.svg?token=I9wlZyhI4Y :alt: Codecov :target: https://codecov.io/gh/Chilipp/autodocsumm .. |version| image:: https://img.shields.io/pypi/v/autodocsumm.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/autodocsumm .. |supported-versions| image:: https://img.shields.io/pypi/pyversions/autodocsumm.svg?style=flat :alt: Supported versions :target: https://pypi.python.org/pypi/autodocsumm .. |supported-implementations| image:: https://img.shields.io/pypi/implementation/autodocsumm.svg?style=flat :alt: Supported implementations :target: https://pypi.python.org/pypi/autodocsumm .. end-badges Welcome! This sphinx extension provides some useful extensions to the Sphinxs autodoc_ extension. Those are 1. It creates a *Table of Contents* in the style of the autosummary_ extension with methods, classes, functions and attributes 2. As you can include the ``__init__`` method documentation for via the :confval:`autoclass_content ` configuration value, we provide the :confval:`autodata_content` configuration value to include the documentation from the ``__call__`` method 3. You can exclude the string representation of specific objects. E.g. if you have a large dictionary using the :confval:`not_document_data` configuration value. See the :ref:`examples` section for more details. .. _autodoc: http://www.sphinx-doc.org/en/stable/ext/autodoc.html .. _autosummary: http://www.sphinx-doc.org/en/stable/ext/autosummary.html Content ------- .. toctree:: :maxdepth: 1 conf_settings examples api/autodocsumm.rst Installation ============ Simply install it via ``pip``:: $ pip install autodocsumm Or you install it via:: $ python setup.py install from the `source on GitHub`_. .. _source on GitHub: https://github.com/Chilipp/autodocsumm Requirements ============ The package only requires Sphinx_ to be installed. It has been tested for versions higher than 1.3. .. _Sphinx: http://www.sphinx-doc.org/en/stable Quickstart ========== In order to activate the autodocsumm extension, you have to list it in your ``conf.py``: .. code-block:: python :caption: conf.py extensions = [ 'sphinx.ext.autodoc', ..., 'autodocsumm', ] Once this is done, you can use the ``:autosummary:`` option for autodoc directives to generate a table at the top, e.g.: .. code-block:: rst .. automodule:: autodocsumm :autosummary: Optionally, you can make autodocsumm active by default for all autodoc directives by adding: .. code-block:: python :caption: conf.py autodoc_default_options = { 'autosummary': True, } Disclaimer ========== Copyright 2016-2019, Philipp S. Sommer Copyright 2020-2021, Helmholtz-Zentrum Hereon Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-autodocsumm-0.2.14/docs/inline_autoclasssumm.py000066400000000000000000000004401470544416500232250ustar00rootroot00000000000000class MyClass(object): """Some class .. autoclasssumm:: MyClass :autosummary-sections: Methods This will be after the autosummary table. """ def do_something(self): """Do something""" pass #: Any instance attribute some_attr = None python-autodocsumm-0.2.14/docs/keep_data_demo.py000077700000000000000000000000001470544416500246702no_data_demo.pyustar00rootroot00000000000000python-autodocsumm-0.2.14/docs/no_data_demo.py000066400000000000000000000000731470544416500214020ustar00rootroot00000000000000#: very large object d = dict(zip(range(100), range(100))) python-autodocsumm-0.2.14/docs/objects.inv000066400000000000000000000203371470544416500205730ustar00rootroot00000000000000# Sphinx inventory version 2 # Project: Sphinx # Version: 1.4.6 # The remainder of this file is compressed using zlib. xÚ½][¯Ü6’~ï_!` °@·Ç™À,à[/âÄŸÌ› –ØÝòÑÍ"u.ùõ[Å‹DJ”DRÊ<$>-ñûH)²X,?=¿«+–äi£´i^³ç†D¯¢¬.á=ÝXYüGüîóç‡ï>þùëW/¢ãáÓyýúN HÙ #Ÿ“6)àtL”ÖeqÎH›°z­,?T¯þËàÜ?å”­Ðü·¨Î&pHùKǤ”Ò"¡t¶ží¿~ý±ªœ0?ÿ•þÊÓáAÌ›¬çøî†J¸ Eð÷»è?ÿÇE<õÇϯî>P¿ccÉ+¶^…ÌMœwsÁH‚:Ox³,óþý\×…C%ÇdÏï·6išõZþíÅöõk×¾ýóß$DäýaÂá!c“jˆ•0DØ®x)¼8] ûß/¿ü}¥¯/]•²¼®&_â>Ž<Á¨EøÐ¶5û5ËPn†ç d)¿3…£– úxŒëµ+arX/}ƒ8ùª|>ÍÚºHA㇤èÈl- ¦ð©÷ãù6ºL·]îD³:¶áHwâ‘‹ù3,ªñSÛðAªAÛh`DÚtƒºØ¡P|ÂÛSü_“‡D¬#¶sáÎË(Ré½´l¤#O{|ûôXLCßßé›Ü§/ Ëž]’¤Mo±nÂÙH( ´·{†…îº*k“Š^ê¶ÜF#%­ á$°Œî®;P|·‘#§»T‡”ù  ùµt1ÚÙòêRoc¨A»kóŒìò¥É †˜öŠV8%Lôä‚{ÝlåꚘ(5rì\ÓCÈcÒ†ãNú¼…f»’0mÖä€nÜ­GLy$N>K–—djX¿‡k´V.uÛ¼òž¤ZmZïÔù¥Lÿþí ”šL&YÊR¡Å[™½Iâ¤(ö!ÂUX¦û°‰Í“­\èÕô¶•xqÝ1¾›ƒ»0t– uÖ]›ïÁÇ\ˆîÁ67øp4-Á½‘ø±ÍÙÌçåC‡4Dm€…á8@n¤h¾Ú~zƒýY>d“Îç„ÊZ2qÁØDió›ØDH»¦©[ü òwÔpµ@ýsHo ‚“ÀT‚OïÄ¿AÍ`çn‚º0ñÏí$zø^¿ >½ÿ‰ÞÎ,úº0ÑÏí%ú®,ŸÐÓ{ü˜Ð'øP M‰v’iºs˜pyúÿ ÍÜ'DažÐì(ß¿„ ø/¼L ±‰ß$äU¸˜GD; šï<±0QKðé¡Êð.aIQ_ƒ¤¾HÜˬam±Ì¹S³à‹°6Á÷Òe¯nŸ¼ûôSP{ÌÒ·Å%U—ŸáÏ Fš¥ nšyư™çÛ©¾±ð)B`O¿²àéÁÆ,{+Y˜Ø­T;IFÀÞ-Â[ä|ºÿ ÝÎ,öº0ÁÏí'z,w†…b¡7Ð[dmKÙ¤ÙI¾O¡v¬'\fSÒeõ¿U~C°˜­da¢¶Rí'îÓyí$©]d´›t„C¸¿C¿Œ¦ñ®‡»y-É0¶üÄ«…,Uˆ÷½kÛ(ÏÃ,ô”$iç|œY²ÖöxÚ½¿àß¹ã÷„,‰åñŒÍ\K¾ôþ,›ëÆo¸c2ÝT"î=¼?¾Ì”WYžn¯ºØäIó³¢¹ŠäLŠ­$%i¯ÊÿS*XH ñ:œ94ôÍÒnÚÚŒnþv[BëâÄIõÜVÛL¶hÆÙÞ‹ \ÆgŽ(:"OüüÈŒ«ß:Ç/ç¯wöc¡óXR=äm]•êøËhJ× ó‰ÞiL¶Q)t2GtÀši6œsaDÞ™QLß;ÂwùÆH°u@¾…!(ÏMî+ÇKÝUƒ?éN¤xpwaV ¡¬ÈcLùOUïÕDUþœþ’*}Þ•¶%-I²½([R\ª]»'mÓ};{±g'š;™Ê5{FmŽÏøRÿõ…ÀÉõEÀAa‰ßrÖXRˆ#»àO)ÌŽ×ZD°4ð2ÑÝ”$¼ÿ ‹ˆC=Ø !\O0©‰ÃÍã6})ŸÏ¶è= {$¤d™Ì ÓŽÅ Œà)A”¦=©ž`­*28‘G\d§Hñ´Öبxõ ŸˆøÃ~eÄ5"ÁÉLãN¾”Ï—ò‡ÿúÀ?V½X_svëÎhªŸâµw‹íæ!ÿ}Š—/–ÀùÅn÷x©^,‚Ëk©æ‹qÕ ¦^–T)Ì—9†ë)§ùi–©|Íñ<“¢·Dñ•U‚oy©)@ªK`$?˘R^¹âû¯É“7 °"š¬x©^,q ™ñáè!'Vù¨s`UÐ6SŠW “¥ŠHø¹?¾z¹¯Jpãñ´=…Ñï¯Øªe€ÜÉS÷@¦ †ô½´ý•£Úƒ±–q¼cæø•òíÛõÞ$Ú×Z ]µ¿¨/³V*ëZl™Ümµ /%tNè«ܟdz{òüX·ÎÉe¨ý¼J‹.#¾ß ¸¸‘$#ÎÃa™ÜÑSsNÎìÃÑ0æŽ+ Ëãs "%Î¥09,¥GÊÇRúŠ<Òk[w3 fÄwE6s^¬>=•_¡à9”Õï÷ !jÑg‘ŽnTð. ­ƒëBMtˆKùžÇ`Ãׯ§<Ïþc°Y+O9ccZɯ¡vË£kñ^«{Ôr.¾s„Y+WFÒÚ{}ªã‚äFžR§ÒÍ[—ùÝf>ÝkÉ+íÄ$²ÎÜÈC:ŒŸNäxbžú—ßc(oÉ•<9ƒíÅy&‹»^O³^>µTÌ¡˜åbuç6O}‡zš”ΔÞua6FuGgùXrMë¢++ê›)^ÐãZ;\ˆãÙ²ªk|×êZg$Ww¬éX’GR÷ÊݳAÊ×vdV[s¼ª¦«ö± º'Î ‘ÜŠKø¬žKbE˜Wo´<5è ;åÇCYöºV^»yõPËØè“–™xw[°Ço]žÞó»ªÉ9aéÛZ¶ñd5ÛÊÐ>ñ¾a?–¤É¡‹ pt[! ?•_óv¦Þ±w;•2ýmgêm2;PIؘ4GÖílÊMt;©¶ÓôÞ Û¨.uQÔGáoþ\j¼*u¾+Š p9ÅÎýe‚Ñc1ö×m£A»Í#§¸ z#IUï6’ÕN5&æ=Žê=:JxqŽåöÏG]´¼~“­êNåm,x_äF!rÉžM¤<¢‚‡‡0‚Q1Þ„÷Ù7ÁEŒ|ŒüŒü>\D?†C?…C®êç`ä¯ÁÈ„WôîßÊûÏðL Î4ù·!GãÃ98ã4™…K8 Îôžé-8Ó뉯ÁoPj‹meÞ°ê Ÿ+ëðL7êß‚Ëüm[ÆÕì ‹.\å‡rTÛÇÐŒñT‰ÚØÀ«TIÅn„!=4><$êÞòéQÁÅÖîä «žÜЇɅOÌÑjó{½ÃûªA ¿([ŠÆ73¨ÄõÐ_•u•£&žù‹è™Ô¿Y+ÂÀ—‘°ÃTñ¹ã°ò̵*c$?mˆÕ5b8Ú+h~­âK‘\i8<Ï ýsöÎÐ(“:#qK®!5ÏrÊ/å&2ŽoÌêºð—@žä-"ë'UzÃpAhÒ†Iìþ˽þh×Þ°”¿c—yãvL\êPÑ–”T&¤Ä”Õ úù78±äˆâ–}‘Z¢aà‘Ä¥7"”ˆzf$ïG*CÕ"ÎïˆÓ±Õ¸É'TFÅÃGyÚ mÓòÊU$—Ð[(ø +~å ëZâK@ïóæ(=¼ý ±ô@¶Žn.µûZÇfñ=iDécèS²¾ø:½óíyWCž!Šû€mv¼qÔHç8'4O¥÷QÌ´f'4¶—_Do1}ô‰'2?gñ ¿F„\»\îÈ þÌÉÌIû'ý€oYžÆ ÂH®ýg‡=Hw„tr©ÌÏ@ÁâÁÅtˆryq˜‹µ8Ô}Û»(,û4ê¼T,.s‹•KÖ´ë^NFCš ÂO*?3¢­âøÿÔ~”—úÒ´„yôLgÍe@ñxÆ~Hǧ7X,4¨J|ä‰Ü«!kÝ@hœPë§5‰,#Å¿ùüñ Ïë…6Œôß„xf$ŸwFR=Ͼ]!v¾:r— ¢¯¾Že‰—¾‰HóûÈcxyášqÊéÉ&âø•±¬ìÐÎèÐu¼$ßLñÃ%z¼í7Âꊤž&;î/&uüö`¾æêÖq¤8q´t÷\qx'æç`ŒÖR9ÀyÑÄš# #ƒïyØ9ÆWŸ“ âU2òÄO]ñ»%©ð’?‰‹/¼Pà éÖÌKîW+ÃãÈS&²Bñcž9[¹8”Ç/ò– &òuç×Þ^â ).=½°2CƒWÙ˜o.룈+Ðø'u𑯝U3Ñ>Ö>[¯’uλ"9%Âêì z˜®+­A&嬚Â< ÐA®Èãk]_Çû<"â¬þ^Î=âÙQb>ˆŸÑâçjêó3ŒŸLàÒ 7äTueó<Ÿmæ#*›Ÿ»òóóZ.†2¢ž mä³ðX£QGqm v{†Îaå‰&—6øÐ'>¨qYÜqþ:¤YKÓ2YÂJÑGy×´0\ÚºŒ2]ŒÓˆÍ¶Ì&£¥˜Ðýô¶Ô‚:‘«q!ÑdË?üÃÈPjÍ\³¡F3á£!Ë”%¶—QMá\ËÁX:G¶ÐÒÀý®.ð¸.Š.Òˆ&¸usZ_[D–Ñ@|ÇaUÞ4„q㌣f›¦Ÿç8ËÇëþµŽ>É9îá{uþB‡8ÖSR-¾ud‹ˆ ¢¶îˆ>~Ã˹ªHm*F<ÍaézœÉ8v4<²ú,fâ¯ä埶Ä9û”\¼Sæ¥MŒ3ÒcLD¶øÚøAdYôƒúÍ_RãHFjDxˆlq·µ\mD¡nšEÂ’8˜7£h “¬F¢•€ÛZÆ:«|-«5:”`dg׎f‚rC6x ,v€š¡–$}éŸ,HS{”™R;²á–mcö-Þë„ÁÔAþ1}¸z+¾•aœ#º({ 6hG¶ÛP6]âƒÃa?¨q¿½ÑxÞŸ»Ð²êÏyEãàÜ£,ø3nÁ=è·Ç|F$îÈ»[е—f<×¼¦d‡És”ÍhVå~"¹ð£á ™DnäØñÃKÁ¡BükøÞæa›öÝbÜÙaAj—yˆL#}¯1 * I0X9×mœ",²öòôïTMÒŽå°({Z0ª-µ0ðç=šŸ_äp•¹^ùÔ°cõ÷žÐÂ=ZGª÷<ÖIï&MÓXiÞ 1<¬z©!'Üt‘”²I)»‘ªß÷o~=,—ôd8‘~Ï—Éö“+©†¤ÏJ=…âW§AJ†±Êcè†9? ]Ä,i¯„Qç¬$H†ö¦uÙ$Î.@ UH×@OXç¾Úìãqi-j˜ £ä/3é nÃÆøbšühnEŒ·ˆ†ƒ¸:VjC±:ÿjöu3r—Q C Ó0´°^ÆòZŠ~.ó5N @?C >8¦b r”]'»1ÇzZw¹,­»yÕe^Yãç7dlÔ–*¬ȇq’cå§ãÉwOàPIgHólßÞ]„ Õ"Vw¨z ùí >ŽŠuI<Ü*ÆêX;èæ}Æ'±Á_J/ab/ ɲ¾Ö>éåÇO*PB•÷#”¢ã¥º)‹ëw’øŽÔäPHŠÁ֘º}ìü[„/Ú½¬» öè½_2 ÅgèÝ*:¬V]ayFÎIë×°„a^f_ã!}¼¿y±@ôøØý@H§@ß y÷')+Z`´+áVäƒõ5Ð÷ •œvû'’‚¦Åž›¤òšíÄY¿ M¸‚ÏëèÜÏòƦ€ amàì!o&£®+lNç[ÅÒ‡kŠ ËôÚ ¿o¤˜^f•Óe0ô÷IçsD…ÕS@›–$å¹ð¯,ö`£ñÈ[]êã%'Ev”¼9?“èÖÁG<±Ä6&HÃÚê=‰bk–a`áË…í4hQ eA?<«/¹ÕSï#ÿ%ßI´ ¬;ˆ10-†mF>RërþCÛBÓì»qš¤7T ÊœY«:º‚Ѭê@SÂÚ#·Ž%k£‚³¾ÔÜ,VùïÂÆÜ'ïÅÒ¸Xf ¾ ¯|†¨­Gemë¾°}ŒÑÃpÌÐLm>HŸª¾D“ó‹c­Âæ!ÆLò8g¡€¾R?V ‰ÌG”§AûPrOHËXb®Ó§§ÏHßÞðSrGþ¥ÖártÖÄ>þ&Üà ã«Méû¨N=ˆoÑø¢ÖÄJ âŸßÜü¼Œâý¥.²˜ß¡ãuÒVx¬VåÌš4¸ó-èÌ„¼ â‹!4¸´äBý‘žFÅê¦ÀýXú¸/Ç>@á€MÒºw™ü¼ê  iÿl¾Çx#é½ç¡Ô'Ž!xÃZÂÐïÁÇò’ÔóÆ=Öí=ñ«ª9ÒIÚ2N›7!`~î=]³+“ÊwàHœ—6…LÚÕrÁE-“¡(ýt¹’°„GP·-€†Å/¢ïA}:>¢ ³‚à5z§5·5×­cê³mžê…ì "ì·Ø°T¯øE¯îòu¶±*éô›ÉMI™7µ[YäP†üï)}ÌÑô1ibO6Ú4Uuw=ÛZAœì“ ÄÌÕg4¬Ä†/è„xƒÆ~l}/Ü@™ãå(Áh†Êpx˯+ñ‚’ÑØÛcBÀ¼ì÷ ç&÷U°$È5ËàG3vɱƒ½¼ÕÅáL’ðö™={f:¡öàã· t[/™´Ô!õó•/ ½6Mî÷t¨_ºÌ ñQ¼|aC ¦öœ³ý6”7 R×+ÒŽü—{«üõ…ëJ]K²;Üÿ mAÚC_Ø•Vo);62oWœÍ°.VLÇ0ªÃÂáÖ;þ“ƤÉa î*<ƒ …ph;8}AÄ3©‹Š÷èX,Ó‚úѰIè ~-¸ñ¾w¯ oäãCï]?9na޵/mà£7˜463P†òb%ˆÆ¢ÞFzàk=°ŽƒÈT˜å†–ŸÌ—>õAº]8Ç}é€ò‘ß9_òõ(1ÐQ?×¼˜ ·´#ô³‹£Ñ¥ô–îi¿µþ‹x½•Ïèç4}­¬ÓÐ!M^8£‹ÕáÈñy1<9žÛ<»‡Ã;¸`R¨H z–Xcq¨€DQŸîá&{}DÝoÝõ¿Ç€!z Ášé '±‡¶àÇy'Òˆs 08rÙ ïs 9‘8Ö îÚYqQ5®ÜyašLX%®J?Oëáô†.úõ2þ°­ö†kz&Pî/ǯIt†jÕÇÅð PÉ—ºf¸Î–§±¸öÛ‘ÃâÏo:òŸƒÂ3ih„vµê“³Q¤`ÍÙÆð•®é1á°ô–zu ÝÒÃø-ü`#/ðÜÈøÚaR^µÓétð 1ªŽ×Ȩu–67NæXœ¯G§0ä£ÁJø9«Ó@ïp%ÊAv³²ùFP¼?Mô+¾ƒvÄà©&;f²è¹-×¢pLh,úÈT”ꤖ‰—O “±V§1PW…tè RÙÁ“°Þr𱵄„ÚÃ`µͶ‰8üq´‡Í³Ÿž’ðÔù©§²@£%sPû„‹\ú\±ä)h™+ ‡ÿÐ,1python-autodocsumm-0.2.14/docs/requirements.txt000066400000000000000000000000301470544416500216740ustar00rootroot00000000000000Sphinx sphinx-rtd-theme python-autodocsumm-0.2.14/pyproject.toml000066400000000000000000000034061470544416500204060ustar00rootroot00000000000000[build-system] build-backend = 'setuptools.build_meta' requires = ['setuptools >= 61.0', 'versioneer[toml]'] [project] name = 'autodocsumm' dynamic = ["version"] description = 'Extended sphinx autodoc including automatic autosummaries' readme = 'README.rst' keywords = ['sphinx', 'autodoc', 'autosummary', 'content', 'table'] authors = [ { name = 'Philipp S. Sommer', email = 'philipp.sommer@hereon.de' }, ] license = { text = 'Apache-2.0' } classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Topic :: Documentation', 'License :: OSI Approved :: Apache Software License', 'Framework :: Sphinx', 'Framework :: Sphinx :: Extension', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Operating System :: OS Independent', ] requires-python = '>= 3.7' dependencies = [ 'Sphinx >= 4.0, < 9.0', ] [project.urls] Homepage = "https://github.com/Chilipp/autodocsumm" Documentation = "https://autodocsumm.readthedocs.io/en/latest/" Source = "https://github.com/Chilipp/autodocsumm" Tracker = "https://github.com/Chilipp/autodocsumm/issues" [tool.setuptools] zip-safe = false [tool.setuptools.packages.find] namespaces = false exclude = ['docs', 'tests*', 'examples'] [tool.pytest.ini_options] addopts = '-v' [tool.versioneer] VCS = 'git' style = 'pep440' versionfile_source = 'autodocsumm/_version.py' versionfile_build = 'autodocsumm/_version.py' tag_prefix = 'v' parentdir_prefix = 'autodocsumm-' python-autodocsumm-0.2.14/setup.py000066400000000000000000000002101470544416500171720ustar00rootroot00000000000000from setuptools import setup import versioneer setup( version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass(), ) python-autodocsumm-0.2.14/tests/000077500000000000000000000000001470544416500166315ustar00rootroot00000000000000python-autodocsumm-0.2.14/tests/test-root/000077500000000000000000000000001470544416500205715ustar00rootroot00000000000000python-autodocsumm-0.2.14/tests/test-root/conf.py000066400000000000000000000021721470544416500220720ustar00rootroot00000000000000import sys import sphinx sys.path.insert(0, '.') master_doc = 'index' extensions = ['autodocsumm'] if tuple(map(int, sphinx.__version__.split('.')[:2])) < (2, 1): autodoc_default_flags = ['show_inheritance', 'autosummary', 'members'] else: autodoc_default_options = { 'show_inheritance': True, 'autosummary': True, 'members': True } not_document_data = [ 'dummy.large_data', 'dummy.TestClass.small_data', 'dummy_title.large_data', 'dummy_title.TestClass.small_data'] autodoc_typehints = "description" autodata_content = 'both' autodocsumm_section_sorter = True def member_filter(app, what, name, obj, skip, options): import dummy import dummy_title if (obj is dummy.TestClass.class_caller or obj is dummy_title.TestClass.class_caller): return False return None def group_member(app, what, name, obj, section, parent): if name == 'class_caller': return 'DummySection' def setup(app): app.connect('autodoc-skip-member', member_filter) app.connect('autodocsumm-grouper', group_member) app.setup_extension('sphinx.ext.napoleon') python-autodocsumm-0.2.14/tests/test-root/dummy.py000066400000000000000000000046641470544416500223100ustar00rootroot00000000000000""" Module for testing the autodocsumm Just a dummy module with some class definitions """ #: to test if the data is included test_data = None def test_func(): """Test if function is contained in autosummary""" pass class Class_CallTest(object): """A class defining a __call__ method""" def __get__(self, instance, owner): return self def __set__(self, instance, value): """Actually not required. We just implement it to ensure the python "help" function works well""" pass def __call__(self, a, b): """ Caller docstring for class attribute Parameters ---------- a: any dummy parameter b: anything else second dummy parameter""" pass class TestClass(object): """Class test for autosummary""" def __init__(self): #: This is an instance attribute self.instance_attribute = 1 def test_method(self): """Test if the method is included""" pass def test_method_args_kwargs(self, *args, **kwargs): """The stars at args and kwargs should not be escaped""" class InnerClass(object): """A test for an inner class""" #: to test if the class attribute is included test_attr = None class_caller = Class_CallTest() #: data to be included large_data = 'Should be included' #: data to be skipped small_data = 'Should be skipped' class TestException(Exception): """Exception test for autosummary""" def __init__(self): #: This is an exception attribute self.exception_instance_attribute = 1 def test_exception_method(self): """Test if the method is included""" pass class InheritedTestClass(TestClass): """Class test for inherited attributes""" class TestClassWithInlineAutoClassSumm: """Class test for the autodocsummary inline .. autoclasssumm:: TestClassWithInlineAutoClassSumm This is after the summary. """ def test_method_of_inline_test(self): """A test method.""" pass class TestClassWithRefToOtherClass: """Class test for the autodocsummary when a class attribute is a reference to another class. No autosummary of the class should be generated for the attribute. See also issue #69""" foo = TestClass #: data to be skipped large_data = 'Should also be skipped' #: data to be included small_data = 'Should also be included' python-autodocsumm-0.2.14/tests/test-root/dummy_submodule/000077500000000000000000000000001470544416500240035ustar00rootroot00000000000000python-autodocsumm-0.2.14/tests/test-root/dummy_submodule/__init__.py000066400000000000000000000000001470544416500261020ustar00rootroot00000000000000python-autodocsumm-0.2.14/tests/test-root/dummy_submodule/submodule1.py000066400000000000000000000002311470544416500264310ustar00rootroot00000000000000import dummy_submodule.submodule2 class SubmoduleClass1: """Docu for myclass 1""" def func1(self): """Docu for func 1""" pass python-autodocsumm-0.2.14/tests/test-root/dummy_submodule/submodule2.py000066400000000000000000000002311470544416500264320ustar00rootroot00000000000000import dummy_submodule.submodule1 class SubmoduleClass2: """Docu for myclass 1""" def func2(self): """Docu for func 1""" pass python-autodocsumm-0.2.14/tests/test-root/dummy_title.py000066400000000000000000000024621470544416500235030ustar00rootroot00000000000000""" Module for testing the autodocsumm ---------------------------------- Just a dummy module with some class definitions """ #: to test if the data is included test_data = None def test_func(): """Test if function is contained in autosummary""" pass class Class_CallTest(object): """A class defining a __call__ method""" def __get__(self, instance, owner): return self def __set__(self, instance, value): """Actually not required. We just implement it to ensure the python "help" function works well""" pass def __call__(self, a, b): """ Caller docstring for class attribute Parameters ---------- a: any dummy parameter b: anything else second dummy parameter""" pass class TestClass(object): """Class test for autosummary""" def test_method(self): """Test if the method is included""" pass #: to test if the class attribute is included test_attr = None class_caller = Class_CallTest() #: data to be included large_data = 'Should be included' #: data to be skipped small_data = 'Should be skipped' #: data to be skipped large_data = 'Should also be skipped' #: data to be included small_data = 'Should also be included' python-autodocsumm-0.2.14/tests/test-root/empty.py000066400000000000000000000002231470544416500222760ustar00rootroot00000000000000"""Empty module just to test if product is imported or not see https://github.com/Chilipp/autodocsumm/issues/32 """ from itertools import product python-autodocsumm-0.2.14/tests/test-root/index.rst000066400000000000000000000007501470544416500224340ustar00rootroot00000000000000Example documentation ===================== .. toctree:: test_module test_module_summary_only test_module_exclude_members test_class test_class_order test_class_summary_only test_inherited test_module_title test_module_no_nesting test_autoclasssumm test_autoclasssumm_some_sections test_autoclasssumm_no_titles test_automodulesumm test_automodulesumm_some_sections test_empty test_class_submodule test_module_submodulepython-autodocsumm-0.2.14/tests/test-root/test_autoclasssumm.rst000066400000000000000000000001361470544416500252620ustar00rootroot00000000000000Autoclasssumm of Dummy Class ============================ .. autoclasssumm:: dummy.TestClass python-autodocsumm-0.2.14/tests/test-root/test_autoclasssumm_inline.rst000066400000000000000000000001771470544416500266250ustar00rootroot00000000000000Inline Autoclasssumm of Dummy Class =================================== .. autoclass:: dummy.TestClassWithInlineAutoClassSumm python-autodocsumm-0.2.14/tests/test-root/test_autoclasssumm_no_titles.rst000066400000000000000000000002501470544416500273370ustar00rootroot00000000000000Autoclasssumm of Dummy Class without section titles =================================================== .. autoclasssumm:: dummy.TestClass :autosummary-no-titles: python-autodocsumm-0.2.14/tests/test-root/test_autoclasssumm_nosignatures.rst000066400000000000000000000003161470544416500300630ustar00rootroot00000000000000Autoclasssumm of Dummy Class without signatures =============================================== .. autoclasssumm:: dummy.TestClass :no-members: :autosummary-members: :autosummary-nosignatures: python-autodocsumm-0.2.14/tests/test-root/test_autoclasssumm_some_sections.rst000066400000000000000000000003041470544416500302110ustar00rootroot00000000000000Autoclasssumm of Dummy Class with some sections only ==================================================== .. autoclasssumm:: dummy.TestClass :autosummary-sections: Attributes ;; DummySection python-autodocsumm-0.2.14/tests/test-root/test_autoexceptionsumm.rst000066400000000000000000000001661470544416500261560ustar00rootroot00000000000000Autoexceptionsumm of Dummy Exception ==================================== .. autoexceptionsumm:: dummy.TestException python-autodocsumm-0.2.14/tests/test-root/test_automodulesumm.rst000066400000000000000000000001431470544416500254400ustar00rootroot00000000000000Automodulesumm of dummy test module =================================== .. automodulesumm:: dummy python-autodocsumm-0.2.14/tests/test-root/test_automodulesumm_nosignatures.rst000066400000000000000000000003231470544416500302410ustar00rootroot00000000000000Automodulesumm of dummy test module without signatures ====================================================== .. automodulesumm:: dummy :no-members: :autosummary-members: :autosummary-nosignatures: python-autodocsumm-0.2.14/tests/test-root/test_automodulesumm_some_sections.rst000066400000000000000000000003001470544416500303650ustar00rootroot00000000000000Automodulesumm of dummy test module with some sections only =========================================================== .. automodulesumm:: dummy :autosummary-sections: Data ;; Functions python-autodocsumm-0.2.14/tests/test-root/test_class.rst000066400000000000000000000000771470544416500234730ustar00rootroot00000000000000Dummy Class Doc =============== .. autoclass:: dummy.TestClasspython-autodocsumm-0.2.14/tests/test-root/test_class_nosignatures.rst000066400000000000000000000002601470544416500262660ustar00rootroot00000000000000Dummy Class Doc without signatures ================================== .. autoclass:: dummy.TestClass :no-members: :autosummary-members: :autosummary-nosignatures: python-autodocsumm-0.2.14/tests/test-root/test_class_order.rst000066400000000000000000000001331470544416500246570ustar00rootroot00000000000000Dummy Class Doc =============== .. autoclass:: dummy.TestClass :member-order: bysourcepython-autodocsumm-0.2.14/tests/test-root/test_class_submodule.rst000066400000000000000000000002351470544416500255460ustar00rootroot00000000000000Test if links in summary are correctly generated ================================================ .. autoclass:: dummy_submodule.submodule1.SubmoduleClass1 python-autodocsumm-0.2.14/tests/test-root/test_class_summary_only.rst000066400000000000000000000002111470544416500262770ustar00rootroot00000000000000Dummy Class Doc with summary only ================================= .. autoclass:: dummy.TestClass :no-members: :autosummary-members: python-autodocsumm-0.2.14/tests/test-root/test_class_with_ref_to_other_class.rst000066400000000000000000000002151470544416500304440ustar00rootroot00000000000000Autoclasssumm of Dummy Class ============================ .. autoclass:: dummy.TestClassWithRefToOtherClass :members: :autosummary: python-autodocsumm-0.2.14/tests/test-root/test_empty.rst000066400000000000000000000002051470544416500235150ustar00rootroot00000000000000Test of empty module ==================== see https://github.com/Chilipp/autodocsumm/issues/32 .. automodule:: empty :members: python-autodocsumm-0.2.14/tests/test-root/test_exception.rst000066400000000000000000000001171470544416500243570ustar00rootroot00000000000000Dummy Exception Doc =================== .. autoexception:: dummy.TestExceptionpython-autodocsumm-0.2.14/tests/test-root/test_inherited.rst000066400000000000000000000001621470544416500243340ustar00rootroot00000000000000Dummy Inherited Class Doc ========================= .. autoclass:: dummy.InheritedTestClass :inherited-members: python-autodocsumm-0.2.14/tests/test-root/test_module.rst000066400000000000000000000001131470544416500236420ustar00rootroot00000000000000Docs of dummy test module ========================= .. automodule:: dummy python-autodocsumm-0.2.14/tests/test-root/test_module_exclude_members.rst000066400000000000000000000002351470544416500270720ustar00rootroot00000000000000Docs of dummy test without some members ======================================= .. automodule:: dummy :autosummary-exclude-members: InheritedTestClass, python-autodocsumm-0.2.14/tests/test-root/test_module_no_nesting.rst000066400000000000000000000002071470544416500260710ustar00rootroot00000000000000Docs of dummy test module without nesting ========================================= .. automodule:: dummy :autosummary-no-nesting: python-autodocsumm-0.2.14/tests/test-root/test_module_nosignatures.rst000066400000000000000000000002731470544416500264520ustar00rootroot00000000000000Docs of dummy test module without signatures ============================================ .. automodule:: dummy :no-members: :autosummary-members: :autosummary-nosignatures: python-autodocsumm-0.2.14/tests/test-root/test_module_submodule.rst000066400000000000000000000002161470544416500257250ustar00rootroot00000000000000Test if links in summary are correctly generated ================================================ .. automodule:: dummy_submodule.submodule2 python-autodocsumm-0.2.14/tests/test-root/test_module_summary_only.rst000066400000000000000000000002241470544416500264630ustar00rootroot00000000000000Docs of dummy test module with summary only =========================================== .. automodule:: dummy :no-members: :autosummary-members: python-autodocsumm-0.2.14/tests/test-root/test_module_title.rst000066400000000000000000000001471470544416500250520ustar00rootroot00000000000000Docs of dummy test module with title ==================================== .. automodule:: dummy_title python-autodocsumm-0.2.14/tests/test_autodocsumm.py000066400000000000000000000452001470544416500226030ustar00rootroot00000000000000"""Test module for autodocsumm. **Disclaimer** Copyright 2016-2019, Philipp S. Sommer Copyright 2020-2021, Helmholtz-Zentrum Hereon Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pathlib import Path import re import bs4 import pytest import sphinx from autodocsumm import sphinx_version def in_between(full, sub, s0, *others): i0 = full.index(s0) try: last = min(filter(lambda i: i > i0, map(full.index, others))) except ValueError: # empty sequence last = len(full) return full.index(sub) > i0 and full.index(sub) < last def get_html(app, fname): return (Path(app.outdir) / fname).read_text() def get_soup(app, fname): return bs4.BeautifulSoup(get_html(app, fname), 'html.parser') def in_autosummary(what, html) -> bool: soup = bs4.BeautifulSoup(html, "html.parser") return any(tag.find_all("span", string=what) for tag in soup("table")) class TestAutosummaryDocumenter: def test_module(self, app): app.build() html = get_html(app, 'test_module.html') assert in_autosummary("TestClass", html) assert in_autosummary("test_func", html) assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) # test whether the right objects are included assert in_autosummary("class_caller", html) assert 'Caller docstring for class attribute' in html # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) try: assert 'Should be included' in html except AssertionError: # sphinx>=3.5 assert ( '\'Should ' 'be ' 'included\'' ) in html assert ( '\'Should ' 'be ' 'skipped\'' ) not in html else: assert 'Should be skipped' not in html try: assert 'Should also be included' in html except AssertionError: # sphinx>=3.5 assert ( '\'Should ' 'also ' 'be ' 'included\'' ) in html assert ( '\'Should ' 'also ' 'be ' 'skipped\'' ) not in html else: assert 'Should also be skipped' not in html def test_module_no_nesting(self, app): app.build() html = get_html(app, 'test_module_no_nesting.html') assert in_autosummary("TestClass", html) assert in_autosummary("test_func", html) # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) # test that elements of TestClass are not autosummarized, # since nesting is disabled. assert not in_autosummary("test_method", html) assert not in_autosummary("test_attr", html) # test the members are still displayed assert re.search( r'', html, ) def test_module_summary_only(self, app): app.build() html = get_html(app, 'test_module_summary_only.html') assert in_autosummary("TestClass", html) assert in_autosummary("test_func", html) # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) assert not re.search( r'', html, ) def test_module_with_title(self, app): app.build() html = get_html(app, 'test_module_title.html') assert in_autosummary("TestClass", html) assert in_autosummary("test_func", html) assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) # test whether the right objects are included assert in_autosummary("class_caller", html) assert 'Caller docstring for class attribute' in html # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) try: assert 'Should be included' in html except AssertionError: # sphinx>=3.5 assert ( '\'Should ' 'be ' 'included\'' ) in html assert ( '\'Should ' 'be ' 'skipped\'' ) not in html else: assert 'Should be skipped' not in html try: assert 'Should also be included' in html except AssertionError: # sphinx>=3.5 assert ( '\'Should ' 'also ' 'be ' 'included\'' ) in html assert ( '\'Should ' 'also ' 'be ' 'skipped\'' ) not in html else: assert 'Should also be skipped' not in html def test_module_nosignatures(self, app): app.build() html = get_html(app, 'test_module_nosignatures.html') assert in_autosummary("TestClass", html) assert in_autosummary("test_func", html) # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) assert not re.search( r'', html, ) assert '()' not in html def test_class(self, app): app.build() html = get_html(app, 'test_class.html') if sphinx_version[:2] > [3, 1]: assert in_autosummary("instance_attribute", html) elif sphinx_version[:2] < [3, 1]: assert in_autosummary("TestClass.instance_attribute", html) assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) # test escaping of * assert r'\*args' not in html assert r', \*\*kwargs' not in html assert '*args' in html assert '**kwargs' in html # test whether the right objects are included assert in_autosummary("class_caller", html) assert 'Caller docstring for class attribute' in html # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) assert 'Should be skipped' not in html try: assert 'Should be included' in html except AssertionError: # sphinx>=3.5 assert ( '\'Should ' 'be ' 'included\'' ) in html assert 'DummySection' in html assert in_between( html, 'class_caller', 'DummySection', 'Attributes', 'Methods' ), 'class_caller Attribute not in the right Section!' # check if the InnerClass is in the Classes section (which ends with # the DummySection) assert in_between( html, 'InnerClass', 'Classes', 'DummySection' ) def test_exception(self, app): app.build() html = get_html(app, 'test_exception.html') if sphinx_version[:2] > [3, 1]: assert in_autosummary("exception_instance_attribute", html) elif sphinx_version[:2] < [3, 1]: assert in_autosummary("TestException.exception_instance_attribute", html) assert in_autosummary("test_exception_method", html) @pytest.mark.skipif( sphinx_version[:2] < [3, 1], reason="Only available for sphinx>=3" ) def test_class_order(self, app): app.build() html = get_html(app, 'test_class_order.html') if sphinx_version[:2] > [3, 1]: assert in_autosummary("instance_attribute", html) elif sphinx_version[:2] < [3, 1]: assert in_autosummary("TestClass.instance_attribute", html) assert in_autosummary("test_attr", html) assert in_autosummary("large_data", html) assert ( html.index('test_attr') < html.index('large_data') ) def test_class_summary_only(self, app): app.build() html = get_html(app, 'test_class_summary_only.html') if sphinx_version[:2] > [3, 1]: assert in_autosummary("instance_attribute", html) elif sphinx_version[:2] < [3, 1]: assert in_autosummary("TestClass.instance_attribute", html) assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) # test whether the right objects are included assert in_autosummary("class_caller", html) # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) assert not re.search( r'', html, ) def test_class_nosignatures(self, app): app.build() html = get_html(app, 'test_class_nosignatures.html') if sphinx_version[:2] > [3, 1]: assert in_autosummary("instance_attribute", html) elif sphinx_version[:2] < [3, 1]: assert in_autosummary("TestClass.instance_attribute", html) assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) # test whether the right objects are included assert in_autosummary("class_caller", html) # test whether the data is shown correctly assert in_autosummary("large_data", html) assert in_autosummary("small_data", html) assert not re.search( r'', html, ) assert '()' not in html def test_class_no_summary_for_reference_to_class(self, app): # see also: issue #69 app.build() html = get_html(app, 'test_class_with_ref_to_other_class.html') # assert that the class itself has an autosummary that contains its # attributes assert in_autosummary("foo", html) # Assert that there is no autosummary of the attribute that is an alias # of another class. This autosummary would contain attrs/methods/... # of the referenced class. assert not in_autosummary("test_method", html) assert not in_autosummary("test_attr", html) def test_inherited(self, app): app.build() html = get_html(app, 'test_inherited.html') assert in_autosummary("test_method", html) @pytest.mark.xfail def test_warnings_depreciation(self, app): with pytest.warns( sphinx.deprecation.RemovedInSphinx40Warning, r'(?s).*Autosummary.warnings', ): app.build() def test_autoclasssumm_inline(self, app): """Test an AutoDocSummDirective inline.""" app.build() html = get_html(app, 'test_autoclasssumm_inline.html') methods_title = "Methods:" num_section_findings = len(re.findall(methods_title, html)) assert num_section_findings == 1 methods_start = html.index(methods_title) docstring_end = html.index("This is after the summary") assert docstring_end > methods_start def test_class_submodule(self, app): app.build() html = get_html(app, 'test_class_submodule.html') # check that hyperlink for instance method exists in summary table assert re.findall(r'.*href="#dummy_submodule\.submodule1' r'\.SubmoduleClass1\.func1".*', html) def test_module_submodule(self, app): app.build() html = get_html(app, 'test_module_submodule.html') # check that hyperlink for class exists in summary table assert re.findall(r'.*href="#dummy_submodule\.submodule2' r'\.SubmoduleClass2".*', html) # check that hyperlink for instance method exists in summary table assert re.findall(r'.*href="#dummy_submodule\.submodule2' r'\.SubmoduleClass2\.func2".*', html) def test_sorted_sections(self, app): soup = get_soup(app, 'test_autoclasssumm_some_sections.html') sections = soup.select("p strong") assert [s.string[:-1] for s in sections] == ["Attributes", "DummySection"] class TestAutoDocSummDirective: """Test case for the :class:`autodocsumm.AutoDocSummDirective`.""" def test_autoclasssumm(self, app): """Test building the autosummary of a class.""" app.build() html = get_html(app, 'test_autoclasssumm.html') # the class docstring must not be in the html assert "Class test for autosummary" not in html # test if the methods and attributes are there in a table assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) def test_autoexceptionsumm(self, app): """Test building the autosummary of a class.""" app.build() html = get_html(app, 'test_autoexceptionsumm.html') # the class docstring must not be in the html assert "Class exception for autosummary" not in html # test if the methods and attributes are there in a table assert in_autosummary("test_exception_method", html) assert in_autosummary("exception_instance_attribute", html) def test_autoclasssumm_no_titles(self, app): """Test building the autosummary of a class.""" app.build() html = get_html(app, 'test_autoclasssumm_no_titles.html') # the class docstring must not be in the html assert "Class test for autosummary" not in html # test if the methods and attributes are there in a table assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) assert "Methods" not in html def test_autoclasssumm_some_sections(self, app): """Test building the autosummary of a class with some sections only.""" app.build() html = get_html(app, 'test_autoclasssumm_some_sections.html') # the class docstring must not be in the html assert "Class test for autosummary" not in html # test if the methods and attributes are there in a table assert not in_autosummary("test_method", html) assert in_autosummary("class_caller", html) assert in_autosummary("test_attr", html) def test_autoclasssumm_nosignatures(self, app): """Test building the autosummary of a class without signatures.""" app.build() html = get_html(app, 'test_autoclasssumm_nosignatures.html') # the class docstring must not be in the html assert "Class test for autosummary" not in html # test if the methods and attributes are there in a table assert in_autosummary("test_method", html) assert in_autosummary("test_attr", html) assert '()' not in html def test_automodulesumm(self, app): """Test building the autosummary of a module.""" app.build() html = get_html(app, 'test_automodulesumm.html') # the class docstring must not be in the html assert "Module for testing the autodocsumm" not in html # test if the classes, data and functions are there in a table assert in_autosummary("Class_CallTest", html) assert in_autosummary("large_data", html) assert in_autosummary("test_func", html) def test_automodulesumm_some_sections(self, app): """Test building the autosummary of a module with some sections only.""" app.build() html = get_html(app, 'test_automodulesumm_some_sections.html') # the class docstring must not be in the html assert "Module for testing the autodocsumm" not in html # test if the classes, data and functions are there in a table assert not in_autosummary("Class_CallTest", html) assert in_autosummary("large_data", html) assert in_autosummary("test_func", html) def test_automodulesumm_nosignatures(self, app): """Test building the autosummary of a module without signatures.""" app.build() html = get_html(app, 'test_automodulesumm_nosignatures.html') # the class docstring must not be in the html assert "Module for testing the autodocsumm" not in html # test if the classes, data and functions are there in a table assert in_autosummary("Class_CallTest", html) assert in_autosummary("large_data", html) assert in_autosummary("test_func", html) assert '()' not in html def test_automodulesumm_exclude_members(self, app): """Test building the autosummary of a module with some members excluded from the autosummary.""" app.build() html = get_html(app, 'test_module_exclude_members.html') assert in_autosummary("TestClass", html) assert not in_autosummary("InheritedTestClass", html) def test_empty(self, app): app.build() html = get_html(app, 'test_empty.html') assert not in_autosummary("product", html)