merge heads

This commit is contained in:
Takayuki Shimizukawa
2013-03-17 10:58:28 +09:00
14 changed files with 137 additions and 43 deletions

View File

@@ -5,6 +5,10 @@ Release 1.2 (in development)
For example: The Sphinx reference documentation in doc directory provides
sphinx.pot file from ``doc/_templates/*.html`` by ``make gettext``.
* PR#124: Fix paragraphs in versionmodified are ignored when it has no
dangling paragraphs. Fix wrong html output (nested <p> tag). Fix
versionmodified is not translatable. Thanks to Nozomu Kaneko.
* PR#123, #1106: Add epub_use_index configuration value.
If provided, it will be used instead of html_use_index for epub builder.

View File

@@ -106,6 +106,8 @@ Documentation using the sphinxdoc theme
* Pysparse: http://pysparse.sourceforge.net/
* PyTango:
http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
* Python Wild Magic:
http://python-wild-magic.googlecode.com/svn/doc/html/index.html
* Reteisi: http://www.reteisi.org/contents.html
* Satchmo: http://www.satchmoproject.com/docs/dev/
* Sphinx: http://sphinx-doc.org/

View File

@@ -14,7 +14,7 @@ from docutils.parsers.rst.directives.misc import Class
from docutils.parsers.rst.directives.misc import Include as BaseInclude
from sphinx import addnodes
from sphinx.locale import _
from sphinx.locale import versionlabels, _
from sphinx.util import url_re, docname_join
from sphinx.util.nodes import explicit_title_re, set_source_info, \
process_index_entry
@@ -190,19 +190,32 @@ class VersionChange(Directive):
set_source_info(self, node)
node['type'] = self.name
node['version'] = self.arguments[0]
text = versionlabels[self.name] % self.arguments[0]
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1],
self.lineno+1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
ret = [node] + messages
para = nodes.paragraph(self.arguments[1], '', *inodes)
set_source_info(self, para)
node.append(para)
else:
ret = [node]
messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
if len(node):
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph('', '', content))
node[0].insert(0, nodes.inline('', '%s: ' % text))
else:
para = nodes.paragraph('', '', nodes.inline('', '%s.' % text))
node.append(para)
env = self.state.document.settings.env
# XXX should record node.source as well
env.note_versionchange(node['type'], node['version'], node, node.line)
return ret
return [node] + messages
class SeeAlso(BaseAdmonition):

View File

@@ -17,7 +17,7 @@ from docutils import nodes
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
from sphinx import addnodes
from sphinx.locale import admonitionlabels, versionlabels, _
from sphinx.locale import admonitionlabels, _
from sphinx.util.smartypants import sphinx_smarty_pants
try:
@@ -157,15 +157,9 @@ class HTMLTranslator(BaseTranslator):
self.body.append('</em>')
def visit_versionmodified(self, node):
self.body.append(self.starttag(node, 'p', CLASS=node['type']))
text = versionlabels[node['type']] % node['version']
if len(node):
text += ': '
else:
text += '.'
self.body.append('<span class="versionmodified">%s</span>' % text)
self.body.append(self.starttag(node, 'div', CLASS=node['type']))
def depart_versionmodified(self, node):
self.body.append('</p>\n')
self.body.append('</div>\n')
# overwritten
def visit_reference(self, node):
@@ -310,6 +304,9 @@ class HTMLTranslator(BaseTranslator):
if isinstance(node.parent, addnodes.desc_content):
# Never compact desc_content items.
return False
if isinstance(node.parent, addnodes.versionmodified):
# Never compact versionmodified nodes.
return False
return BaseTranslator.should_be_compact_paragraph(self, node)
def visit_compact_paragraph(self, node):

View File

@@ -22,7 +22,7 @@ from docutils.writers.latex2e import Babel
from sphinx import addnodes
from sphinx import highlighting
from sphinx.errors import SphinxError
from sphinx.locale import admonitionlabels, versionlabels, _
from sphinx.locale import admonitionlabels, _
from sphinx.util import split_into
from sphinx.util.osutil import ustrftime
from sphinx.util.pycompat import any
@@ -1053,12 +1053,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
depart_warning = _depart_named_admonition
def visit_versionmodified(self, node):
intro = versionlabels[node['type']] % node['version']
if node.children:
intro += ': '
else:
intro += '.'
self.body.append(intro)
pass
def depart_versionmodified(self, node):
pass

View File

@@ -20,7 +20,7 @@ except ImportError:
has_manpage_writer = False
from sphinx import addnodes
from sphinx.locale import admonitionlabels, versionlabels, _
from sphinx.locale import admonitionlabels, _
from sphinx.util.osutil import ustrftime
@@ -157,12 +157,6 @@ class ManualPageTranslator(BaseTranslator):
def visit_versionmodified(self, node):
self.visit_paragraph(node)
text = versionlabels[node['type']] % node['version']
if len(node):
text += ': '
else:
text += '.'
self.body.append(text)
def depart_versionmodified(self, node):
self.depart_paragraph(node)

View File

@@ -17,7 +17,7 @@ from os import path
from docutils import nodes, writers
from sphinx import addnodes, __version__
from sphinx.locale import admonitionlabels, versionlabels, _
from sphinx.locale import admonitionlabels, _
from sphinx.util import ustrftime
from sphinx.writers.latex import collected_footnote
@@ -1225,12 +1225,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
self.body.append('\n')
def visit_versionmodified(self, node):
intro = versionlabels[node['type']] % node['version']
if node.children:
intro += ': '
else:
intro += '.'
self.body.append('\n%s' % self.escape(intro))
self.body.append('\n')
def depart_versionmodified(self, node):
self.body.append('\n')

View File

@@ -17,7 +17,7 @@ from docutils import nodes, writers
from docutils.utils import column_width
from sphinx import addnodes
from sphinx.locale import admonitionlabels, versionlabels, _
from sphinx.locale import admonitionlabels, _
class TextWrapper(textwrap.TextWrapper):
@@ -680,10 +680,6 @@ class TextTranslator(nodes.NodeVisitor):
def visit_versionmodified(self, node):
self.new_state(0)
if node.children:
self.add_text(versionlabels[node['type']] % node['version'] + ': ')
else:
self.add_text(versionlabels[node['type']] % node['version'] + '.')
def depart_versionmodified(self, node):
self.end_state()

View File

@@ -208,6 +208,15 @@ Version markup
.. deprecated:: 0.6
Boring stuff.
.. versionadded:: 1.2
First paragraph of versionadded.
.. versionchanged:: 1.2
First paragraph of versionchanged.
Second paragraph of versionchanged.
Code blocks
-----------

View File

@@ -19,4 +19,5 @@ CONTENTS
role_xref
glossary_terms
glossary_terms_inconsistency
versionchange
docfields

View File

@@ -0,0 +1,33 @@
# 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 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-12-15 03:17\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 versionchange"
msgstr "I18N WITH VERSIONCHANGE"
msgid "This is the *first* paragraph of deprecated."
msgstr "THIS IS THE *FIRST* PARAGRAPH OF DEPRECATED."
msgid "This is the *second* paragraph of deprecated."
msgstr "THIS IS THE *SECOND* PARAGRAPH OF DEPRECATED."
msgid "This is the *first* paragraph of versionadded."
msgstr "THIS IS THE *FIRST* PARAGRAPH OF VERSIONADDED."
msgid "This is the *first* paragraph of versionchanged."
msgstr "THIS IS THE *FIRST* PARAGRAPH OF VERSIONCHANGED."

View File

@@ -0,0 +1,16 @@
:tocdepth: 2
i18n with versionchange
============================
.. deprecated:: 1.0
This is the *first* paragraph of deprecated.
This is the *second* paragraph of deprecated.
.. versionadded:: 1.0
This is the *first* paragraph of versionadded.
.. versionchanged:: 1.0
This is the *first* paragraph of versionchanged.

View File

@@ -144,7 +144,13 @@ HTML_XPATH = {
# abbreviations
(".//abbr[@title='abbreviation']", '^abbr$'),
# version stuff
(".//span[@class='versionmodified']", 'New in version 0.6'),
(".//div[@class='versionadded']/p/span", 'New in version 0.6: '),
(".//div[@class='versionadded']/p/span",
tail_check('First paragraph of versionadded')),
(".//div[@class='versionchanged']/p/span",
tail_check('First paragraph of versionchanged')),
(".//div[@class='versionchanged']/p",
'Second paragraph of versionchanged'),
# footnote reference
(".//a[@class='footnote-reference']", r'\[1\]'),
# created by reference lookup

View File

@@ -389,6 +389,39 @@ def test_i18n_index_entries(app):
assert re.search(expr, result, re.M)
@with_intl_app(buildername='html', cleanenv=True)
def test_versionchange(app):
app.builder.build(['versionchange'])
result = (app.outdir / 'versionchange.html').text(encoding='utf-8')
def get_content(result, name):
matched = re.search(r'<div class="%s">\n*(.*?)</div>' % name,
result, re.DOTALL)
if matched:
return matched.group(1)
else:
return ''
expect1 = (
u"""<p><span>Deprecated since version 1.0: </span>"""
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF DEPRECATED.</p>\n"""
u"""<p>THIS IS THE <em>SECOND</em> PARAGRAPH OF DEPRECATED.</p>\n""")
matched_content = get_content(result, "deprecated")
assert expect1 == matched_content
expect2 = (
u"""<p><span>New in version 1.0: </span>"""
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONADDED.</p>\n""")
matched_content = get_content(result, "versionadded")
assert expect2 == matched_content
expect3 = (
u"""<p><span>Changed in version 1.0: </span>"""
u"""THIS IS THE <em>FIRST</em> PARAGRAPH OF VERSIONCHANGED.</p>\n""")
matched_content = get_content(result, "versionchanged")
assert expect3 == matched_content
@with_intl_app(buildername='text', cleanenv=True)
def test_i18n_docfields(app):
app.builder.build(['docfields'])