Merge pull request #2 from rtfd/add-full-python-test

Add full python test; fix double auto_api_dir prepended to find_files path bug
pull/6/head
Eric Holscher 9 years ago
commit bf7e3870fa

@ -70,7 +70,7 @@ class PythonDomain(AutoAPIDomain):
def get_objects(self, pattern):
'''Trigger find of serialized sources and build objects'''
for path in self.find_files(pattern):
data = self.read_file(os.path.join(self.get_config('autoapi_dir'), path))
data = self.read_file(path)
if data:
obj = self.create_class(data)
self.add_object(obj)

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'pyexample'
copyright = u'2015, rtfd'
author = u'rtfd'
version = '0.1'
release = '0.1'
language = None
exclude_patterns = ['_build']
pygments_style = 'sphinx'
todo_include_todos = False
html_theme = 'alabaster'
html_static_path = ['_static']
htmlhelp_basename = 'pyexampledoc'
extensions = ['autoapi.extension']
autoapi_type = 'python'
autoapi_dir = 'example'
autoapi_file_pattern = '*.py'

@ -0,0 +1,7 @@
__author__ = 'swenson'
import math
def example_function(x):
"""Compute the square root of x and return it."""
return math.sqrt(x)

@ -0,0 +1,26 @@
.. pyexample documentation master file, created by
sphinx-quickstart on Fri May 29 13:34:37 2015.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pyexample's documentation!
=====================================
.. toctree::
autoapi/index
Contents:
.. toctree::
:maxdepth: 2
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -0,0 +1,33 @@
__author__ = 'swenson'
import os
import shutil
import subprocess as sp
import unittest
class FullPythonTests(unittest.TestCase):
def test_full_run(self):
os.chdir('tests/pyexample')
try:
if os.path.exists('_build'):
shutil.rmtree('_build')
os.mkdir('_build')
sp.check_call('sphinx-build -b text -d ./doctrees . _build/text', shell=True)
with open('_build/text/autoapi/example/index.txt') as fin:
text = fin.read().strip()
self.assertEquals(text, '''example
*******
Function
========
example.example_function()
Compute the square root of x and return it.''')
finally:
os.chdir('../..')
Loading…
Cancel
Save