summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNozomu Kaneko <nozom.kaneko@gmail.com>2012-12-24 03:39:37 +0900
committerNozomu Kaneko <nozom.kaneko@gmail.com>2012-12-24 03:39:37 +0900
commit7197d15a3e9c1e9b1d56c29c9c2807db4ea89399 (patch)
tree4f27f5c10d9a15f42b368ec179c5a92613dacfff
parent45e5b2e0eda309a771899717ad91195e14b9db18 (diff)
parente1bf8968511b3d6c2459d1f0e2abd306b8f55f27 (diff)
downloadsphinx-7197d15a3e9c1e9b1d56c29c9c2807db4ea89399.tar.gz
merge heads
-rw-r--r--sphinx/environment.py8
-rw-r--r--sphinx/ext/refcounting.py9
-rw-r--r--sphinx/texinputs/sphinx.sty4
-rw-r--r--sphinx/websupport/search/__init__.py2
-rw-r--r--tests/root/i18n/index.txt1
-rw-r--r--tests/root/i18n/literalblock.po30
-rw-r--r--tests/root/i18n/literalblock.txt13
-rw-r--r--tests/test_build_html.py1
-rw-r--r--tests/test_intl.py22
-rw-r--r--tox.ini19
10 files changed, 96 insertions, 13 deletions
diff --git a/sphinx/environment.py b/sphinx/environment.py
index cada082d..0b9e5bcc 100644
--- a/sphinx/environment.py
+++ b/sphinx/environment.py
@@ -220,6 +220,14 @@ class Locale(Transform):
if not msgstr or msgstr == msg: # as-of-yet untranslated
continue
+ # Avoid "Literal block expected; none found." warnings.
+ # If msgstr ends with '::' then it cause warning message at
+ # parser.parse() processing.
+ # literal-block-warning is only appear in avobe case.
+ if msgstr.strip().endswith('::'):
+ msgstr += '\n\n dummy literal'
+ # dummy literal node will discard by 'patch = patch[0]'
+
patch = new_document(source, settings)
parser.parse(msgstr, patch)
patch = patch[0]
diff --git a/sphinx/ext/refcounting.py b/sphinx/ext/refcounting.py
index a8dc721d..c76d25d2 100644
--- a/sphinx/ext/refcounting.py
+++ b/sphinx/ext/refcounting.py
@@ -17,6 +17,7 @@ from os import path
from docutils import nodes
from sphinx import addnodes
+from sphinx.locale import _
# refcount annotation
@@ -78,12 +79,12 @@ class Refcounts(dict):
continue
elif entry.result_type not in ("PyObject*", "PyVarObject*"):
continue
- rc = 'Return value: '
if entry.result_refs is None:
- rc += "Always NULL."
+ rc = _('Return value: Always NULL.')
+ elif entry.result_refs:
+ rc = _('Return value: New reference.')
else:
- rc += (entry.result_refs and "New" or "Borrowed") + \
- " reference."
+ rc = _('Return value: Borrowed reference.')
node.insert(0, refcount(rc, rc))
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index c9d3e100..ce15591a 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -137,7 +137,7 @@
% Some custom font markup commands.
%
-\newcommand{\strong}[1]{{\bf #1}}
+\newcommand{\strong}[1]{{\textbf{#1}}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\bfcode}[1]{\code{\bfseries#1}}
\newcommand{\email}[1]{\textsf{#1}}
@@ -333,7 +333,7 @@
\@ifundefined{ChTitleVar}{}{
\ChNameVar{\raggedleft\normalsize\py@HeaderFamily}
\ChNumVar{\raggedleft \bfseries\Large\py@HeaderFamily}
- \ChTitleVar{\raggedleft \rm\Huge\py@HeaderFamily}
+ \ChTitleVar{\raggedleft \textrm{\Huge\py@HeaderFamily}}
% This creates chapter heads without the leading \vspace*{}:
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
diff --git a/sphinx/websupport/search/__init__.py b/sphinx/websupport/search/__init__.py
index 385c3fa9..10e3532d 100644
--- a/sphinx/websupport/search/__init__.py
+++ b/sphinx/websupport/search/__init__.py
@@ -102,7 +102,7 @@ class BaseSearch(object):
res = self.context_re.search(text)
if res is None:
return ''
- context_start = max(res.start() - length/2, 0)
+ context_start = max(res.start() - int(length/2), 0)
context_end = context_start + length
context = ''.join([context_start > 0 and '...' or '',
text[context_start:context_end],
diff --git a/tests/root/i18n/index.txt b/tests/root/i18n/index.txt
index aef5854d..97faf19c 100644
--- a/tests/root/i18n/index.txt
+++ b/tests/root/i18n/index.txt
@@ -5,4 +5,5 @@
footnote
external_links
refs_inconsistency
+ literalblock
seealso
diff --git a/tests/root/i18n/literalblock.po b/tests/root/i18n/literalblock.po
new file mode 100644
index 00000000..8ea83b3b
--- /dev/null
+++ b/tests/root/i18n/literalblock.po
@@ -0,0 +1,30 @@
+# 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: 2012-11-22 08:28\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 literal block"
+msgstr "I18N WITH LITERAL BLOCK"
+
+msgid "Correct literal block::"
+msgstr "CORRECT LITERAL BLOCK::"
+
+msgid "Missing literal block::"
+msgstr "MISSING LITERAL BLOCK::"
+
+msgid "That's all."
+msgstr "THAT'S ALL."
+
diff --git a/tests/root/i18n/literalblock.txt b/tests/root/i18n/literalblock.txt
new file mode 100644
index 00000000..c9c71099
--- /dev/null
+++ b/tests/root/i18n/literalblock.txt
@@ -0,0 +1,13 @@
+:tocdepth: 2
+
+i18n with literal block
+=========================
+
+Correct literal block::
+
+ this is
+ literal block
+
+Missing literal block::
+
+That's all.
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index a693e6c0..69111d4e 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -35,6 +35,7 @@ ENV_WARNINGS = """\
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder\\.MarkupError:2: \
WARNING: Explicit markup ends without a blank line; unexpected \
unindent\\.\\n?
+%(root)s/i18n/literalblock.txt:13: WARNING: Literal block expected; none found.
%(root)s/images.txt:9: WARNING: image file not readable: foo.png
%(root)s/images.txt:23: WARNING: nonlocal image URI found: \
http://www.python.org/logo.png
diff --git a/tests/test_intl.py b/tests/test_intl.py
index c3cd4491..f8a9bcda 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -186,6 +186,28 @@ def test_i18n_keep_external_links(app):
assert expect_line == matched_line
+@with_app(buildername='text', warning=warnfile, cleanenv=True,
+ confoverrides={'language': 'xx', 'locale_dirs': ['.'],
+ 'gettext_compact': False})
+def test_i18n_literalblock_warning(app):
+ app.builddir.rmtree(True) #for warnings acceleration
+ app.builder.build(['i18n/literalblock'])
+ result = (app.outdir / 'i18n' / 'literalblock.txt').text(encoding='utf-8')
+ expect = (u"\nI18N WITH LITERAL BLOCK"
+ u"\n***********************\n"
+ u"\nCORRECT LITERAL BLOCK:\n"
+ u"\n this is"
+ u"\n literal block\n"
+ u"\nMISSING LITERAL BLOCK:\n"
+ u"\n<SYSTEM MESSAGE: ")
+ assert result.startswith(expect)
+
+ warnings = warnfile.getvalue().replace(os.sep, '/')
+ expected_warning_expr = u'.*/i18n/literalblock.txt:\\d+: ' \
+ u'WARNING: Literal block expected; none found.'
+ assert re.search(expected_warning_expr, warnings)
+
+
@with_app(buildername='text', cleanenv=True,
confoverrides={'language': 'xx', 'locale_dirs': ['.'],
'gettext_compact': False})
diff --git a/tox.ini b/tox.ini
index cedda4f3..8315de9b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,6 +4,8 @@ envlist=py25,py26,py27,py31,py32,py33,pypy,du09,du08,du07
[testenv]
deps=
nose
+ sqlalchemy
+ whoosh
setenv =
BUILD_TEST_PATH = {envdir}/tests
commands=
@@ -12,31 +14,36 @@ commands=
[testenv:py25]
deps=
- nose
simplejson==2.5.0
+ {[testenv]deps}
[testenv:py33]
deps=
- nose
#svn+http://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils
docutils>=0.10.0
+ {[testenv]deps}
[testenv:pypy]
deps=
- nose
simplejson
+ {[testenv]deps}
[testenv:du07]
deps=
- nose
docutils==0.7
+ {[testenv]deps}
[testenv:du08]
deps=
- nose
docutils==0.8.1
+ {[testenv]deps}
[testenv:du09]
deps=
- nose
docutils==0.9.1
+ {[testenv]deps}
+
+[testenv:du10]
+deps=
+ docutils==0.10.0
+ {[testenv]deps}