pax_global_header 0000666 0000000 0000000 00000000064 15176144365 0014526 g ustar 00root root 0000000 0000000 52 comment=ba8f7f26df46250ee8408c621c423de1e1b2327b
repoze-repoze.sphinx.autointerface-af7340e/ 0000775 0000000 0000000 00000000000 15176144365 0021107 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/.github/ 0000775 0000000 0000000 00000000000 15176144365 0022447 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/.github/workflows/ 0000775 0000000 0000000 00000000000 15176144365 0024504 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/.github/workflows/ci-tests.yml 0000664 0000000 0000000 00000002430 15176144365 0026761 0 ustar 00root root 0000000 0000000 name: Build and test
on:
# Build on pushes to master
push:
branches:
- master
# Temporarily add for CI on stevepiercy's fork
- sphinx-40-compat
tags:
# Build pull requests
pull_request:
jobs:
test:
strategy:
fail-fast: true
matrix:
py:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "pypy-3.11"
os:
- "ubuntu-latest"
name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
architecture: ${{ matrix.architecture }}
- run: pip install tox
- name: Running tox
run: tox -e py -- ${{ matrix.pytest-args }}
# This block is temporarily commented out to speed up testing and until I add
# a lint tox env.
# lint:
# runs-on: ubuntu-latest
# name: Lint the package
# steps:
# - uses: actions/checkout@v2
# - name: Setup python
# uses: actions/setup-python@v2
# with:
# python-version: 3.10
# architecture: x64
# - run: pip install tox
# - run: tox -e lint
repoze-repoze.sphinx.autointerface-af7340e/.github/workflows/pypi.yaml 0000664 0000000 0000000 00000001141 15176144365 0026346 0 ustar 00root root 0000000 0000000 name: Build & publish to pypi
on:
release:
types: [published]
workflow_dispatch:
jobs:
release-to-pypi:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Build soliplex
run: uv build --sdist --wheel
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
repoze-repoze.sphinx.autointerface-af7340e/.gitignore 0000664 0000000 0000000 00000000101 15176144365 0023067 0 ustar 00root root 0000000 0000000 *.egg-info
*.pyc
*$py.class
.coverage
build/
dist/
*~
.tox
env*/
repoze-repoze.sphinx.autointerface-af7340e/CHANGES.rst 0000664 0000000 0000000 00000005746 15176144365 0022725 0 ustar 00root root 0000000 0000000 repoze.sphinx.autointerface Changelog
=====================================
1.1.0 (2026-05-04)
------------------
- Drop ``pkg_resources`` namespace support.
- Move package metadata to ``pyproject.toml``.
- Move to ``src/`` layout, with ``tests/unit/`` at top level.
- Add support for Python 3.11 - 3.14.
- Drop support for Python <= 3.9
1.0.0 (2022-05-26)
------------------
- Remove sphinx.util.force_decode. Previously we hacked it in to support Python
2 and Sphinx 3.x, but Sphinx 4.0 deprecated it and dropped Python 2 support.
- Replace Travis-CI with GitHub Actions
- Add support for Python 3.6, 3.7, 3.8, 3.9, 3.10, and PyPy3.
- Drop support for Python 2.7, 3.3, 3.4, 3.5, and PyPy.
- Update to work with newer Sphinx versions:
* Sphinx.domains -> Sphinx.registry.domains
* Sphinx.override_domain(D) -> Sphinx.add_domain(D, override=True)
- Drop support for Sphinx < 4.0.
0.8 (2016-03-28)
----------------
- Add support for Python 3.3, 3.4, and 3.5.
- Drop support for Python 2.6 and 3.2.
- Allow cross references using the ``:class:`` directive to use the
``.`` for "fuzzy" searching. Thanks to Jason Madden for the patch.
0.7.1 (2012-09-15)
------------------
- Remove ``setup.py`` dependency on ``ez_setup.py``.
0.7.0 (2012-06-20)
------------------
- PyPy compatibility.
- Python 3.2+ compatibility. Thanks to Arfrever for the patch.
- Include interface docs under the ``automodule`` directive. Thanks to
Krys Lawrence for the patch.
0.6.2 (2011-02-13)
------------------
- Fix ``TypeError: 'NoneType' object is not iterable`` error when generating
a rendering of an interface under Python 2.7.
0.6.1 (2011-01-28)
------------------
- Fix ':member-order: bysource' handling.
0.6 (2011-01-28)
----------------
- Correctly handle ':members:' values explicitly set in the directive.
0.5 (2011-01-18)
----------------
- Added support for the ':member-order:' flag, which can take one of the
three stock values, "alphabetical", "groupwise", or "bysource". By
default, members are documented in "hash" order.
0.4 (2010-07-26)
----------------
- Fixed compatibility with Sphinx 1.0
- Un-break PyPI ReST/HTML-rendering again.
0.3 (2009-10-25)
----------------
- Refactor sphinx integration. There are now separate ``autointerface``
and ``interface`` directives.
0.2.1 (2009-08-20)
------------------
- Fix add_directive arguments to work with Sphinx 0.6.1, now required.
0.1.3 (2009-01-14)
------------------
- Coerce unicode path elements to str in ``_resolve_dotted_name``.
Note that non-ASCII path elements won't work: this fix just deals
with the case where the path was of type unicode.
- Fixed spelling of directive in README.txt.
- Added dependency on ``zope.interface``.
0.1.2 (2008-10-03)
------------------
- Packaging change: improved description in README.txt.
0.1.1 (2008-10-03)
------------------
- Packaging bug: the ``long_description`` was not rendering properly to
HTML on PyPI.
0.1 (2008-10-02)
----------------
- Initial release.
repoze-repoze.sphinx.autointerface-af7340e/CONTRIBUTORS.txt 0000664 0000000 0000000 00000011116 15176144365 0023605 0 ustar 00root root 0000000 0000000 Repoze Project Contributor Agreement
====================================
The submitter agrees by adding his or her name within the section below named
"Contributors" and submitting the resulting modified document to the
canonical shared repository location for this software project (whether
directly, as a user with "direct commit access", or via a "pull request"), he
or she is signing a contract electronically. The submitter becomes a
Contributor after a) he or she signs this document by adding their name
beneath the "Contributors" section below, and b) the resulting document is
accepted into the canonical version control repository.
Treatment of Account
---------------------
Contributor will not allow anyone other than the Contributor to use his or
her username or source repository login to submit code to a Repoze Project
source repository. Should Contributor become aware of any such use,
Contributor will immediately by notifying Agendaless Consulting.
Notification must be performed by sending an email to
webmaster@agendaless.com. Until such notice is received, Contributor will be
presumed to have taken all actions made through Contributor's account. If the
Contributor has direct commit access, Agendaless Consulting will have
complete control and discretion over capabilities assigned to Contributor's
account, and may disable Contributor's account for any reason at any time.
Legal Effect of Contribution
----------------------------
Upon submitting a change or new work to a Repoze Project source Repository (a
"Contribution"), you agree to assign, and hereby do assign, a one-half
interest of all right, title and interest in and to copyright and other
intellectual property rights with respect to your new and original portions
of the Contribution to Agendaless Consulting. You and Agendaless Consulting
each agree that the other shall be free to exercise any and all exclusive
rights in and to the Contribution, without accounting to one another,
including without limitation, the right to license the Contribution to others
under the Repoze Public License. This agreement shall run with title to the
Contribution. Agendaless Consulting does not convey to you any right, title
or interest in or to the Program or such portions of the Contribution that
were taken from the Program. Your transmission of a submission to the Repoze
Project source Repository and marks of identification concerning the
Contribution itself constitute your intent to contribute and your assignment
of the work in accordance with the provisions of this Agreement.
License Terms
-------------
Code committed to the Repoze Project source repository (Committed Code) must
be governed by the Repoze Public License (http://repoze.org/LICENSE.txt, aka
"the RPL") or another license acceptable to Agendaless Consulting. Until
Agendaless Consulting declares in writing an acceptable license other than
the RPL, only the RPL shall be used. A list of exceptions is detailed within
the "Licensing Exceptions" section of this document, if one exists.
Representations, Warranty, and Indemnification
----------------------------------------------
Contributor represents and warrants that the Committed Code does not violate
the rights of any person or entity, and that the Contributor has legal
authority to enter into this Agreement and legal authority over Contributed
Code. Further, Contributor indemnifies Agendaless Consulting against
violations.
Cryptography
------------
Contributor understands that cryptographic code may be subject to government
regulations with which Agendaless Consulting and/or entities using Committed
Code must comply. Any code which contains any of the items listed below must
not be checked-in until Agendaless Consulting staff has been notified and has
approved such contribution in writing.
- Cryptographic capabilities or features
- Calls to cryptographic features
- User interface elements which provide context relating to cryptography
- Code which may, under casual inspection, appear to be cryptographic.
Notices
-------
Contributor confirms that any notices required will be included in any
Committed Code.
Licensing Exceptions
====================
None.
List of Contributors
====================
The below-signed are contributors to a code repository that is part of the
project named "repoze.sphinx.autointerface".
Each below-signed contributor has read, understand and agrees to the terms
above in the section within this document entitled "Repoze Project Contributor
Agreement" as of the date beside his or her name.
Contributors
------------
- Tres Seaver, 2011/03/22
- Jason Madden, 2013/01/10
- Steve Piercy, 2021/05/11
repoze-repoze.sphinx.autointerface-af7340e/COPYRIGHT.txt 0000664 0000000 0000000 00000000155 15176144365 0023221 0 ustar 00root root 0000000 0000000 Copyright (c) 2008 Agendaless Consulting and Contributors.
(http://www.agendaless.com), All Rights Reserved
repoze-repoze.sphinx.autointerface-af7340e/LICENSE.txt 0000664 0000000 0000000 00000003377 15176144365 0022744 0 ustar 00root root 0000000 0000000 License
A copyright notice accompanies this license document that identifies
the copyright holders.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions in source code must retain the accompanying
copyright notice, this list of conditions, and the following
disclaimer.
2. Redistributions in binary form must reproduce the accompanying
copyright notice, this list of conditions, and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
3. Names of the copyright holders must not be used to endorse or
promote products derived from this software without prior
written permission from the copyright holders.
4. If any files are modified, you must cause the modified files to
carry prominent notices stating that you changed the files and
the date of any change.
Disclaimer
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
repoze-repoze.sphinx.autointerface-af7340e/MANIFEST.in 0000664 0000000 0000000 00000000343 15176144365 0022645 0 ustar 00root root 0000000 0000000 graft repoze
include README.rst
include CHANGES.rst
include CONTRIBUTORS.txt LICENSE.txt COPYRIGHT.txt
include tox.ini .travis.yml
include TODO.txt
graft .github
global-exclude __pycache__ *.py[cod]
global-exclude .DS_Store
repoze-repoze.sphinx.autointerface-af7340e/README.rst 0000664 0000000 0000000 00000003617 15176144365 0022605 0 ustar 00root root 0000000 0000000 repoze.sphinx.autointerface README
==================================
.. image:: https://github.com/repoze/repoze.sphinx.autointerface/actions/workflows/ci-tests.yml/badge.svg
:target: https://github.com/repoze/repoze.sphinx.autointerface/actions/workflows/ci-tests.yml
.. image:: https://img.shields.io/pypi/v/repoze.sphinx.autointerface.svg
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
.. image:: https://img.shields.io/pypi/pyversions/repoze.sphinx.autointerface.svg
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
Overview
--------
Thie package defines an extension for the
`Sphinx `_ documentation system.
The extension allows generation of API documentation by introspection of
`zope.interface `_ instances in
code.
Installation
------------
Install via ``pip``:
.. code-block:: bash
pip install repoze.sphinx.autointerface
Registering the Extension
-------------------------
Add ``repoze.sphinx.autointerface`` to the ``extensions`` list in the
``conf.py`` of the Sphinx documentation for your product.
.. code-block:: python
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"repoze.sphinx.autointerface",
]
Using the Extension
-------------------
At appropriate points in your document, call out the autodoc interface.
.. code-block:: rst
.. autointerface:: yourpackage.interfaces.IFoo
Output from the directive includes
- the fully-qualified interface name
- any base interfaces
- the docstring from the interface, rendered as reStructuredText
- the members of the interface (methods and attributes)
* For each attribute, the output includes the attribute name
and its description.
* For each method, the output includes the method name, its signature,
and its docstring (also rendered as reStructuredText).
repoze-repoze.sphinx.autointerface-af7340e/TODO.txt 0000664 0000000 0000000 00000000374 15176144365 0022421 0 ustar 00root root 0000000 0000000 repoze.sphinx.autointerface TODOs
=================================
- [X] Add an :interface: mode and corresponding directive.
- [_] Get our output to look more like that produced by '.. autoclass::'.
Probably blocks in the ':interface:' mode.
repoze-repoze.sphinx.autointerface-af7340e/pyproject.toml 0000664 0000000 0000000 00000005431 15176144365 0024026 0 ustar 00root root 0000000 0000000 [build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["src"]
[project]
name = "repoze-sphinx-autointerface"
version = "1.1.0"
description = "Sphinx extension: auto-generates API docs from Zope interfaces"
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">=3.10"
dependencies = [
"zope.interface",
"Sphinx >= 4.0",
]
authors = [
{name = "Tres Seaver, Agendaless Consulting", email = "tseaver@agendaless.com"},
]
license = "LicenseRef-Repoze-BSD-derived"
license-files = ["LICENSE.txt"]
keywords = ["web", "wsgi", "zope", "sphinx"]
classifiers = [
"Development Status :: 6 - Mature",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: OS Independent",
]
# Not supported by 'setuptools':
# import-namespaces = ["repoze"]
# import-names = ["repoze.sphinx""]
[project.urls]
Repository = "https://github.com/repoze/repoze.sphinx.autointerface"
Issues = "https://github.com/repoze/repoze.sphinx.autointerface/issues"
Documentation = "https://repozesphinxautointerface.readthedocs.io/en/stable/index.html"
Changelog = "https://github.com/repoze/repoze.sphinx.autointerface/blob/master/CHANGES.rst"
[project.entry-points."paste.filter_app_factory"]
retry = "repoze.retry:make_retry"
[dependency-groups]
dev = [
"tox",
"pytest",
"pytest-cov",
"ruff",
"check-manifest",
"build",
"twine",
]
[tool.setuptools]
include-package-data = true
[tool.pytest.ini_options]
pythonpath = "."
python_files = "test_*.py"
#minversion = "6.0"
testpaths = ["tests/unit"]
#addopts = "--cov=repoze.sphinx.autointerfae --cov=tests/unit --cov-branch --cov-fail-under=100"
[tool.coverage.run]
omit = []
[tool.coverage.report]
show_missing = true
[tool.ruff]
line-length = 79
exclude = [
]
target-version = "py314"
[tool.ruff.lint]
select = [
# flake8
"F",
# pycodestyle
"E",
# flake8-bugbear
"B",
# pyupgrade
"U",
# isort
"I",
# pandas vet
"PD",
# tryceratops
"TRY",
# flake8-pytest-style
"PT",
]
ignore = [
]
[tool.ruff.lint.isort]
force-single-line = true
[tool.ruff.lint.flake8-pytest-style]
parametrize-names-type = "csv"
[tool.check-manifest]
ignore = [
".gitignore",
".gitattributes",
"PKG-INFO",
"*.egg-info",
"*.egg-info/*",
"setup.cfg",
]
ignore-default-rules = true
repoze-repoze.sphinx.autointerface-af7340e/setup.py 0000664 0000000 0000000 00000001274 15176144365 0022625 0 ustar 00root root 0000000 0000000 ##############################################################################
#
# Copyright (c) 2008 Agendaless Consulting and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the BSD-like license at
# http://www.repoze.org/LICENSE.txt. A copy of the license should accompany
# this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL
# EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND
# FITNESS FOR A PARTICULAR PURPOSE
#
##############################################################################
from setuptools import setup
setup()
repoze-repoze.sphinx.autointerface-af7340e/src/ 0000775 0000000 0000000 00000000000 15176144365 0021676 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/src/repoze/ 0000775 0000000 0000000 00000000000 15176144365 0023202 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/src/repoze/sphinx/ 0000775 0000000 0000000 00000000000 15176144365 0024513 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/src/repoze/sphinx/autointerface.py 0000664 0000000 0000000 00000011434 15176144365 0027721 0 ustar 00root root 0000000 0000000
import sys
from sphinx.util.docstrings import prepare_docstring
from sphinx.domains.python import PyClasslike
from sphinx.ext import autodoc
from zope.interface import Interface
from zope.interface.interface import InterfaceClass
class InterfaceDesc(PyClasslike):
def get_index_text(self, modname, name_cls):
return '%s (interface in %s)' % (name_cls[0], modname)
class InterfaceDocumenter(autodoc.ClassDocumenter):
"""
Specialized Documenter directive for zope interfaces.
"""
objtype = "interface"
# Must be a higher priority than ClassDocumenter
member_order = 10
def __init__(self, *args, **kwargs):
super(InterfaceDocumenter, self).__init__(*args, **kwargs)
self.options.show_inheritance = True
@classmethod
def can_document_member(cls, member, membername, isattr, parent):
return isinstance(member, InterfaceClass)
def add_directive_header(self, sig):
if self.doc_as_attr:
self.directivetype = 'attribute'
autodoc.Documenter.add_directive_header(self, sig)
# add inheritance info, if wanted
bases = [base for base in self.object.__bases__
if base is not Interface]
if not self.doc_as_attr and self.options.show_inheritance and bases:
self.add_line(u'', '')
bases = [u':class:`%s.%s`' % (b.__module__, b.getName())
for b in bases]
self.add_line(u' Extends: %s' % ', '.join(bases),
'')
def format_args(self):
return ""
def document_members(self, all_members=True):
oldindent = self.indent
members = list(self.object.namesAndDescriptions())
if self.options.members is not autodoc.ALL:
specified = []
for line in (self.options.members or []):
specified.extend(line.split())
mapping = dict(members)
members = [(x, mapping[x]) for x in specified]
member_order = (self.options.member_order or
self.env.config.autodoc_member_order)
if member_order == 'alphabetical':
members.sort()
if member_order == 'groupwise':
# sort by group; relies on stable sort to keep items in the
# same group sorted alphabetically
members.sort(key=lambda e:
getattr(e[1], 'getSignatureString',
None) is not None)
elif member_order == 'bysource' and self.analyzer:
# sort by source order, by virtue of the module analyzer
tagorder = self.analyzer.tagorder
name = self.object.__name__
def keyfunc(entry):
return tagorder.get('%s.%s' % (name, entry[0]), len(tagorder))
members.sort(key=keyfunc)
for name, desc in members:
self.add_line(u'', '')
sig = getattr(desc, 'getSignatureString', None)
if sig is None:
self.add_line(u'.. attribute:: %s' % name, '')
else:
self.add_line(u'.. method:: %s%s' % (name, sig()),
'')
doc = desc.getDoc()
if doc:
self.add_line(u'', '')
self.indent += self.content_indent
sourcename = u'docstring of %s.%s' % (self.fullname, name)
docstrings = [prepare_docstring(doc)]
for i, line in enumerate(self.process_doc(docstrings)):
self.add_line(line, sourcename, i)
self.add_line(u'', '')
self.indent = oldindent
def setup(app):
app.add_directive_to_domain('py', 'interface', InterfaceDesc)
from sphinx.domains import ObjType
try:
domains = app.domains
except AttributeError:
domains = app.registry.domains
# Allow the :class: directive to xref interface objects through the search
# mechanism, i.e., prefixed with a '.', like :class:`.ITheInterface`
# (without this, an exact match is required)
class InterfacePythonDomain(domains['py']):
pass
InterfacePythonDomain.object_types = domains['py'].object_types.copy()
InterfacePythonDomain.object_types['interface'] = ObjType( 'interface', 'interface', 'obj', 'class')
old_class = InterfacePythonDomain.object_types['class']
new_class = ObjType( old_class.lname, *(old_class.roles + ('interface',)), **old_class.attrs )
InterfacePythonDomain.object_types['class'] = new_class
if hasattr(app, 'override_domain'):
app.override_domain( InterfacePythonDomain )
else:
app.add_domain( InterfacePythonDomain, override=True )
app.add_autodocumenter(InterfaceDocumenter)
repoze-repoze.sphinx.autointerface-af7340e/tests/ 0000775 0000000 0000000 00000000000 15176144365 0022251 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/tests/__init__.py 0000664 0000000 0000000 00000000011 15176144365 0024352 0 ustar 00root root 0000000 0000000 #package
repoze-repoze.sphinx.autointerface-af7340e/tests/unit/ 0000775 0000000 0000000 00000000000 15176144365 0023230 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/tests/unit/__init__.py 0000664 0000000 0000000 00000000000 15176144365 0025327 0 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/tests/unit/root/ 0000775 0000000 0000000 00000000000 15176144365 0024213 5 ustar 00root root 0000000 0000000 repoze-repoze.sphinx.autointerface-af7340e/tests/unit/root/conf.py 0000664 0000000 0000000 00000000044 15176144365 0025510 0 ustar 00root root 0000000 0000000 extensions = ['sphinx.ext.autodoc']
repoze-repoze.sphinx.autointerface-af7340e/tests/unit/test_autointerface.py 0000664 0000000 0000000 00000006205 15176144365 0027475 0 ustar 00root root 0000000 0000000 import unittest
from docutils.statemachine import ViewList
from sphinx.ext.autodoc import ALL
from zope import interface
from repoze.sphinx import autointerface
from .util import SphinxTestApp
class IPlumbusMaker(interface.Interface):
grumbo = interface.Attribute("The dinglebop is fed through here")
fleeb = interface.Attribute("The dinglebop is polished with this")
def smoothTheDinglebop(schleem):
"""Smooth it out
The schleem is then repurposed.
"""
class Options(dict):
inherited_members = False
undoc_members = False
private_members = False
special_members = False
imported_members = False
show_inheritance = False
noindex = False
no_index = False # FBO Sphinx 8.x
no_index_entry = False # FBO Sphinx 9.x
annotation = None
synopsis = ''
platform = ''
deprecated = False
members = ()
member_order = 'alphabetic'
exclude_members = ()
def __init__(self):
super(Options, self).__init__()
self.exclude_members = set()
self.members = []
self.__dict__ = self
class Settings(object):
tab_width = 4
class Document(object):
def __init__(self, settings):
self.settings = settings
class State(object):
def __init__(self, document):
self.document = document
class Directive(object):
env = None
genopt = None
result = None
record_dependencies = None
def __init__(self):
self._warnings = []
self.filename_set = set()
self.result = ViewList()
self.record_dependencies = set()
self.state = State(Document(Settings()))
def warn(self, msg):
self._warnings.append(msg)
class AutoInterfaceTests(unittest.TestCase):
def setUp(self):
app = self.app = SphinxTestApp()
app.builder.env.temp_data['docname'] = 'dummy'
autointerface.setup(app)
opt = self.options = Options()
d = self.directive = Directive()
d.env = app.builder.env
d.genopt = opt
def tearDown(self):
self.app.cleanup()
self.app = None
def assertResultContains(
self,
item,
objtype='interface',
name='tests.unit.test_autointerface.IPlumbusMaker',
**kw,
):
directive = self.directive
inst = self.app.registry.documenters['interface'](directive, name)
inst.generate(**kw)
# print '\n'.join(directive.result)
self.assertEqual([], directive._warnings)
self.assertIn(item, directive.result)
results = directive.result[:]
del directive.result[:]
return '\n'.join(results)
def test_restricted_members(self):
self.options.members = ['smoothTheDinglebop']
all_results = self.assertResultContains(
' .. method:: smoothTheDinglebop(schleem)'
)
self.assertNotIn('grumbo', all_results)
def test_all_members(self):
self.options.members = ALL
all_results = self.assertResultContains(
' .. method:: smoothTheDinglebop(schleem)'
)
self.assertIn('grumbo', all_results)
self.assertIn('fleeb', all_results)
repoze-repoze.sphinx.autointerface-af7340e/tests/unit/util.py 0000664 0000000 0000000 00000007703 15176144365 0024566 0 ustar 00root root 0000000 0000000 import sys
import os
import tempfile
import shutil
from io import StringIO
from docutils import nodes
from docutils.parsers.rst import directives, roles
from sphinx import application
from sphinx.builders.latex import LaTeXBuilder
from sphinx.pycode import ModuleAnalyzer
rootdir = os.path.abspath(os.path.dirname(__file__) or '.')
class ListOutput(object):
"""
File-like object that collects written text in a list.
"""
def __init__(self, name):
self.name = name
self.content = []
def reset(self):
del self.content[:]
def write(self, text):
self.content.append(text)
class SphinxTestApp(application.Sphinx):
"""
A subclass of :class:`Sphinx` that runs on the test root, with some
better default values for the initialization parameters.
"""
def __init__(
self,
buildername='html',
testroot=None,
srcdir=None,
freshenv=False,
confoverrides=None,
status=None,
warning=None,
tags=None,
docutilsconf=None,
):
if testroot is None:
defaultsrcdir = 'root'
testroot = os.path.join(rootdir, 'root')
else:
defaultsrcdir = 'test-' + testroot
testroot = os.path.join(rootdir, 'roots', ('test-' + testroot))
self.__tempdir = os.path.abspath(tempfile.mkdtemp())
if srcdir is None:
srcdir = os.path.join(self.__tempdir, defaultsrcdir)
else:
srcdir = os.path.join(self.__tempdir, srcdir)
if not os.path.exists(srcdir):
shutil.copytree(testroot, srcdir, symlinks=False)
if docutilsconf is not None:
with open(os.path.join(srcdir, 'docutils.conf')) as f:
f.write(docutilsconf)
builddir = os.path.join(srcdir, '_build')
# if confdir is None:
confdir = srcdir
# if outdir is None:
outdir = os.path.join(builddir, buildername)
if not os.path.exists(outdir):
os.makedirs(outdir)
doctreedir = os.path.join(builddir, 'doctrees')
if not os.path.exists(doctreedir):
os.makedirs(doctreedir)
if confoverrides is None:
confoverrides = {}
if status is None:
status = StringIO()
if warning is None:
warning = ListOutput('stderr')
# if warningiserror is None:
warningiserror = False
self._saved_path = sys.path[:]
self._saved_directives = directives._directives.copy()
self._saved_roles = roles._roles.copy()
self._saved_nodeclasses = set(
v for v in dir(nodes.GenericNodeVisitor)
if v.startswith('visit_')
)
try:
application.Sphinx.__init__(
self,
srcdir,
confdir,
outdir,
doctreedir,
buildername,
confoverrides,
status,
warning,
freshenv,
warningiserror,
tags,
)
except:
self.cleanup()
raise
def cleanup(self, doctrees=False):
shutil.rmtree(self.__tempdir)
ModuleAnalyzer.cache.clear()
LaTeXBuilder.usepackages = []
sys.path[:] = self._saved_path
sys.modules.pop('autodoc_fodder', None)
directives._directives = self._saved_directives
roles._roles = self._saved_roles
for method in dir(nodes.GenericNodeVisitor):
if (
method.startswith('visit_') and
method not in self._saved_nodeclasses
):
delattr(nodes.GenericNodeVisitor, 'visit_' + method[6:])
delattr(nodes.GenericNodeVisitor, 'depart_' + method[6:])
def __repr__(self):
klass_name = self.__class__.__name__
builder_name = self.builder.name
return f'<{klass_name} buildername={buildername:r}>'
repoze-repoze.sphinx.autointerface-af7340e/tox.ini 0000664 0000000 0000000 00000000205 15176144365 0022417 0 ustar 00root root 0000000 0000000 [tox]
envlist =
py3.10,py3.11,py3.12,py3.13,py3.14,pypy3.11
[testenv]
usedevelop = true
commands =
pytest
deps =
pytest