This commit is contained in:
Nozomu Kaneko
2013-02-06 13:28:26 +09:00
13 changed files with 535 additions and 290 deletions

View File

@@ -1,9 +1,13 @@
CONTENTS
========
.. toctree::
:maxdepth: 2
:numbered:
subdir/contents
bom
warnings
footnote
external_links
refs_inconsistency
@@ -12,6 +16,7 @@
definition_terms
figure_caption
index_entries
role_xref
glossary_terms
glossary_terms_inconsistency
docfields

View File

@@ -0,0 +1,23 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2012, foof
# This file is distributed under the same license as the foo package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: sphinx 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-04 14:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "i18n role xref"
msgstr "I18N ROCK'N ROLE XREF"
msgid "link to :term:`Some term`, :ref:`i18n-role-xref`, :doc:`contents`."
msgstr "LINK TO :ref:`i18n-role-xref`, :doc:`contents`, :term:`SOME NEW TERM`."

View File

@@ -0,0 +1,9 @@
:tocdepth: 2
.. _i18n-role-xref:
i18n role xref
==============
link to :term:`Some term`, :ref:`i18n-role-xref`, :doc:`contents`.

View File

@@ -0,0 +1,23 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2010, Georg Brandl & Team
# This file is distributed under the same license as the Sphinx <Tests> package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Sphinx <Tests> 0.6\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-04 13:06\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "i18n with reST warnings"
msgstr "I18N WITH REST WARNINGS"
msgid "line of ``literal`` markup."
msgstr "LINE OF ``BROKEN LITERAL MARKUP."

View File

@@ -0,0 +1,5 @@
i18n with reST warnings
========================
line of ``literal`` markup.

65
tests/test_build_text.py Normal file
View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
"""
test_build_text
~~~~~~~~~~~~~~~
Test the build process with Text builder with the test root.
:copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from textwrap import dedent
from docutils.utils import column_width
from util import *
def with_text_app(*args, **kw):
default_kw = {
'buildername': 'text',
'srcdir': '(empty)',
'confoverrides': {
'project': 'text',
'master_doc': 'contents',
},
}
default_kw.update(kw)
return with_app(*args, **default_kw)
@with_text_app()
def test_multibyte_title_line(app):
title = u'\u65e5\u672c\u8a9e'
underline = u'=' * column_width(title)
content = u'\n'.join((title, underline, u''))
(app.srcdir / 'contents.rst').write_text(content, encoding='utf-8')
app.builder.build_all()
result = (app.outdir / 'contents.txt').text(encoding='utf-8')
expect_underline = underline.replace('=', '*')
result_underline = result.splitlines()[2].strip()
assert expect_underline == result_underline
@with_text_app()
def test_multibyte_table(app):
text = u'\u65e5\u672c\u8a9e'
contents = (u"\n.. list-table::"
"\n"
"\n - - spam"
"\n - egg"
"\n"
"\n - - %(text)s"
"\n - %(text)s"
"\n" % locals())
(app.srcdir / 'contents.rst').write_text(contents, encoding='utf-8')
app.builder.build_all()
result = (app.outdir / 'contents.txt').text(encoding='utf-8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
line_widths = [column_width(line) for line in lines]
assert len(set(line_widths)) == 1 # same widths

View File

@@ -89,6 +89,23 @@ def test_subdir(app):
assert result.startswith(u"\nsubdir contents\n***************\n")
@with_intl_app(buildername='text', warning=warnfile)
def test_i18n_warnings_in_translation(app):
app.builddir.rmtree(True)
app.builder.build(['warnings'])
result = (app.outdir / 'warnings.txt').text(encoding='utf-8')
expect = (u"\nI18N WITH REST WARNINGS"
u"\n***********************\n"
u"\nLINE OF >>``<<BROKEN LITERAL MARKUP.\n")
assert result == expect
warnings = warnfile.getvalue().replace(os.sep, '/')
warning_expr = u'.*/warnings.txt:4: ' \
u'WARNING: Inline literal start-string without end-string.\n'
assert re.search(warning_expr, warnings)
@with_intl_app(buildername='html', cleanenv=True)
def test_i18n_footnote_break_refid(app):
"""test for #955 cant-build-html-with-footnotes-when-using"""
@@ -97,9 +114,10 @@ def test_i18n_footnote_break_refid(app):
# expect no error by build
@with_intl_app(buildername='text', cleanenv=True)
@with_intl_app(buildername='text', warning=warnfile)
def test_i18n_footnote_regression(app):
"""regression test for fix #955"""
app.builddir.rmtree(True)
app.builder.build(['footnote'])
result = (app.outdir / 'footnote.txt').text(encoding='utf-8')
expect = (u"\nI18N WITH FOOTNOTE"
@@ -110,6 +128,10 @@ def test_i18n_footnote_regression(app):
u"\n[100] THIS IS A NUMBERED FOOTNOTE.\n")
assert result == expect
warnings = warnfile.getvalue().replace(os.sep, '/')
warning_expr = u'.*/footnote.txt:\\d*: SEVERE: Duplicate ID: ".*".\n'
assert not re.search(warning_expr, warnings)
@with_intl_app(buildername='html', cleanenv=True)
def test_i18n_footnote_backlink(app):
@@ -271,6 +293,24 @@ def test_i18n_glossary_terms(app):
assert 'term not in glossary' not in warnings
@with_intl_app(buildername='text', warning=warnfile)
def test_i18n_role_xref(app):
# regression test for #1090
app.builddir.rmtree(True) #for warnings acceleration
app.builder.build(['role_xref'])
result = (app.outdir / 'role_xref.txt').text(encoding='utf-8')
expect = (u"\nI18N ROCK'N ROLE XREF"
u"\n*********************\n"
u"\nLINK TO *I18N ROCK'N ROLE XREF*, *CONTENTS*, *SOME NEW TERM*.\n")
warnings = warnfile.getvalue().replace(os.sep, '/')
assert 'term not in glossary' not in warnings
assert 'undefined label' not in warnings
assert 'unknown document' not in warnings
assert result == expect
@with_intl_app(buildername='text', warning=warnfile)
def test_i18n_glossary_terms_inconsistency(app):
# regression test for #1090

View File

@@ -142,6 +142,13 @@ class TestApp(application.Sphinx):
temproot = tempdir / 'root'
test_root.copytree(temproot)
srcdir = temproot
elif srcdir == '(empty)':
tempdir = path(tempfile.mkdtemp())
self.cleanup_trees.append(tempdir)
temproot = tempdir / 'root'
temproot.makedirs()
(temproot / 'conf.py').write_text('')
srcdir = temproot
else:
srcdir = path(srcdir)
self.builddir = srcdir.joinpath('_build')