Merge remote-tracking branch 'origin/master' into cleanup-june

pull/113/head
Eric Holscher 7 years ago
commit 3531f5560a

1
.gitignore vendored

@ -12,3 +12,4 @@ _api_
.tox
.eggs
.ropeproject/
.cache

@ -3,7 +3,8 @@ environment:
matrix:
- PYTHON: "C:/Python27"
install:
- ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
- ps: "[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls11, Tls12'"
- ps: "Start-FileDownload 'https://bootstrap.pypa.io/get-pip.py' -FileName 'C:/get-pip.py'"
- "%PYTHON%/python.exe C:/get-pip.py"
- "%PYTHON%/Scripts/pip.exe --version"
- "%PYTHON%/Scripts/pip.exe install tox"

@ -145,10 +145,6 @@ def doctree_read(app, doctree):
app.info(bold('[AutoAPI] ') +
darkgreen('Adding AutoAPI TOCTree [%s] to index.rst' % toc_entry)
)
if sphinx.version_info > (1, 5):
app.env.note_toctree(app.env.docname, root)
else:
app.env.build_toc_from(app.env.docname, doctree)
def setup(app):

@ -5,6 +5,7 @@ from collections import OrderedDict, namedtuple
import unidecode
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
import sphinx.util
from sphinx.util.console import darkgreen, bold
from sphinx.util.osutil import ensuredir
from sphinx.util.docstrings import prepare_docstring
@ -199,7 +200,7 @@ class SphinxMapperBase(object):
# Mapping of {namespace id -> Python Object}
self.top_level_objects = OrderedDict()
def load(self, patterns, dirs, ignore=None, **kwargs):
def load(self, patterns, dirs, ignore=None):
'''
Load objects from the filesystem into the ``paths`` dictionary.
@ -238,7 +239,12 @@ class SphinxMapperBase(object):
files_to_read.append(filename)
for _path in self.app.status_iterator(
if sphinx.version_info >= (1, 6):
status_iterator = sphinx.util.status_iterator
else:
status_iterator = self.app.status_iterator
for _path in status_iterator(
files_to_read,
'[AutoAPI] Reading files... ',
darkgreen,
@ -272,7 +278,7 @@ class SphinxMapperBase(object):
'''
Create class object.
:param obj: Instance of a AutoAPI object
:param data: Instance of a AutoAPI object
'''
raise NotImplementedError

@ -60,6 +60,7 @@ class DotNetSphinxMapper(SphinxMapperBase):
DOCFX_OUTPUT_PATH = '_api'
# pylint: disable=arguments-differ
def load(self, patterns, dirs, ignore=None, **kwargs):
'''Load objects from the filesystem into the ``paths`` dictionary.
@ -135,7 +136,7 @@ class DotNetSphinxMapper(SphinxMapperBase):
self.organize_objects()
def create_class(self, data, options=None, **kwargs):
def create_class(self, data, options=None, path=None, **kwargs):
'''
Return instance of class based on Roslyn type property

@ -40,7 +40,7 @@ class GoSphinxMapper(SphinxMapperBase):
self.app.warn('Error reading file: {0}'.format(path))
return None
def create_class(self, data, options=None, **kwargs):
def create_class(self, data, options=None, path=None, **kwargs):
'''Return instance of class based on Go data
Data keys handled here:

@ -40,7 +40,7 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
obj.jinja_env = self.jinja_env
self.add_object(obj)
def create_class(self, data, options=None, **kwargs):
def create_class(self, data, options=None, path=None, **kwargs):
'''Return instance of class based on Javascript data
Data keys handled here:

@ -25,14 +25,14 @@ class PythonSphinxMapper(SphinxMapperBase):
:param app: Sphinx application passed in as part of the extension
"""
def load(self, patterns, dirs, ignore=None, **kwargs):
def load(self, patterns, dirs, ignore=None):
"""Load objects from the filesystem into the ``paths`` dictionary
Also include an attribute on the object, ``relative_path`` which is the
shortened, relative path the package/module
"""
for dir_ in dirs:
for path in self.find_files(patterns=patterns, dirs=[dir_], ignore=ignore, **kwargs):
for path in self.find_files(patterns=patterns, dirs=[dir_], ignore=ignore):
data = self.read_file(path=path)
data.relative_path = os.path.relpath(path, dir_)
if data:

@ -21,9 +21,7 @@ def _build_toc_node(docname, anchor='anchor', text='test text', bullet=False):
anchorname='#' + anchor, *[nodes.Text(text, text)])
para = addnodes.compact_paragraph('', '', reference)
ret_list = nodes.list_item('', para)
if not bullet:
return ret_list
return nodes.bullet_list('', ret_list)
return nodes.bullet_list('', ret_list) if bullet else ret_list
def _traverse_parent(node, objtypes):

@ -1,3 +1,4 @@
import io
import json
import os
import sys
@ -32,7 +33,7 @@ class LanguageIntegrationTests(unittest.TestCase):
def _run_test(self, test_dir, test_file, test_string):
with sphinx_build(test_dir):
with open(test_file) as fin:
with io.open(test_file, encoding='utf8') as fin:
text = fin.read().strip()
self.assertIn(test_string, text)
@ -69,7 +70,9 @@ class PythonTests(LanguageIntegrationTests):
def test_integration(self):
with sphinx_build('pyexample'):
example_file = open('_build/text/autoapi/example/index.txt').read()
example_path = '_build/text/autoapi/example/index.txt'
with io.open(example_path, encoding='utf8') as example_handle:
example_file = example_handle.read()
self.assertIn(
'class example.Foo',
example_file
@ -89,6 +92,17 @@ class PythonTests(LanguageIntegrationTests):
self.assertFalse(
os.path.exists('_build/text/autoapi/method_multiline')
)
index_path = '_build/text/index.txt'
with io.open(index_path, encoding='utf8') as index_handle:
index_file = index_handle.read()
self.assertIn(
'Sphinx AutoAPI Index',
index_file
)
self.assertIn(
'Foo',
index_file
)
class DotNetTests(LanguageIntegrationTests):

@ -26,7 +26,7 @@ commands =
[testenv:docs]
deps =
Sphinx>=1.6
Sphinx>=1.6,<=1.7
sphinx_rtd_theme
changedir = {toxinidir}/docs
commands =

Loading…
Cancel
Save