diff --git a/README.rst b/README.rst index 0d8f9c9..cc38d87 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ License :: - Copyright (C) 2015 Carlos Jenkins + Copyright (C) 2015-2018 KuraLabs S.R.L Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/doc/conf.py b/doc/conf.py index dd8923d..75c39b7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,7 +13,7 @@ import os from sys import path -from os.path import join, dirname, abspath +from os.path import dirname, abspath from autoapi import __version__ @@ -36,9 +36,8 @@ 'sphinx.ext.autodoc', 'sphinx.ext.inheritance_diagram', 'sphinx.ext.intersphinx', - 'sphinxcontrib.plantuml', - 'sphinx.ext.graphviz', - 'autoapi.sphinx' + 'autoapi.sphinx', + 'plantweb.directive', ] # Add any paths that contain templates here, relative to this directory. @@ -57,8 +56,8 @@ # General information about the project. project = 'autoapi' -copyright = '2015, Carlos Jenkins' -author = 'Carlos Jenkins' +author = 'KuraLabs S.R.L' +copyright = '2015-2018, ' + author # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -235,7 +234,7 @@ ( 'index', 'autoapi.tex', 'autoapi Documentation', - 'Carlos Jenkins', 'manual' + author, 'manual' ), ] @@ -313,22 +312,22 @@ def setup(app): app.add_stylesheet('styles/custom.css') + # autoapi configuration autoapi_modules = { 'autoapi': {'prune': True}, 'documented': {'output': 'autoapi'} } -# Configure PlantUML -plantuml = 'java -jar ' + join(dirname(abspath(__name__)), 'plantuml.8030.jar') -plantuml_output_format = 'svg' - -# Configure Graphviz -graphviz_output_format = 'svg' +# Plantweb configuration +plantweb_defaults = { + 'use_cache': True, + 'format': 'svg', +} # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'python': ('https://docs.python.org/3.4', None) + 'python': ('https://docs.python.org/3', None) } # Setup theme if not building in readthedocs.org diff --git a/doc/documented.py b/doc/documented.py index fb70fe4..3889f0e 100644 --- a/doc/documented.py +++ b/doc/documented.py @@ -37,8 +37,9 @@ def a_function(my_arg, another): :param int my_arg: The first argument of the function. Just a number. :param another: The other argument of the important function. :type another: A list of :class:`MyClass` - :rtype: int + :return: The length of the second argument times the first argument. + :rtype: int """ return my_arg * len(another) @@ -52,7 +53,9 @@ class MyClass(object): :param int param1: The first parameter of my class. :param param2: The second one. :type param2: int or float + :var my_attribute: Just an instance attribute. + :raises TypeError: if param2 is not None. """ @@ -74,9 +77,10 @@ def my_method(self, param1, param2): :param int param1: A parameter. :param list param2: Another parameter. - :rtype: list of int + :return: A list of the first parameter as long a the length of the second parameter. + :rtype: list of int """ return [param1] * len(param2) diff --git a/doc/index.rst b/doc/index.rst index 9ef8ea5..7d5d3e4 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -239,7 +239,7 @@ License :: - Copyright (C) 2015 Carlos Jenkins + Copyright (C) 2015-2018 KuraLabs S.R.L Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/doc/plantuml.8030.jar b/doc/plantuml.8030.jar deleted file mode 100644 index 925e833..0000000 Binary files a/doc/plantuml.8030.jar and /dev/null differ diff --git a/examples/apinode.py b/examples/apinode.py index 7708866..ca183d6 100644 --- a/examples/apinode.py +++ b/examples/apinode.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/autoapi/__init__.py b/lib/autoapi/__init__.py index 52a5a3f..48b6356 100644 --- a/lib/autoapi/__init__.py +++ b/lib/autoapi/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ from .apinode import __doc__, APINode # noqa -__author__ = 'Carlos Jenkins' -__email__ = 'carlos@jenkins.co.cr' -__version__ = '1.3.1' +__author__ = 'KuraLabs S.R.L' +__email__ = 'info@kuralabs.io' +__version__ = '1.4.0' __all__ = ['APINode'] diff --git a/lib/autoapi/apinode.py b/lib/autoapi/apinode.py index 9fbee1a..fefa0ad 100644 --- a/lib/autoapi/apinode.py +++ b/lib/autoapi/apinode.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -162,9 +162,9 @@ def __init__(self, name, directory=None): try: subnode = APINode(subname, self.directory) self.subnodes.append(subnode) - except: # Overbroad exception handling on purpose + except Exception as e: log.error('Failed to import {}'.format(subname)) - log.debug(format_exc()) + log.error(format_exc()) self.subnodes_failed.append(subname) # Fetch all public objects diff --git a/lib/autoapi/sphinx.py b/lib/autoapi/sphinx.py index aa38b9b..ef796bb 100644 --- a/lib/autoapi/sphinx.py +++ b/lib/autoapi/sphinx.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,12 +23,13 @@ from __future__ import print_function, division from inspect import getdoc -from logging import getLogger +from functools import wraps from traceback import format_exc from os.path import join, dirname, abspath, exists from jinja2.sandbox import SandboxedEnvironment from sphinx.util.osutil import ensuredir +from sphinx.util.logging import getLogger from sphinx.jinja2glue import BuiltinTemplateLoader from . import __version__ @@ -43,20 +44,17 @@ def handle_exception(func): Utility decorator to report all exceptions in module without making Sphinx to die. """ + @wraps(func) def wrapper(app): try: func(app) except Exception: - app.warn( + log.warning( 'Unhandled exception in autoapi module: \n{}'.format( format_exc() ) ) - # Preserve docstring - if hasattr(func, '__doc__'): - wrapper.__doc__ = func.__doc__ - return wrapper @@ -73,9 +71,9 @@ def filter_summary(obj): summary = doc.split('\n').pop(0) summary.replace('\\', '\\\\') # Escape backslash in RST return summary - except: + except Exception as e: log.error( - 'AutoApi failed to determine autosummary for obj: {}'.format(obj) + 'AutoApi failed to determine summary for obj: {}'.format(obj) ) log.error(format_exc()) @@ -158,7 +156,8 @@ def builder_inited(app): # Iterate nodes and render them for node in nodes: - out_file = join(out_dir, node.name + app.config.source_suffix[0]) + source_suffix = next(iter(app.config.source_suffix)) + out_file = join(out_dir, node.name + source_suffix) # Skip file if it override is off and it exists if not options['override'] and exists(out_file): diff --git a/requirements.dev.txt b/requirements.dev.txt index 6a1be21..7a2330c 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -4,4 +4,4 @@ pytest pytest-cov sphinx sphinx_rtd_theme -sphinxcontrib-plantuml +plantweb diff --git a/setup.py b/setup.py index d285013..1df19da 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -68,8 +68,8 @@ def find_requirements(filename): install_requires=find_requirements('requirements.txt'), # Metadata - author='Carlos Jenkins', - author_email='carlos@jenkins.co.cr', + author='KuraLabs S.R.L', + author_email='info@kuralabs.io', description=( 'Automatic API reference documentation generation for Sphinx inspired ' 'by Doxygen' @@ -79,7 +79,7 @@ def find_requirements(filename): keywords='autoapi', classifiers=[ - 'Development Status :: 3 - Alpha', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', @@ -88,5 +88,6 @@ def find_requirements(filename): 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', ] ) diff --git a/test/test_autoapi.py b/test/test_autoapi.py index 6fb8d4a..c569ce7 100644 --- a/test/test_autoapi.py +++ b/test/test_autoapi.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test/test_autoapi_apinode.py b/test/test_autoapi_apinode.py index 27725a4..d75314b 100644 --- a/test/test_autoapi_apinode.py +++ b/test/test_autoapi_apinode.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2015 Carlos Jenkins +# Copyright (C) 2015-2018 KuraLabs S.R.L # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tox.ini b/tox.ini index c5922b1..5dd42f0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,9 @@ [tox] -envlist = py27, py34, coverage, doc +envlist = py27, py34, py35, coverage, doc + [testenv] -passenv = http_proxy https_proxy +passenv = http_proxy https_proxy no_proxy HOME deps = -rrequirements.dev.txt changedir = {envtmpdir} @@ -10,13 +11,6 @@ commands = {envpython} -c "import autoapi; print(autoapi.__file__)" flake8 {toxinidir} py.test {posargs} \ - {toxinidir}/test \ - {envsitepackagesdir}/autoapi - -[testenv:coverage] -basepython = python3.4 -commands = - py.test \ --junitxml=tests.xml \ --cov=autoapi \ --cov-report xml \ @@ -25,15 +19,18 @@ commands = {toxinidir}/test \ {envsitepackagesdir}/autoapi + [testenv:doc] -basepython = python3.4 +basepython = python3 whitelist_externals = dot commands = sphinx-build -W -b html -d doctrees {toxinidir}/doc/ html + [flake8] exclude = .git,.tox,.cache,__pycache__,*.egg-info + [pytest] addopts = --doctest-modules