Skip to content

Commit f8b36bb

Browse files
authored
Merge pull request #17 from stevepiercy/sphinx-40-compat
Add Sphinx 4.0 compatibility, drop EOLed Pythons
2 parents 228bb3b + 8e0176c commit f8b36bb

File tree

12 files changed

+227
-84
lines changed

12 files changed

+227
-84
lines changed

.github/workflows/ci-tests.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and test
2+
3+
on:
4+
# Build on pushes to master
5+
push:
6+
branches:
7+
- master
8+
# Temporarily add for CI on stevepiercy's fork
9+
- sphinx-40-compat
10+
tags:
11+
# Build pull requests
12+
pull_request:
13+
14+
jobs:
15+
test:
16+
strategy:
17+
# We want to see all failures:
18+
fail-fast: false
19+
matrix:
20+
py:
21+
- "3.6"
22+
- "3.7"
23+
- "3.8"
24+
- "3.9"
25+
- "3.10"
26+
- "pypy-3.7"
27+
os:
28+
- "ubuntu-latest"
29+
- "windows-latest"
30+
- "macos-latest"
31+
architecture:
32+
- x64
33+
- x86
34+
35+
exclude:
36+
# Linux and macOS don't have x86 python
37+
- os: "ubuntu-latest"
38+
architecture: x86
39+
- os: "macos-latest"
40+
architecture: x86
41+
# PyPy3 on Windows doesn't seem to work
42+
- os: "windows-latest"
43+
py: "pypy-3.7"
44+
45+
name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}"
46+
runs-on: ${{ matrix.os }}
47+
steps:
48+
- uses: actions/checkout@v2
49+
- name: Setup Python
50+
uses: actions/setup-python@v2
51+
with:
52+
python-version: ${{ matrix.py }}
53+
architecture: ${{ matrix.architecture }}
54+
- run: pip install tox
55+
- name: Running tox
56+
run: tox -e py -- ${{ matrix.pytest-args }}
57+
# This block is temporarily commented out to speed up testing and until I add
58+
# a lint tox env.
59+
# lint:
60+
# runs-on: ubuntu-latest
61+
# name: Lint the package
62+
# steps:
63+
# - uses: actions/checkout@v2
64+
# - name: Setup python
65+
# uses: actions/setup-python@v2
66+
# with:
67+
# python-version: 3.10
68+
# architecture: x64
69+
# - run: pip install tox
70+
# - run: tox -e lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.pyc
33
*$py.class
44
.coverage
5+
build/
56
dist/
67
*~
78
.tox

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
language: python
22
sudo: false
33
python:
4-
- 2.7
5-
- 3.4
6-
- 3.5
7-
- pypy
4+
- 3.6
5+
- 3.7
6+
- 3.8
7+
- 3.9
8+
- 3.10
9+
- pypy3
810
script:
911
- zope-testrunner --test-path=. --auto-color --auto-progress
1012

CHANGES.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
repoze.sphinx.autointerface Changelog
22
=====================================
33

4-
0.8.1 (unreleased)
4+
1.0.0 (unreleased)
55
------------------
66

7+
- Remove sphinx.util.force_decode. Previously we hacked it in to support Python
8+
2 and Sphinx 3.x, but Sphinx 4.0 deprecated it and dropped Python 2 support.
9+
10+
- Replace Travis-CI with GitHub Actions
11+
12+
- Add support for Python 3.6, 3.7, 3.8, 3.9, 3.10, and PyPy3.
13+
14+
- Drop support for Python 2.7, 3.3, 3.4, 3.5, and PyPy.
15+
716
- Update to work with newer Sphinx versions:
817
* Sphinx.domains -> Sphinx.registry.domains
918
* Sphinx.override_domain(D) -> Sphinx.add_domain(D, override=True)

CONTRIBUTORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,5 @@ Contributors
105105

106106
- Tres Seaver, 2011/03/22
107107
- Jason Madden, 2013/01/10
108+
- Steve Piercy, 2021/05/11
109+

MANIFEST.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
graft repoze
2+
3+
include README.rst
4+
include CHANGES.rst
5+
include CONTRIBUTORS.txt LICENSE.txt COPYRIGHT.txt
6+
7+
include tox.ini .travis.yml
8+
include TODO.txt
9+
graft .github
10+
11+
global-exclude __pycache__ *.py[cod]
12+
global-exclude .DS_Store

README.rst

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,68 @@
11
repoze.sphinx.autointerface README
22
==================================
33

4-
.. image:: https://travis-ci.org/repoze/repoze.sphinx.autointerface.png?branch=master
5-
:target: https://travis-ci.org/repoze/repoze.sphinx.autointerface
4+
.. image:: https://github.com/repoze/repoze.sphinx.autointerface/actions/workflows/ci-tests.yml/badge.svg
5+
:target: https://github.com/repoze/repoze.sphinx.autointerface/actions/workflows/ci-tests.yml
66

77
.. image:: https://img.shields.io/pypi/v/repoze.sphinx.autointerface.svg
8-
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
8+
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
99

1010
.. image:: https://img.shields.io/pypi/pyversions/repoze.sphinx.autointerface.svg
11-
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
11+
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface
12+
1213

1314
Overview
1415
--------
1516

1617
Thie package defines an extension for the
17-
`Sphinx <http://sphinx.pocool.org>`_ documentation system. The extension
18-
allows generation of API documentation by introspection of
19-
`zope.interface <http://pypi.python.org/pypi/zope.interface>`_ instances in
18+
`Sphinx <https://www.sphinx-doc.org/en/master/>`_ documentation system.
19+
The extension allows generation of API documentation by introspection of
20+
`zope.interface <https://pypi.org/project/zope.interface/>`_ instances in
2021
code.
2122

2223

2324
Installation
2425
------------
2526

26-
Install via `easy_install
27-
<http://peak.telecommunity.com/DevCenter/EasyInstall>`_::
27+
Install via ``pip``:
2828

29-
$ bin/easy_install repoze.sphinx.autointerface
29+
.. code-block:: bash
3030
31-
or any other means which gets the package on your ``PYTHONPATH``.
31+
pip install repoze.sphinx.autointerface
3232
3333
3434
Registering the Extension
3535
-------------------------
3636

3737
Add ``repoze.sphinx.autointerface`` to the ``extensions`` list in the
38-
``conf.py`` of the Sphinx documentation for your product. E.g.::
38+
``conf.py`` of the Sphinx documentation for your product.
39+
40+
.. code-block:: python
3941
40-
extensions = ['sphinx.ext.autodoc',
41-
'sphinx.ext.doctest',
42-
'repoze.sphinx.autointerface',
43-
]
42+
extensions = [
43+
"sphinx.ext.autodoc",
44+
"sphinx.ext.doctest",
45+
"repoze.sphinx.autointerface",
46+
]
4447
4548
4649
Using the Extension
4750
-------------------
4851

49-
At appropriate points in your document, call out the interface
50-
autodocs via::
52+
At appropriate points in your document, call out the autodoc interface.
53+
54+
.. code-block:: rst
5155
52-
.. autointerface:: yourpackage.interfaces.IFoo
56+
.. autointerface:: yourpackage.interfaces.IFoo
5357
5458
Output from the directive includes
5559

5660
- the fully-qualified interface name
5761
- any base interfaces
58-
- the doctstring from the interface, rendered as reSTX.
59-
- the members of the interface (methods and attributes).
62+
- the docstring from the interface, rendered as reStructuredText
63+
- the members of the interface (methods and attributes)
6064

6165
* For each attribute, the output includes the attribute name
6266
and its description.
6367
* For each method, the output includes the method name, its signature,
64-
and its docstring (also rendered as reSTX).
68+
and its docstring (also rendered as reStructuredText).

repoze/sphinx/autointerface.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
from zope.interface.interface import InterfaceClass
99

1010

11-
if sys.version_info < (3,):
12-
from sphinx.util import force_decode
13-
else:
14-
def force_decode(s, encoding):
15-
return s
16-
17-
1811
class InterfaceDesc(PyClasslike):
1912
def get_index_text(self, modname, name_cls):
2013
return '%s (interface in %s)' % (name_cls[0], modname)
@@ -95,7 +88,7 @@ def keyfunc(entry):
9588
self.add_line(u'', '<autointerface>')
9689
self.indent += self.content_indent
9790
sourcename = u'docstring of %s.%s' % (self.fullname, name)
98-
docstrings = [prepare_docstring(force_decode(doc, None))]
91+
docstrings = [prepare_docstring(doc)]
9992
for i, line in enumerate(self.process_doc(docstrings)):
10093
self.add_line(line, sourcename, i)
10194
self.add_line(u'', '<autointerface>')

repoze/sphinx/tests/test_autointerface.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .util import TestApp
44

55
from .. import autointerface
6-
from sphinx.ext.autodoc import AutoDirective, ALL
6+
from sphinx.ext.autodoc import ALL
77

88
from docutils.statemachine import ViewList
99

@@ -21,7 +21,7 @@ def smoothTheDinglebop(schleem):
2121
The schleem is then repurposed.
2222
"""
2323

24-
class Options(object):
24+
class Options(dict):
2525
inherited_members = False
2626
undoc_members = False
2727
private_members = False
@@ -38,18 +38,40 @@ class Options(object):
3838
exclude_members = ()
3939

4040
def __init__(self):
41+
super(Options, self).__init__()
4142
self.exclude_members = set()
4243
self.members = []
44+
self.__dict__ = self
45+
46+
class Settings(object):
47+
48+
tab_width = 4
49+
50+
51+
class Document(object):
52+
53+
def __init__(self, settings):
54+
self.settings = settings
55+
56+
57+
class State(object):
58+
59+
def __init__(self, document):
60+
self.document = document
61+
4362

4463
class Directive(object):
4564
env = None
4665
genopt = None
4766
result = None
67+
record_dependencies = None
4868

4969
def __init__(self):
5070
self._warnings = []
5171
self.filename_set = set()
5272
self.result = ViewList()
73+
self.record_dependencies = set()
74+
self.state = State(Document(Settings()))
5375

5476
def warn(self, msg):
5577
self._warnings.append(msg)
@@ -77,7 +99,7 @@ def assertResultContains(self, item,
7799
objtype='interface', name='repoze.sphinx.tests.test_autointerface.IPlumbusMaker',
78100
**kw):
79101
directive = self.directive
80-
inst = AutoDirective._registry[objtype](directive, name)
102+
inst = self.app.registry.documenters['interface'](directive, name)
81103
inst.generate(**kw)
82104
# print '\n'.join(directive.result)
83105
self.assertEqual([], directive._warnings)

repoze/sphinx/tests/util.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import tempfile
44
import shutil
55

6-
from six import StringIO
6+
from io import StringIO
77

88
from sphinx import application
99
from sphinx.builders.latex import LaTeXBuilder
10-
from sphinx.theming import Theme
11-
from sphinx.ext.autodoc import AutoDirective
1210
from sphinx.pycode import ModuleAnalyzer
1311

1412
from docutils import nodes
@@ -98,8 +96,6 @@ def __init__(self, buildername='html', testroot=None, srcdir=None,
9896

9997
def cleanup(self, doctrees=False):
10098
shutil.rmtree(self.__tempdir)
101-
Theme.themes.clear()
102-
AutoDirective._registry.clear()
10399
ModuleAnalyzer.cache.clear()
104100
LaTeXBuilder.usepackages = []
105101
sys.path[:] = self._saved_path

0 commit comments

Comments
 (0)