mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix autosummary test suite.
This commit is contained in:
@@ -309,7 +309,8 @@ def process_generate_options(app):
|
||||
genfiles = [path.join(app.srcdir, genfile +
|
||||
(not genfile.endswith(ext) and ext or ''))
|
||||
for genfile in genfiles]
|
||||
generate_autosummary_docs(genfiles, warn=app.warn, info=app.info)
|
||||
generate_autosummary_docs(genfiles, warn=app.warn, info=app.info,
|
||||
suffix=ext)
|
||||
|
||||
|
||||
def setup(app):
|
||||
|
||||
@@ -38,7 +38,7 @@ def _simple_info(msg):
|
||||
def _simple_warn(msg):
|
||||
print >>sys.stderr, 'WARNING: ' + msg
|
||||
|
||||
def generate_autosummary_docs(sources, output_dir=None,
|
||||
def generate_autosummary_docs(sources, output_dir=None, suffix=None,
|
||||
warn=_simple_warn, info=_simple_info):
|
||||
info('generating autosummary for: %s' % ', '.join(sources))
|
||||
if output_dir:
|
||||
@@ -62,7 +62,7 @@ def generate_autosummary_docs(sources, output_dir=None,
|
||||
warn('failed to import %r: %s' % (name, e))
|
||||
continue
|
||||
|
||||
fn = os.path.join(path, '%s.rst' % name)
|
||||
fn = os.path.join(path, name + (suffix or '.rst'))
|
||||
# skip it if it exists
|
||||
if os.path.isfile(fn):
|
||||
continue
|
||||
@@ -212,23 +212,26 @@ def get_documented(filenames):
|
||||
|
||||
|
||||
def main(argv):
|
||||
usage = 'usage: %s [-o output_dir] sourcefile ...' % sys.argv[0]
|
||||
usage = 'usage: %s [-o output_dir] [-s suffix] sourcefile ...' % sys.argv[0]
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], 'o:')
|
||||
opts, args = getopt.getopt(argv[1:], 'o:s:')
|
||||
except getopt.error:
|
||||
print >>sys.stderr, usage
|
||||
return 1
|
||||
|
||||
output_dir = None
|
||||
suffix = None
|
||||
for opt, val in opts:
|
||||
if opt == '-o':
|
||||
output_dir = val
|
||||
elif opt == '-s':
|
||||
suffix = val
|
||||
|
||||
if len(args) < 1:
|
||||
print >>sys.stderr, usage
|
||||
return 1
|
||||
|
||||
generate_autosummary_docs(args, output_dir)
|
||||
generate_autosummary_docs(args, output_dir, suffix)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -4,4 +4,4 @@ Autosummary test
|
||||
.. autosummary::
|
||||
:toctree: generated
|
||||
|
||||
sphinx.application
|
||||
sphinx.application.TemplateBridge
|
||||
|
||||
@@ -32,6 +32,7 @@ from sphinx.writers.latex import LaTeXTranslator
|
||||
|
||||
def teardown_module():
|
||||
(test_root / '_build').rmtree()
|
||||
(test_root / 'generated').rmtree()
|
||||
|
||||
|
||||
html_warnfile = StringIO()
|
||||
@@ -166,7 +167,8 @@ def check_xpath(etree, fname, path, check):
|
||||
'path %s in %s: %r' % (check, path, fname,
|
||||
[node.text for node in nodes]))
|
||||
|
||||
@gen_with_app(buildername='html', warning=html_warnfile, tags=['testtag'])
|
||||
@gen_with_app(buildername='html', warning=html_warnfile, cleanenv=True,
|
||||
tags=['testtag'])
|
||||
def test_html(app):
|
||||
app.builder.build_all()
|
||||
html_warnings = html_warnfile.getvalue().replace(os.sep, '/')
|
||||
@@ -183,7 +185,7 @@ def test_html(app):
|
||||
yield check_xpath, etree, fname, path, check
|
||||
|
||||
|
||||
@with_app(buildername='latex', warning=latex_warnfile)
|
||||
@with_app(buildername='latex', warning=latex_warnfile, cleanenv=True)
|
||||
def test_latex(app):
|
||||
LaTeXTranslator.ignore_missing_images = True
|
||||
app.builder.build_all()
|
||||
@@ -264,6 +266,6 @@ def test_htmlhelp(app):
|
||||
def test_qthelp(app):
|
||||
app.builder.build_all()
|
||||
|
||||
@with_app(buildername='changes')
|
||||
@with_app(buildername='changes', cleanenv=True)
|
||||
def test_changes(app):
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -50,6 +50,7 @@ class ForgivingLaTeXTranslator(LaTeXTranslator, ForgivingTranslator):
|
||||
|
||||
def verify_re(rst, html_expected, latex_expected):
|
||||
document = utils.new_document('test data', settings)
|
||||
document['file'] = 'dummy'
|
||||
parser.parse(rst, document)
|
||||
for msg in document.traverse(nodes.system_message):
|
||||
if msg['level'] == 1:
|
||||
|
||||
Reference in New Issue
Block a user