summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2017-01-07 02:13:50 +0900
committershimizukawa <shimizukawa@gmail.com>2017-01-07 02:14:29 +0900
commit4c22cd10caa7b9621ece480fade5653d65226fcc (patch)
tree19a64268e9814dfa12087dc2d432c5339a23a0a9 /sphinx
parentf695aac2e28e1463385b399b61fc2c4b4ef40c5c (diff)
parent620616cdbd92147f6ea7bbeb670dc3a0562235ff (diff)
downloadsphinx-git-4c22cd10caa7b9621ece480fade5653d65226fcc.tar.gz
Merge branch 'stable'
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/application.py3
-rw-r--r--sphinx/environment/managers/toctree.py8
-rw-r--r--sphinx/util/__init__.py7
-rw-r--r--sphinx/writers/html.py40
4 files changed, 33 insertions, 25 deletions
diff --git a/sphinx/application.py b/sphinx/application.py
index 7a4736d42..307d63073 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -812,7 +812,8 @@ class Sphinx(object):
def add_latex_package(self, packagename, options=None):
# type: (unicode, unicode) -> None
logger.debug('[app] adding latex package: %r', packagename)
- self.builder.usepackages.append((packagename, options))
+ if hasattr(self.builder, 'usepackages'): # only for LaTeX builder
+ self.builder.usepackages.append((packagename, options))
def add_lexer(self, alias, lexer):
# type: (unicode, Any) -> None
diff --git a/sphinx/environment/managers/toctree.py b/sphinx/environment/managers/toctree.py
index 1df3f0999..8f247c986 100644
--- a/sphinx/environment/managers/toctree.py
+++ b/sphinx/environment/managers/toctree.py
@@ -483,10 +483,14 @@ class Toctree(EnvironmentManager):
if depth == 0:
return
for (title, ref) in toctreenode['entries']:
- if url_re.match(ref) or ref == 'self' or ref in assigned:
+ if url_re.match(ref) or ref == 'self':
# don't mess with those
continue
- if ref in self.tocs:
+ elif ref in assigned:
+ logger.warning('%s is already assigned section numbers '
+ '(nested numbered toctree?)', ref,
+ location=toctreenode, type='toc', subtype='secnum')
+ elif ref in self.tocs:
secnums = self.toc_secnumbers[ref] = {}
assigned.add(ref)
_walk_toc(self.tocs[ref], secnums, depth,
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index d8a70e99a..11e48b4a1 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -228,9 +228,10 @@ def save_traceback(app):
modfile = getattr(extmod, '__file__', 'unknown')
if isinstance(modfile, bytes):
modfile = modfile.decode(fs_encoding, 'replace')
- os.write(fd, ('# %s (%s) from %s\n' % (
- extname, app._extension_metadata[extname]['version'],
- modfile)).encode('utf-8'))
+ version = app._extension_metadata[extname]['version']
+ if version != 'builtin':
+ os.write(fd, ('# %s (%s) from %s\n' %
+ (extname, version, modfile)).encode('utf-8'))
os.write(fd, exc_format.encode('utf-8'))
os.close(fd)
return path
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index e6dd89faa..4cc669a36 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -344,6 +344,27 @@ class HTMLTranslator(BaseTranslator):
if isinstance(node.parent, nodes.table):
self.body.append('<span class="caption-text">')
+ def depart_title(self, node):
+ close_tag = self.context[-1]
+ if (self.permalink_text and self.builder.add_permalinks and
+ node.parent.hasattr('ids') and node.parent['ids']):
+ # add permalink anchor
+ if close_tag.startswith('</h'):
+ self.add_permalink_ref(node.parent, _('Permalink to this headline'))
+ elif close_tag.startswith('</a></h'):
+ self.body.append(u'</a><a class="headerlink" href="#%s" ' %
+ node.parent['ids'][0] +
+ u'title="%s">%s' % (
+ _('Permalink to this headline'),
+ self.permalink_text))
+ elif isinstance(node.parent, nodes.table):
+ self.body.append('</span>')
+ self.add_permalink_ref(node.parent, _('Permalink to this table'))
+ elif isinstance(node.parent, nodes.table):
+ self.body.append('</span>')
+
+ BaseTranslator.depart_title(self, node)
+
# overwritten
def visit_literal_block(self, node):
if node.rawsource != node.astext():
@@ -701,25 +722,6 @@ class HTMLTranslator(BaseTranslator):
def depart_manpage(self, node):
return self.depart_literal_emphasis(node)
- def depart_title(self, node):
- close_tag = self.context[-1]
- if (self.permalink_text and self.builder.add_permalinks and
- node.parent.hasattr('ids') and node.parent['ids']):
- # add permalink anchor
- if close_tag.startswith('</h'):
- self.add_permalink_ref(node.parent, _('Permalink to this headline'))
- elif close_tag.startswith('</a></h'):
- self.body.append(u'</a><a class="headerlink" href="#%s" ' %
- node.parent['ids'][0] +
- u'title="%s">%s' % (
- _('Permalink to this headline'),
- self.permalink_text))
- elif isinstance(node.parent, nodes.table):
- self.body.append('</span>')
- self.add_permalink_ref(node.parent, _('Permalink to this table'))
-
- BaseTranslator.depart_title(self, node)
-
# overwritten to add even/odd classes
def visit_table(self, node):