Skip to content

Commit f6877e4

Browse files
authored
Merge pull request #84 from astrofrog/use-tox
Fix packaging bug, add tox configuration, and switched to Azure Pipelines
2 parents 67e9fa4 + 93dd803 commit f6877e4

11 files changed

+170
-107
lines changed

.coveragerc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[run]
22
source = sphinx_automodapi
3-
omit = sphinx_automodapi/tests/*.py
3+
omit = */tests/*
44

5+
[paths]
6+
source =
7+
sphinx_automodapi/
8+
*/site-packages/sphinx_automodapi
9+
*\site-packages\sphinx_automodapi
10+
11+
[report]
12+
omit = */tests/*

.travis.yml

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,34 @@
1-
# We set the language to c because python isn't supported on the MacOS X nodes
2-
# on Travis. However, the language ends up being irrelevant anyway, since we
3-
# install Python ourselves using conda.
1+
# Most of the CI testing happens on Azure, but this configuration is for a
2+
# regular cron job on Travis (as well as for pull requests).
3+
44
language: c
55

66
os:
7-
- osx
87
- linux
98

10-
# Adding notifications since this is a project we otherwise don't update
11-
# often, but need to make sure we see failures when they happen when
12-
# running cron jobs.
13-
notifications:
14-
email:
15-
recipients:
16-
17-
189
# Setting sudo to false opts in to Travis-CI container-based builds.
1910
sudo: false
2011

21-
# The apt packages below are needed for sphinx builds, which can no longer
22-
# be installed with sudo apt-get.
2312
addons:
2413
apt:
2514
packages:
2615
- graphviz
2716

2817
env:
29-
matrix:
30-
- PYTHON_VERSION=2.7
31-
- PYTHON_VERSION=3.4 SPHINX_VERSION=1.3
32-
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.4
33-
- PYTHON_VERSION=3.5 SPHINX_VERSION=1.5
34-
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.6
35-
- PYTHON_VERSION=3.6 SPHINX_VERSION=1.7
36-
- PYTHON_VERSION=3.7 SPHINX_VERSION=1.8
37-
- PYTHON_VERSION=3.7 SPHINX_VERSION=2.0
38-
- PYTHON_VERSION=3.7 SPHINX_VERSION=dev CONDA_DEPENDENCIES="setuptools cython pytest-cov"
39-
- PYTHON_VERSION=2.7 LOCALE=C
40-
- PYTHON_VERSION=3.7 LOCALE=C
4118
global:
42-
- LOCALE=default
43-
- CONDA_DEPENDENCIES="setuptools sphinx cython pytest-cov"
19+
- CONDA_DEPENDENCIES="setuptools cython pytest-cov"
4420
- PIP_DEPENDENCIES="codecov"
4521
- HOMEBREW_NO_AUTO_UPDATE=1
22+
- PYTHON_VERSION=3.7
23+
- EVENT_TYPE=cron
4624

4725
before_install:
48-
49-
# Make sure that things work even if the locale is set to C (which effectively means ASCII).
50-
# Some of the input rst files have unicode characters and we need to deal with this gracefully.
51-
- if [[ $LOCALE == C ]]; then
52-
export LC_CTYPE=C;
53-
export LC_ALL=C;
54-
export LANG=C;
55-
fi
56-
5726
- if [[ $TRAVIS_OS_NAME == osx ]]; then brew install graphviz; fi
5827

5928
install:
6029
- git clone git://github.com/astropy/ci-helpers.git
6130
- source ci-helpers/travis/setup_conda.sh
62-
- if [[ $SPHINX_VERSION == dev ]]; then
63-
pip install git+https://github.com/sphinx-doc/sphinx.git;
64-
fi
31+
- pip install git+https://github.com/sphinx-doc/sphinx.git
6532

6633
script:
67-
- py.test --cov sphinx_automodapi sphinx_automodapi -v
68-
69-
after_success:
70-
- codecov
34+
- pytest sphinx_automodapi

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ available as a standalone package since it can be used for any other
99
package. The documentation can be found on
1010
`ReadTheDocs <http://sphinx-automodapi.readthedocs.io/en/latest/>`_.
1111

12+
Running tests
13+
-------------
14+
15+
To run the tests, you can either do::
16+
17+
pytest sphinx_automodapi
18+
19+
or if you have `tox <https://tox.readthedocs.io/en/latest/>`_ installed::
20+
21+
tox -e test
22+
1223
.. |Travis Status| image:: https://travis-ci.org/astropy/sphinx-automodapi.svg?branch=master
1324
:target: https://travis-ci.org/astropy/sphinx-automodapi
1425
.. |AppVeyor status| image:: https://ci.appveyor.com/api/projects/status/warwyfj06t1rkn5p/branch/master?svg=true

appveyor.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1+
schedules:
2+
- cron: "0 0 * * 1"
3+
displayName: "weekly"
4+
branches:
5+
include:
6+
- master
7+
always: "true"
18

9+
jobs:
10+
11+
- template: azure-template.yml
12+
parameters:
13+
name: Linux
14+
os: linux
15+
16+
- template: azure-template.yml
17+
parameters:
18+
name: MacOSX
19+
os: macosx
20+
21+
- template: azure-template.yml
22+
parameters:
23+
name: Windows
24+
os: windows

azure-template.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
jobs:
2+
- job: ${{ format(parameters.name) }}
3+
pool:
4+
${{ if eq(parameters.os, 'macosx') }}:
5+
vmImage: macOS 10.13
6+
${{ if eq(parameters.os, 'linux') }}:
7+
vmImage: Ubuntu 16.04
8+
${{ if eq(parameters.os, 'windows') }}:
9+
vmImage: vs2017-win2016
10+
11+
steps:
12+
13+
- ${{ if eq(parameters.os, 'macosx') }}:
14+
- script: brew install graphviz
15+
displayName: Installing graphviz
16+
- ${{ if eq(parameters.os, 'linux') }}:
17+
- script: sudo apt-get install -y graphviz
18+
displayName: Installing graphviz
19+
- ${{ if eq(parameters.os, 'windows') }}:
20+
- script: choco install graphviz vcpython27 curl codecov --no-progress
21+
displayName: Installing graphviz, vcpython27, curl, and codecov
22+
23+
- task: UsePythonVersion@0
24+
inputs:
25+
versionSpec: '2.7'
26+
architecture: 'x64'
27+
28+
- task: UsePythonVersion@0
29+
inputs:
30+
versionSpec: '3.5'
31+
architecture: 'x64'
32+
33+
- task: UsePythonVersion@0
34+
inputs:
35+
versionSpec: '3.6'
36+
architecture: 'x64'
37+
38+
- task: UsePythonVersion@0
39+
inputs:
40+
versionSpec: '3.7'
41+
architecture: 'x64'
42+
43+
- script: pip install tox coverage
44+
displayName: Installing tox and coverage
45+
46+
- script: tox
47+
displayName: Running tests with tox
48+
49+
- bash: coverage combine .tmp/*/.coverage
50+
displayName: Combining coverage results
51+
- bash: coverage report
52+
displayName: Show coverage
53+
54+
# As described in https://github.com/codecov/codecov-bash/issues/189, the
55+
# official bash script doesn't use the correct variable names for pull
56+
# requests, so we use a fork of the bash script for now.
57+
- bash: bash <(curl https://raw.githubusercontent.com/astrofrog/codecov-bash/fixed-azure/codecov) -t $(codecov.token)
58+
displayName: Uploading results to codecov

setup.cfg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ classifiers =
1919
[options]
2020
zip_safe = False
2121
packages = find:
22-
install_requires = sphinx>=1.3
22+
install_requires =
23+
sphinx>=1.3
24+
25+
[options.extras_require]
26+
test =
27+
pytest
28+
pytest-cov
29+
cython
30+
codecov
31+
coverage
2332

2433
[options.package_data]
2534
sphinx_automodapi = templates/*/*.rst
26-
sphinx_automodapi.tests = cases/*/*.*, cases/*/*/*.*, cases/*/*/*/*.*
35+
sphinx_automodapi.tests = cases/*/*.*, cases/*/*/*.*, cases/*/*/*/*.*, cases/*/*/*/*/*.*

sphinx_automodapi/automodapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ def automodapi_replace(sourcestr, app, dotoctree=True, docname=None,
208208
toctreestr = ':toctree: '
209209
api_dir = os.path.join(app.srcdir, app.config.automodapi_toctreedirnm)
210210
if docname is None:
211-
doc_path = '.'
211+
doc_path = app.srcdir
212212
else:
213-
doc_path = os.path.join(app.srcdir, docname)
214-
toctreestr += os.path.relpath(api_dir, os.path.dirname(doc_path)).replace(os.sep, '/')
213+
doc_path = os.path.dirname(os.path.join(app.srcdir, docname))
214+
toctreestr += os.path.relpath(api_dir, doc_path).replace(os.sep, '/')
215215
else:
216216
toctreestr = ''
217217

sphinx_automodapi/automodsumm.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,13 @@ def run(self):
133133
env = self.state.document.settings.env
134134
modname = self.arguments[0]
135135

136-
try:
137-
self.warnings[:] = []
138-
except AttributeError:
139-
self.warnings = []
140-
141136
nodelist = []
142137

143138
try:
144139
localnames, fqns, objs = find_mod_objs(modname)
145140
except ImportError:
146141
self.warn("Couldn't import module " + modname)
147-
return self.warnings
142+
return []
148143

149144
try:
150145
# set self.content to trick the autosummary internals.
@@ -200,12 +195,15 @@ def run(self):
200195
# super(Autosummary,self).run()
201196
nodelist.extend(Autosummary.run(self))
202197

203-
return self.warnings + nodelist
198+
return nodelist
204199
finally: # has_content = False for the Automodsumm
205200
self.content = []
206201

207202
def get_items(self, names):
208-
self.genopt['imported-members'] = True
203+
try:
204+
self.bridge.genopt['imported-members'] = True
205+
except AttributeError: # Sphinx < 4.0
206+
self.genopt['imported-members'] = True
209207
return Autosummary.get_items(self, names)
210208

211209

@@ -223,9 +221,8 @@ def run(self):
223221

224222
nms, objs = find_mod_objs(self.arguments[0], onlylocals=ols)[1:]
225223
except ImportError:
226-
self.warnings = []
227224
self.warn("Couldn't import module " + self.arguments[0])
228-
return self.warnings
225+
return []
229226

230227
# Check if some classes should be skipped
231228
skip = self.options.get('skip', [])

sphinx_automodapi/tests/test_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def write_conf(filename, conf):
4343

4444

4545
intersphinx_mapping = {
46-
'python': ('http://docs.python.org/{0}/'.format(sys.version_info[0]), None)
46+
'python': ('https://docs.python.org/{0}/'.format(sys.version_info[0]), None)
4747
}
4848

4949
DEFAULT_CONF = {'source_suffix': '.rst',

tox.ini

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[tox]
2+
envlist =
3+
py27-test
4+
py37-test
5+
py27-test-clocale
6+
py37-test-clocale
7+
py27-test-sphinx13
8+
py35-test-sphinx14
9+
py35-test-sphinx15
10+
py36-test-sphinx16
11+
py36-test-sphinx17
12+
py37-test-sphinx18
13+
py37-test-sphinx20
14+
py37-test-sphinxdev
15+
requires = pip >= 18.0
16+
setuptools >= 30.3.0
17+
18+
[testenv]
19+
changedir = .tmp/{envname}
20+
deps =
21+
sphinx13: sphinx==1.3.6
22+
sphinx14: sphinx==1.4.9
23+
sphinx15: sphinx==1.5.6
24+
sphinx16: sphinx==1.6.7
25+
sphinx17: sphinx==1.7.9
26+
sphinx18: sphinx==1.8.5
27+
sphinx20: sphinx==2.0.1
28+
sphinx21: sphinx==2.1.2
29+
sphinxdev: git+https://github.com/sphinx-doc/sphinx.git
30+
extras =
31+
test: test
32+
commands =
33+
test: pytest --pyargs sphinx_automodapi --cov-append --cov sphinx_automodapi --cov-report=
34+
setenv =
35+
clocale: LC_CTYPE=C
36+
clocale: LC_ALL=C
37+
clocale: LANG=C
38+
platform =
39+
clocale: linux|darwin

0 commit comments

Comments
 (0)