Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sphinx 4.0 compatibility, drop EOLed Pythons #17

Merged
merged 24 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
69cdfaf
Drop EOLed Pythons, add supported Pythons
stevepiercy May 11, 2021
ed4e178
DRY when setting README and CHANGES
stevepiercy May 11, 2021
7f5ad44
Add python_requires
stevepiercy May 16, 2021
bcd3931
Blackify
stevepiercy May 16, 2021
544b388
Add GitHub Actions
stevepiercy May 16, 2021
4413ab9
Remove optional author_email because it lacks an MX record and is pro…
stevepiercy May 16, 2021
3213650
Remove deprecated sphinx.util.force_decode
stevepiercy May 16, 2021
4e04ccc
Add change log entries
stevepiercy May 16, 2021
ca824fd
Replace six.StringIO with io.StringIO
stevepiercy May 16, 2021
1765c02
Temporarily add for CI on stevepiercy's fork on the branch sphinx-40-…
stevepiercy May 16, 2021
6b58256
Update badge for CI
stevepiercy May 16, 2021
f4a0b20
Update installation method
stevepiercy May 16, 2021
54e9b80
Add lint to tox
stevepiercy May 16, 2021
6f0f5b7
Fix warning about long_description_content_type
stevepiercy May 16, 2021
40eef0d
Break apart tox env lint into format and build, temporarily commentin…
stevepiercy May 16, 2021
1663057
Replace `setuptools` with `build` package
stevepiercy May 17, 2021
0ad316e
Fix compatibility with Sphinx 4 and 5b1.
May 17, 2022
8590958
Use an existing PyPy3 version.
May 18, 2022
ae7ce32
Merge pull request #1 from icemac/sphinx-40-compat
stevepiercy May 18, 2022
b02bd50
Attempt to jigger a test build.
stevepiercy May 18, 2022
9915e71
Restore Python 3.5 and add Python 3.10
stevepiercy May 18, 2022
23a32ab
Restore Python 3.5 and add Python 3.10
stevepiercy May 18, 2022
d9177c4
Revert restoration of Python 3.5
stevepiercy May 18, 2022
8e0176c
Change release number to 1.0.0
stevepiercy May 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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:
# We want to see all failures:
fail-fast: false
matrix:
py:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "pypy-3.7"
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
architecture:
- x64
- x86

exclude:
# Linux and macOS don't have x86 python
- os: "ubuntu-latest"
architecture: x86
- os: "macos-latest"
architecture: x86
# PyPy3 on Windows doesn't seem to work
- os: "windows-latest"
py: "pypy-3.7"

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.pyc
*$py.class
.coverage
build/
dist/
*~
.tox
Expand Down
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: python
sudo: false
python:
- 2.7
- 3.4
- 3.5
- pypy
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10
- pypy3
script:
- zope-testrunner --test-path=. --auto-color --auto-progress

Expand Down
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ repoze.sphinx.autointerface Changelog
0.8.1 (unreleased)
------------------

- 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)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ Contributors

- Tres Seaver, 2011/03/22
- Jason Madden, 2013/01/10
- Steve Piercy, 2021/05/11

12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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
48 changes: 26 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
repoze.sphinx.autointerface README
==================================

.. image:: https://travis-ci.org/repoze/repoze.sphinx.autointerface.png?branch=master
:target: https://travis-ci.org/repoze/repoze.sphinx.autointerface
.. 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
: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
:target: https://pypi.python.org/pypi/repoze.sphinx.autointerface


Overview
--------

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


Installation
------------

Install via `easy_install
<http://peak.telecommunity.com/DevCenter/EasyInstall>`_::
Install via ``pip``:

$ bin/easy_install repoze.sphinx.autointerface
.. code-block:: bash

or any other means which gets the package on your ``PYTHONPATH``.
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. E.g.::
``conf.py`` of the Sphinx documentation for your product.

.. code-block:: python

extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'repoze.sphinx.autointerface',
]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"repoze.sphinx.autointerface",
]


Using the Extension
-------------------

At appropriate points in your document, call out the interface
autodocs via::
At appropriate points in your document, call out the autodoc interface.

.. code-block:: rst

.. autointerface:: yourpackage.interfaces.IFoo
.. autointerface:: yourpackage.interfaces.IFoo

Output from the directive includes

- the fully-qualified interface name
- any base interfaces
- the doctstring from the interface, rendered as reSTX.
- the members of the interface (methods and attributes).
- 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 reSTX).
and its docstring (also rendered as reStructuredText).
9 changes: 1 addition & 8 deletions repoze/sphinx/autointerface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
from zope.interface.interface import InterfaceClass


if sys.version_info < (3,):
from sphinx.util import force_decode
else:
def force_decode(s, encoding):
return s


class InterfaceDesc(PyClasslike):
def get_index_text(self, modname, name_cls):
return '%s (interface in %s)' % (name_cls[0], modname)
Expand Down Expand Up @@ -95,7 +88,7 @@ def keyfunc(entry):
self.add_line(u'', '<autointerface>')
self.indent += self.content_indent
sourcename = u'docstring of %s.%s' % (self.fullname, name)
docstrings = [prepare_docstring(force_decode(doc, None))]
docstrings = [prepare_docstring(doc)]
for i, line in enumerate(self.process_doc(docstrings)):
self.add_line(line, sourcename, i)
self.add_line(u'', '<autointerface>')
Expand Down
28 changes: 25 additions & 3 deletions repoze/sphinx/tests/test_autointerface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .util import TestApp

from .. import autointerface
from sphinx.ext.autodoc import AutoDirective, ALL
from sphinx.ext.autodoc import ALL

from docutils.statemachine import ViewList

Expand All @@ -21,7 +21,7 @@ def smoothTheDinglebop(schleem):
The schleem is then repurposed.
"""

class Options(object):
class Options(dict):
inherited_members = False
undoc_members = False
private_members = False
Expand All @@ -38,18 +38,40 @@ class Options(object):
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)
Expand Down Expand Up @@ -77,7 +99,7 @@ def assertResultContains(self, item,
objtype='interface', name='repoze.sphinx.tests.test_autointerface.IPlumbusMaker',
**kw):
directive = self.directive
inst = AutoDirective._registry[objtype](directive, name)
inst = self.app.registry.documenters['interface'](directive, name)
inst.generate(**kw)
# print '\n'.join(directive.result)
self.assertEqual([], directive._warnings)
Expand Down
6 changes: 1 addition & 5 deletions repoze/sphinx/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import tempfile
import shutil

from six import StringIO
from io import StringIO

from sphinx import application
from sphinx.builders.latex import LaTeXBuilder
from sphinx.theming import Theme
from sphinx.ext.autodoc import AutoDirective
from sphinx.pycode import ModuleAnalyzer

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

def cleanup(self, doctrees=False):
shutil.rmtree(self.__tempdir)
Theme.themes.clear()
AutoDirective._registry.clear()
ModuleAnalyzer.cache.clear()
LaTeXBuilder.usepackages = []
sys.path[:] = self._saved_path
Expand Down