Commit 4d7d1f39 authored by Amber Brown's avatar Amber Brown Committed by GitHub

Merge branch 'master' into deprecated-on-common

parents 64c82e6e 99b0a9af
......@@ -8,6 +8,12 @@ matrix:
env: TOX_ENV=test-pypy
- python: 2.7
env: TOX_ENV=test-py27-codecov-travis
- python: 2.7
env: TOX_ENV=twisted-apidoc
allow_failures:
# Twisted trunk is broken for now.
- env: TOX_ENV=twisted-apidoc
install:
- pip install tox
......
......@@ -25,6 +25,15 @@ The default HTML generator requires Twisted.
There are some more notes in the doc/ subdirectory.
Tox development environment
---------------------------
Since Python 3 is not yet supported, you the case in which your default
tox runs with Python 3, call the tox as::
python2 -m tox -e pyflakes
Sphinx Integration
------------------
......
"""PyDoctor, an API documentation generator for Python libraries."""
version_info = (16, 1, 0, '', 0)
version_info = (16, 1, 1, '', 0)
......@@ -17,15 +17,16 @@ class SphinxInventory(object):
def __init__(self, logger, project_name):
self.project_name = project_name
self.msg = logger
self.info = logger
self._links = {}
self.error = lambda where, message: logger(where, message, thresh=-1)
def generate(self, subjects, basepath):
"""
Generate Sphinx objects inventory version 2 at `basepath`/objects.inv.
"""
path = os.path.join(basepath, 'objects.inv')
self.msg('sphinx', 'Generating objects inventory at %s' % (path,))
self.info('sphinx', 'Generating objects inventory at %s' % (path,))
with self._openFileForWriting(path) as target:
target.write(self._generateHeader())
......@@ -96,7 +97,8 @@ class SphinxInventory(object):
domainname = 'attribute'
else:
domainname = 'obj'
self.msg('sphinx', "Unknown type %r for %s." % (type(obj), full_name,))
self.error(
'sphinx', "Unknown type %r for %s." % (type(obj), full_name,))
return '%s py:%s -1 %s %s\n' % (full_name, domainname, url, display)
......@@ -106,7 +108,7 @@ class SphinxInventory(object):
"""
parts = url.rsplit('/', 1)
if len(parts) != 2:
self.msg(
self.error(
'sphinx', 'Failed to get remote base url for %s' % (url,))
return
......@@ -115,7 +117,7 @@ class SphinxInventory(object):
data = self._getURL(url)
if not data:
self.msg(
self.error(
'sphinx', 'Failed to get object inventory from %s' % (url, ))
return
......@@ -151,7 +153,7 @@ class SphinxInventory(object):
try:
return zlib.decompress(payload)
except:
self.msg(
self.error(
'sphinx',
'Failed to uncompress inventory from %s' % (base_url,))
return ''
......@@ -164,7 +166,7 @@ class SphinxInventory(object):
for line in payload.splitlines():
parts = line.split(' ', 4)
if len(parts) != 5:
self.msg(
self.error(
'sphinx',
'Failed to parse line "%s" for %s' % (line, base_url),
)
......
......@@ -31,6 +31,28 @@ class PersistentStringIO(StringIO):
return self.buf
def make_SphinxInventory(logger=object()):
"""
Return a SphinxInventory.
"""
return SphinxInventory(logger=logger, project_name='project_name')
def make_SphinxInventoryWithLog():
"""
Return a SphinxInventory with patched log.
"""
log = []
def msg(section, msg, thresh=0):
"""
Partial implementation of pydoctor.model.System.msg
"""
log.append((section, msg, thresh))
inventory = make_SphinxInventory(logger=msg)
return (inventory, log)
def test_initialization():
"""
Is initialized with logger and project name.
......@@ -40,7 +62,7 @@ def test_initialization():
sut = SphinxInventory(logger=logger, project_name=name)
assert logger is sut.msg
assert logger is sut.info
assert name is sut.project_name
......@@ -52,7 +74,8 @@ def test_generate_empty_functional():
"""
project_name = 'some-name'
log = []
logger = lambda part, message: log.append((part, message))
logger = lambda section, message, thresh=0: log.append((
section, message, thresh))
sut = SphinxInventory(logger=logger, project_name=project_name)
output = PersistentStringIO()
sut._openFileForWriting = lambda path: closing(output)
......@@ -61,7 +84,8 @@ def test_generate_empty_functional():
expected_log = [(
'sphinx',
'Generating objects inventory at base-path/objects.inv'
'Generating objects inventory at base-path/objects.inv',
0
)]
assert expected_log == log
......@@ -73,12 +97,6 @@ x\x9c\x03\x00\x00\x00\x00\x01"""
assert expected_ouput == output.getvalue()
def make_SphinxInventory():
"""
Return a SphinxInventory.
"""
return SphinxInventory(logger=object(), project_name='project_name')
def test_generateContent():
"""
......@@ -192,9 +210,7 @@ def test_generateLine_unknown():
When object type is uknown a message is logged and is handled as
generic object.
"""
log = []
sut = make_SphinxInventory()
sut.msg = lambda part, message: log.append((part, message))
sut, log = make_SphinxInventoryWithLog()
result = sut._generateLine(
UnknownType('ignore-system', 'unknown1', 'ignore-docstring'))
......@@ -202,15 +218,6 @@ def test_generateLine_unknown():
assert 'unknown1 py:obj -1 unknown1.html -\n' == result
def make_SphinxInventoryWithLog():
"""
Return a SphinxInventory with patched log.
"""
inventory = make_SphinxInventory()
log = []
inventory.msg = lambda part, msg: log.append((part, msg))
return (inventory, log)
def test_getPayload_empty():
"""
......@@ -259,7 +266,7 @@ not-valid-zlib-content"""
assert '' == result
assert [(
'sphinx', 'Failed to uncompress inventory from http://tm.tld',
'sphinx', 'Failed to uncompress inventory from http://tm.tld', -1,
)] == log
......@@ -325,7 +332,7 @@ def test_update_bad_url():
assert sut._links == {}
expected_log = [(
'sphinx', 'Failed to get remote base url for really.bad.url'
'sphinx', 'Failed to get remote base url for really.bad.url', -1
)]
assert expected_log == log
......@@ -341,7 +348,9 @@ def test_update_fail():
assert sut._links == {}
expected_log = [(
'sphinx', 'Failed to get object inventory from http://some.tld/o.inv'
'sphinx',
'Failed to get object inventory from http://some.tld/o.inv',
-1,
)]
assert expected_log == log
......@@ -392,8 +401,9 @@ def test_parseInventory_invalid_lines():
assert [
(
'sphinx',
'Failed to parse line "bad.attr bad format" for http://tm.tld'
'Failed to parse line "bad.attr bad format" for http://tm.tld',
-1,
),
('sphinx', 'Failed to parse line "very.bad" for http://tm.tld'),
('sphinx', 'Failed to parse line "" for http://tm.tld'),
('sphinx', 'Failed to parse line "very.bad" for http://tm.tld', -1),
('sphinx', 'Failed to parse line "" for http://tm.tld', -1),
] == log
......@@ -10,7 +10,7 @@ from setuptools import setup
setup(
name='pydoctor',
version='16.1.0',
version='16.1.1',
author='Michael Hudson-Doyle',
author_email='micahel@gmail.com',
url='http://github.com/twisted/pydoctor',
......
......@@ -5,16 +5,19 @@
;
[tox]
envlist =
test-{py27,pypy},pyflakes
test-{py27,pypy},pyflakes,twisted-apidoc
[testenv:pyflakes]
basepython = /usr/bin/python
[testenv]
whitelist_externals =
git
rm
passenv = *
deps =
test: coverage
test: Twisted
......@@ -40,3 +43,9 @@ commands =
; Custom pyflakes run to exlcude test files.
pyflakes: /bin/sh -c "find pydoctor/ -name \*.py ! -path '*/testpackages/*' | xargs pyflakes"
; Run current version against twisted trunk
twisted-apidoc: rm -rf {toxworkdir}/twisted-trunk
twisted-apidoc: git clone --depth 1 --branch trunk https://github.com/twisted/twisted.git {toxworkdir}/twisted-trunk
twisted-apidoc: bash -c \'{toxworkdir}/twisted-trunk/bin/admin/build-apidocs {toxworkdir}/twisted-trunk {toxworkdir}/twisted-apidocs-build > {toxworkdir}/twisted-apidocs.log \'
twisted-apidoc: cat {toxworkdir}/twisted-apidocs.log
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment