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: ...@@ -8,6 +8,12 @@ matrix:
env: TOX_ENV=test-pypy env: TOX_ENV=test-pypy
- python: 2.7 - python: 2.7
env: TOX_ENV=test-py27-codecov-travis 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: install:
- pip install tox - pip install tox
......
...@@ -25,6 +25,15 @@ The default HTML generator requires Twisted. ...@@ -25,6 +25,15 @@ The default HTML generator requires Twisted.
There are some more notes in the doc/ subdirectory. 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 Sphinx Integration
------------------ ------------------
......
"""PyDoctor, an API documentation generator for Python libraries.""" """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): ...@@ -17,15 +17,16 @@ class SphinxInventory(object):
def __init__(self, logger, project_name): def __init__(self, logger, project_name):
self.project_name = project_name self.project_name = project_name
self.msg = logger self.info = logger
self._links = {} self._links = {}
self.error = lambda where, message: logger(where, message, thresh=-1)
def generate(self, subjects, basepath): def generate(self, subjects, basepath):
""" """
Generate Sphinx objects inventory version 2 at `basepath`/objects.inv. Generate Sphinx objects inventory version 2 at `basepath`/objects.inv.
""" """
path = os.path.join(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: with self._openFileForWriting(path) as target:
target.write(self._generateHeader()) target.write(self._generateHeader())
...@@ -96,7 +97,8 @@ class SphinxInventory(object): ...@@ -96,7 +97,8 @@ class SphinxInventory(object):
domainname = 'attribute' domainname = 'attribute'
else: else:
domainname = 'obj' 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) return '%s py:%s -1 %s %s\n' % (full_name, domainname, url, display)
...@@ -106,7 +108,7 @@ class SphinxInventory(object): ...@@ -106,7 +108,7 @@ class SphinxInventory(object):
""" """
parts = url.rsplit('/', 1) parts = url.rsplit('/', 1)
if len(parts) != 2: if len(parts) != 2:
self.msg( self.error(
'sphinx', 'Failed to get remote base url for %s' % (url,)) 'sphinx', 'Failed to get remote base url for %s' % (url,))
return return
...@@ -115,7 +117,7 @@ class SphinxInventory(object): ...@@ -115,7 +117,7 @@ class SphinxInventory(object):
data = self._getURL(url) data = self._getURL(url)
if not data: if not data:
self.msg( self.error(
'sphinx', 'Failed to get object inventory from %s' % (url, )) 'sphinx', 'Failed to get object inventory from %s' % (url, ))
return return
...@@ -151,7 +153,7 @@ class SphinxInventory(object): ...@@ -151,7 +153,7 @@ class SphinxInventory(object):
try: try:
return zlib.decompress(payload) return zlib.decompress(payload)
except: except:
self.msg( self.error(
'sphinx', 'sphinx',
'Failed to uncompress inventory from %s' % (base_url,)) 'Failed to uncompress inventory from %s' % (base_url,))
return '' return ''
...@@ -164,7 +166,7 @@ class SphinxInventory(object): ...@@ -164,7 +166,7 @@ class SphinxInventory(object):
for line in payload.splitlines(): for line in payload.splitlines():
parts = line.split(' ', 4) parts = line.split(' ', 4)
if len(parts) != 5: if len(parts) != 5:
self.msg( self.error(
'sphinx', 'sphinx',
'Failed to parse line "%s" for %s' % (line, base_url), 'Failed to parse line "%s" for %s' % (line, base_url),
) )
......
...@@ -31,6 +31,28 @@ class PersistentStringIO(StringIO): ...@@ -31,6 +31,28 @@ class PersistentStringIO(StringIO):
return self.buf 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(): def test_initialization():
""" """
Is initialized with logger and project name. Is initialized with logger and project name.
...@@ -40,7 +62,7 @@ def test_initialization(): ...@@ -40,7 +62,7 @@ def test_initialization():
sut = SphinxInventory(logger=logger, project_name=name) sut = SphinxInventory(logger=logger, project_name=name)
assert logger is sut.msg assert logger is sut.info
assert name is sut.project_name assert name is sut.project_name
...@@ -52,7 +74,8 @@ def test_generate_empty_functional(): ...@@ -52,7 +74,8 @@ def test_generate_empty_functional():
""" """
project_name = 'some-name' project_name = 'some-name'
log = [] 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) sut = SphinxInventory(logger=logger, project_name=project_name)
output = PersistentStringIO() output = PersistentStringIO()
sut._openFileForWriting = lambda path: closing(output) sut._openFileForWriting = lambda path: closing(output)
...@@ -61,7 +84,8 @@ def test_generate_empty_functional(): ...@@ -61,7 +84,8 @@ def test_generate_empty_functional():
expected_log = [( expected_log = [(
'sphinx', 'sphinx',
'Generating objects inventory at base-path/objects.inv' 'Generating objects inventory at base-path/objects.inv',
0
)] )]
assert expected_log == log assert expected_log == log
...@@ -73,12 +97,6 @@ x\x9c\x03\x00\x00\x00\x00\x01""" ...@@ -73,12 +97,6 @@ x\x9c\x03\x00\x00\x00\x00\x01"""
assert expected_ouput == output.getvalue() assert expected_ouput == output.getvalue()
def make_SphinxInventory():
"""
Return a SphinxInventory.
"""
return SphinxInventory(logger=object(), project_name='project_name')
def test_generateContent(): def test_generateContent():
""" """
...@@ -192,9 +210,7 @@ def test_generateLine_unknown(): ...@@ -192,9 +210,7 @@ def test_generateLine_unknown():
When object type is uknown a message is logged and is handled as When object type is uknown a message is logged and is handled as
generic object. generic object.
""" """
log = [] sut, log = make_SphinxInventoryWithLog()
sut = make_SphinxInventory()
sut.msg = lambda part, message: log.append((part, message))
result = sut._generateLine( result = sut._generateLine(
UnknownType('ignore-system', 'unknown1', 'ignore-docstring')) UnknownType('ignore-system', 'unknown1', 'ignore-docstring'))
...@@ -202,15 +218,6 @@ def test_generateLine_unknown(): ...@@ -202,15 +218,6 @@ def test_generateLine_unknown():
assert 'unknown1 py:obj -1 unknown1.html -\n' == result 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(): def test_getPayload_empty():
""" """
...@@ -259,7 +266,7 @@ not-valid-zlib-content""" ...@@ -259,7 +266,7 @@ not-valid-zlib-content"""
assert '' == result assert '' == result
assert [( assert [(
'sphinx', 'Failed to uncompress inventory from http://tm.tld', 'sphinx', 'Failed to uncompress inventory from http://tm.tld', -1,
)] == log )] == log
...@@ -325,7 +332,7 @@ def test_update_bad_url(): ...@@ -325,7 +332,7 @@ def test_update_bad_url():
assert sut._links == {} assert sut._links == {}
expected_log = [( 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 assert expected_log == log
...@@ -341,7 +348,9 @@ def test_update_fail(): ...@@ -341,7 +348,9 @@ def test_update_fail():
assert sut._links == {} assert sut._links == {}
expected_log = [( 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 assert expected_log == log
...@@ -392,8 +401,9 @@ def test_parseInventory_invalid_lines(): ...@@ -392,8 +401,9 @@ def test_parseInventory_invalid_lines():
assert [ assert [
( (
'sphinx', '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 "very.bad" for http://tm.tld', -1),
('sphinx', 'Failed to parse line "" for http://tm.tld'), ('sphinx', 'Failed to parse line "" for http://tm.tld', -1),
] == log ] == log
...@@ -10,7 +10,7 @@ from setuptools import setup ...@@ -10,7 +10,7 @@ from setuptools import setup
setup( setup(
name='pydoctor', name='pydoctor',
version='16.1.0', version='16.1.1',
author='Michael Hudson-Doyle', author='Michael Hudson-Doyle',
author_email='micahel@gmail.com', author_email='micahel@gmail.com',
url='http://github.com/twisted/pydoctor', url='http://github.com/twisted/pydoctor',
......
...@@ -5,16 +5,19 @@ ...@@ -5,16 +5,19 @@
; ;
[tox] [tox]
envlist = envlist =
test-{py27,pypy},pyflakes test-{py27,pypy},pyflakes,twisted-apidoc
[testenv:pyflakes] [testenv:pyflakes]
basepython = /usr/bin/python basepython = /usr/bin/python
[testenv] [testenv]
whitelist_externals =
git
rm
passenv = * passenv = *
deps = deps =
test: coverage test: coverage
test: Twisted test: Twisted
...@@ -40,3 +43,9 @@ commands = ...@@ -40,3 +43,9 @@ commands =
; Custom pyflakes run to exlcude test files. ; Custom pyflakes run to exlcude test files.
pyflakes: /bin/sh -c "find pydoctor/ -name \*.py ! -path '*/testpackages/*' | xargs pyflakes" 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