diff --git a/sphinx/themes/agogo/static/agogo.css_t b/sphinx/themes/agogo/static/agogo.css_t index db4a621a4..686b1312d 100644 --- a/sphinx/themes/agogo/static/agogo.css_t +++ b/sphinx/themes/agogo/static/agogo.css_t @@ -97,7 +97,10 @@ h3:hover > a.headerlink, h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, -dt:hover > a.headerlink { +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { visibility: visible; } diff --git a/sphinx/themes/basic/static/basic.css_t b/sphinx/themes/basic/static/basic.css_t index 3616288c8..1d1c5e595 100644 --- a/sphinx/themes/basic/static/basic.css_t +++ b/sphinx/themes/basic/static/basic.css_t @@ -197,7 +197,10 @@ h3:hover > a.headerlink, h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, -dt:hover > a.headerlink { +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { visibility: visible; } diff --git a/sphinx/themes/scrolls/static/scrolls.css_t b/sphinx/themes/scrolls/static/scrolls.css_t index 9591f045f..2040d97fa 100644 --- a/sphinx/themes/scrolls/static/scrolls.css_t +++ b/sphinx/themes/scrolls/static/scrolls.css_t @@ -250,7 +250,10 @@ h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, dt:hover > a.headerlink, -dt:hover > a.headerlink { +dt:hover > a.headerlink, +caption:hover > a.headerlink, +p.caption:hover > a.headerlink, +div.code-block-caption:hover > a.headerlink { visibility: visible; } diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 82c228bdc..cf92fc5ef 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -102,12 +102,7 @@ class HTMLTranslator(BaseTranslator): and node['ids'] and node['first']: self.body.append('' % node['ids'][0]) def depart_desc_signature(self, node): - if node['ids'] and self.permalink_text and self.builder.add_permalinks: - self.body.append(u'%s' % ( - _('Permalink to this definition'), - self.permalink_text)) + self.add_permalink_ref(node, 'definition') self.body.append('\n') def visit_desc_addname(self, node): @@ -253,9 +248,11 @@ class HTMLTranslator(BaseTranslator): def add_fignumber(self, node): def append_fignumber(figtype, figure_id): if figure_id in self.builder.fignumbers.get(figtype, {}): + self.body.append(self.starttag(node, 'span', '', CLASS='caption-number')) prefix = self.builder.config.numfig_prefix.get(figtype, '') numbers = self.builder.fignumbers[figtype][figure_id] self.body.append(prefix + '.'.join(map(str, numbers)) + " ") + self.body.append('') if isinstance(node.parent, nodes.figure): append_fignumber('figure', node.parent['ids'][0]) @@ -264,6 +261,12 @@ class HTMLTranslator(BaseTranslator): elif isinstance(node.parent, nodes.container): append_fignumber('code-block', node.parent['ids'][0]) + def add_permalink_ref(self, node, typename): + if node['ids'] and self.permalink_text and self.builder.add_permalinks: + title = _('Permalink to this %s' % typename) + format = u'%s' + self.body.append(format % (node['ids'][0], title, self.permalink_text)) + # overwritten to avoid emitting empty