mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merged in tk0miya/sphinx (pull request #304)
numfig feature improvement
This commit is contained in:
commit
6c0b4f1933
@ -97,7 +97,10 @@ h3:hover > a.headerlink,
|
|||||||
h4:hover > a.headerlink,
|
h4:hover > a.headerlink,
|
||||||
h5:hover > a.headerlink,
|
h5:hover > a.headerlink,
|
||||||
h6: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;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,10 @@ h3:hover > a.headerlink,
|
|||||||
h4:hover > a.headerlink,
|
h4:hover > a.headerlink,
|
||||||
h5:hover > a.headerlink,
|
h5:hover > a.headerlink,
|
||||||
h6: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;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,10 @@ h4:hover > a.headerlink,
|
|||||||
h5:hover > a.headerlink,
|
h5:hover > a.headerlink,
|
||||||
h6:hover > a.headerlink,
|
h6:hover > a.headerlink,
|
||||||
dt: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;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +102,7 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
and node['ids'] and node['first']:
|
and node['ids'] and node['first']:
|
||||||
self.body.append('<!--[%s]-->' % node['ids'][0])
|
self.body.append('<!--[%s]-->' % node['ids'][0])
|
||||||
def depart_desc_signature(self, node):
|
def depart_desc_signature(self, node):
|
||||||
if node['ids'] and self.permalink_text and self.builder.add_permalinks:
|
self.add_permalink_ref(node, 'definition')
|
||||||
self.body.append(u'<a class="headerlink" href="#%s" '
|
|
||||||
% node['ids'][0] +
|
|
||||||
u'title="%s">%s</a>' % (
|
|
||||||
_('Permalink to this definition'),
|
|
||||||
self.permalink_text))
|
|
||||||
self.body.append('</dt>\n')
|
self.body.append('</dt>\n')
|
||||||
|
|
||||||
def visit_desc_addname(self, node):
|
def visit_desc_addname(self, node):
|
||||||
@ -253,9 +248,11 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
def add_fignumber(self, node):
|
def add_fignumber(self, node):
|
||||||
def append_fignumber(figtype, figure_id):
|
def append_fignumber(figtype, figure_id):
|
||||||
if figure_id in self.builder.fignumbers.get(figtype, {}):
|
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, '')
|
prefix = self.builder.config.numfig_prefix.get(figtype, '')
|
||||||
numbers = self.builder.fignumbers[figtype][figure_id]
|
numbers = self.builder.fignumbers[figtype][figure_id]
|
||||||
self.body.append(prefix + '.'.join(map(str, numbers)) + " ")
|
self.body.append(prefix + '.'.join(map(str, numbers)) + " ")
|
||||||
|
self.body.append('</span>')
|
||||||
|
|
||||||
if isinstance(node.parent, nodes.figure):
|
if isinstance(node.parent, nodes.figure):
|
||||||
append_fignumber('figure', node.parent['ids'][0])
|
append_fignumber('figure', node.parent['ids'][0])
|
||||||
@ -264,6 +261,12 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
elif isinstance(node.parent, nodes.container):
|
elif isinstance(node.parent, nodes.container):
|
||||||
append_fignumber('code-block', node.parent['ids'][0])
|
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'<a class="headerlink" href="#%s" title="%s">%s</a>'
|
||||||
|
self.body.append(format % (node['ids'][0], title, self.permalink_text))
|
||||||
|
|
||||||
# overwritten to avoid emitting empty <ul></ul>
|
# overwritten to avoid emitting empty <ul></ul>
|
||||||
def visit_bullet_list(self, node):
|
def visit_bullet_list(self, node):
|
||||||
if len(node) == 1 and node[0].tagname == 'toctree':
|
if len(node) == 1 and node[0].tagname == 'toctree':
|
||||||
@ -275,6 +278,8 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
BaseTranslator.visit_title(self, node)
|
BaseTranslator.visit_title(self, node)
|
||||||
self.add_secnumber(node)
|
self.add_secnumber(node)
|
||||||
self.add_fignumber(node)
|
self.add_fignumber(node)
|
||||||
|
if isinstance(node.parent, nodes.table):
|
||||||
|
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_literal_block(self, node):
|
def visit_literal_block(self, node):
|
||||||
@ -307,8 +312,17 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
else:
|
else:
|
||||||
BaseTranslator.visit_caption(self, node)
|
BaseTranslator.visit_caption(self, node)
|
||||||
self.add_fignumber(node)
|
self.add_fignumber(node)
|
||||||
|
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
||||||
|
|
||||||
def depart_caption(self, node):
|
def depart_caption(self, node):
|
||||||
|
self.body.append('</span>')
|
||||||
|
|
||||||
|
# append permalink if available
|
||||||
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
|
self.add_permalink_ref(node.parent, 'code')
|
||||||
|
elif isinstance(node.parent, nodes.figure):
|
||||||
|
self.add_permalink_ref(node.parent, 'image')
|
||||||
|
|
||||||
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
self.body.append('</div>\n')
|
self.body.append('</div>\n')
|
||||||
else:
|
else:
|
||||||
@ -576,19 +590,18 @@ class HTMLTranslator(BaseTranslator):
|
|||||||
close_tag = self.context[-1]
|
close_tag = self.context[-1]
|
||||||
if (self.permalink_text and self.builder.add_permalinks and
|
if (self.permalink_text and self.builder.add_permalinks and
|
||||||
node.parent.hasattr('ids') and node.parent['ids']):
|
node.parent.hasattr('ids') and node.parent['ids']):
|
||||||
aname = node.parent['ids'][0]
|
|
||||||
# add permalink anchor
|
# add permalink anchor
|
||||||
if close_tag.startswith('</h'):
|
if close_tag.startswith('</h'):
|
||||||
self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
|
self.add_permalink_ref(node.parent, 'headline')
|
||||||
u'title="%s">%s</a>' % (
|
|
||||||
_('Permalink to this headline'),
|
|
||||||
self.permalink_text))
|
|
||||||
elif close_tag.startswith('</a></h'):
|
elif close_tag.startswith('</a></h'):
|
||||||
self.body.append(u'</a><a class="headerlink" href="#%s" ' %
|
self.body.append(u'</a><a class="headerlink" href="#%s" ' %
|
||||||
aname +
|
node.parent['ids'][0] +
|
||||||
u'title="%s">%s' % (
|
u'title="%s">%s' % (
|
||||||
_('Permalink to this headline'),
|
_('Permalink to this headline'),
|
||||||
self.permalink_text))
|
self.permalink_text))
|
||||||
|
elif isinstance(node.parent, nodes.table):
|
||||||
|
self.body.append('</span>')
|
||||||
|
self.add_permalink_ref(node.parent, 'table')
|
||||||
|
|
||||||
BaseTranslator.depart_title(self, node)
|
BaseTranslator.depart_title(self, node)
|
||||||
|
|
||||||
|
@ -305,6 +305,11 @@ class NslessParser(ET.XMLParser):
|
|||||||
|
|
||||||
def check_xpath(etree, fname, path, check, be_found=True):
|
def check_xpath(etree, fname, path, check, be_found=True):
|
||||||
nodes = list(etree.findall(path))
|
nodes = list(etree.findall(path))
|
||||||
|
if check is None:
|
||||||
|
assert nodes == [], ('found any nodes matching xpath '
|
||||||
|
'%r in file %s' % (path, fname))
|
||||||
|
return
|
||||||
|
else:
|
||||||
assert nodes != [], ('did not find any node matching xpath '
|
assert nodes != [], ('did not find any node matching xpath '
|
||||||
'%r in file %s' % (path, fname))
|
'%r in file %s' % (path, fname))
|
||||||
if hasattr(check, '__call__'):
|
if hasattr(check, '__call__'):
|
||||||
@ -464,62 +469,32 @@ def test_numfig(app, status, warning):
|
|||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^should be Fig.1$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//table/caption/span[@class='caption-number']", None, True),
|
||||||
'^should be Fig.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//table/caption", '^should be Table 1$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
(".//table/caption", '^should be Table 2$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 1$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 2$', True),
|
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^should be Fig.1.1$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//table/caption/span[@class='caption-number']", None, True),
|
||||||
'^should be Fig.1.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
"span[@class='caption-number']", None, True),
|
||||||
'^should be Fig.1.3$', True),
|
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
|
||||||
'^should be Fig.1.4$', True),
|
|
||||||
(".//table/caption", '^should be Table 1.1$', True),
|
|
||||||
(".//table/caption", '^should be Table 1.2$', True),
|
|
||||||
(".//table/caption", '^should be Table 1.3$', True),
|
|
||||||
(".//table/caption", '^should be Table 1.4$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 1.1$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 1.2$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 1.3$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 1.4$', True),
|
|
||||||
],
|
],
|
||||||
'bar.html': [
|
'bar.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^should be Fig.2.1$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//table/caption/span[@class='caption-number']", None, True),
|
||||||
'^should be Fig.2.3$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
"span[@class='caption-number']", None, True),
|
||||||
'^should be Fig.2.4$', True),
|
|
||||||
(".//table/caption", '^should be Table 2.1$', True),
|
|
||||||
(".//table/caption", '^should be Table 2.3$', True),
|
|
||||||
(".//table/caption", '^should be Table 2.4$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 2.1$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 2.3$', True),
|
|
||||||
(".//div[@class='code-block-caption']",
|
|
||||||
'^should be List 2.4$', True),
|
|
||||||
],
|
],
|
||||||
'baz.html': [
|
'baz.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^should be Fig.2.2$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
(".//table/caption", '^should be Table 2.2$', True),
|
(".//table/caption/span[@class='caption-number']", None, True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^should be List 2.2$', True),
|
"span[@class='caption-number']", None, True),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,62 +522,72 @@ def test_numfig_without_numbered_toctree(app, status, warning):
|
|||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.9 should be Fig.1$', True),
|
"span[@class='caption-number']", '^Fig.9 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.10 should be Fig.2$', True),
|
"span[@class='caption-number']", '^Fig.10 $', True),
|
||||||
(".//table/caption", '^Table 9 should be Table 1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 10 should be Table 2$', True),
|
'^Table 9 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 9 should be List 1$', True),
|
'^Table 10 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 10 should be List 2$', True),
|
"span[@class='caption-number']", '^List 9 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 10 $', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1 should be Fig.1.1$', True),
|
"span[@class='caption-number']", '^Fig.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2 should be Fig.1.2$', True),
|
"span[@class='caption-number']", '^Fig.2 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.3 should be Fig.1.3$', True),
|
"span[@class='caption-number']", '^Fig.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.4 should be Fig.1.4$', True),
|
"span[@class='caption-number']", '^Fig.4 $', True),
|
||||||
(".//table/caption", '^Table 1 should be Table 1.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 2 should be Table 1.2$', True),
|
'^Table 1 $', True),
|
||||||
(".//table/caption", '^Table 3 should be Table 1.3$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 4 should be Table 1.4$', True),
|
'^Table 2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1 should be List 1.1$', True),
|
'^Table 3 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 2 should be List 1.2$', True),
|
'^Table 4 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 3 should be List 1.3$', True),
|
"span[@class='caption-number']", '^List 1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 4 should be List 1.4$', True),
|
"span[@class='caption-number']", '^List 2 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 4 $', True),
|
||||||
],
|
],
|
||||||
'bar.html': [
|
'bar.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.5 should be Fig.2.1$', True),
|
"span[@class='caption-number']", '^Fig.5 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.7 should be Fig.2.3$', True),
|
"span[@class='caption-number']", '^Fig.7 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.8 should be Fig.2.4$', True),
|
"span[@class='caption-number']", '^Fig.8 $', True),
|
||||||
(".//table/caption", '^Table 5 should be Table 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 7 should be Table 2.3$', True),
|
'^Table 5 $', True),
|
||||||
(".//table/caption", '^Table 8 should be Table 2.4$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 7 $', True),
|
||||||
'^List 5 should be List 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 8 $', True),
|
||||||
'^List 7 should be List 2.3$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='code-block-caption']",
|
"span[@class='caption-number']", '^List 5 $', True),
|
||||||
'^List 8 should be List 2.4$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 7 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 8 $', True),
|
||||||
],
|
],
|
||||||
'baz.html': [
|
'baz.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.6 should be Fig.2.2$', True),
|
"span[@class='caption-number']", '^Fig.6 $', True),
|
||||||
(".//table/caption", '^Table 6 should be Table 2.2$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 6 $', True),
|
||||||
'^List 6 should be List 2.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 6 $', True),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,62 +611,72 @@ def test_numfig_with_numbered_toctree(app, status, warning):
|
|||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1 should be Fig.1$', True),
|
"span[@class='caption-number']", '^Fig.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2 should be Fig.2$', True),
|
"span[@class='caption-number']", '^Fig.2 $', True),
|
||||||
(".//table/caption", '^Table 1 should be Table 1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 2 should be Table 2$', True),
|
'^Table 1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1 should be List 1$', True),
|
'^Table 2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 2 should be List 2$', True),
|
"span[@class='caption-number']", '^List 1 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2 $', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.1 should be Fig.1.1$', True),
|
"span[@class='caption-number']", '^Fig.1.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.2 should be Fig.1.2$', True),
|
"span[@class='caption-number']", '^Fig.1.2 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.3 should be Fig.1.3$', True),
|
"span[@class='caption-number']", '^Fig.1.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.4 should be Fig.1.4$', True),
|
"span[@class='caption-number']", '^Fig.1.4 $', True),
|
||||||
(".//table/caption", '^Table 1.1 should be Table 1.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 1.2 should be Table 1.2$', True),
|
'^Table 1.1 $', True),
|
||||||
(".//table/caption", '^Table 1.3 should be Table 1.3$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 1.4 should be Table 1.4$', True),
|
'^Table 1.2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1.1 should be List 1.1$', True),
|
'^Table 1.3 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1.2 should be List 1.2$', True),
|
'^Table 1.4 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 1.3 should be List 1.3$', True),
|
"span[@class='caption-number']", '^List 1.1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 1.4 should be List 1.4$', True),
|
"span[@class='caption-number']", '^List 1.2 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 1.3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 1.4 $', True),
|
||||||
],
|
],
|
||||||
'bar.html': [
|
'bar.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.1 should be Fig.2.1$', True),
|
"span[@class='caption-number']", '^Fig.2.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.3 should be Fig.2.3$', True),
|
"span[@class='caption-number']", '^Fig.2.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.4 should be Fig.2.4$', True),
|
"span[@class='caption-number']", '^Fig.2.4 $', True),
|
||||||
(".//table/caption", '^Table 2.1 should be Table 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 2.3 should be Table 2.3$', True),
|
'^Table 2.1 $', True),
|
||||||
(".//table/caption", '^Table 2.4 should be Table 2.4$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.3 $', True),
|
||||||
'^List 2.1 should be List 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.4 $', True),
|
||||||
'^List 2.3 should be List 2.3$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='code-block-caption']",
|
"span[@class='caption-number']", '^List 2.1 $', True),
|
||||||
'^List 2.4 should be List 2.4$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.4 $', True),
|
||||||
],
|
],
|
||||||
'baz.html': [
|
'baz.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.2 should be Fig.2.2$', True),
|
"span[@class='caption-number']", '^Fig.2.2 $', True),
|
||||||
(".//table/caption", '^Table 2.2 should be Table 2.2$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.2 $', True),
|
||||||
'^List 2.2 should be List 2.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.2 $', True),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,68 +694,81 @@ def test_numfig_with_numbered_toctree(app, status, warning):
|
|||||||
|
|
||||||
|
|
||||||
@gen_with_app(buildername='html', testroot='numfig',
|
@gen_with_app(buildername='html', testroot='numfig',
|
||||||
confoverrides={'numfig': True, 'numfig_prefix': {'figure': 'Figure:', 'table': 'Tab_', 'code-block': 'Code-'}})
|
confoverrides={'numfig': True,
|
||||||
|
'numfig_prefix': {'figure': 'Figure:',
|
||||||
|
'table': 'Tab_',
|
||||||
|
'code-block': 'Code-'}})
|
||||||
def test_numfig_with_prefix(app, status, warning):
|
def test_numfig_with_prefix(app, status, warning):
|
||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:1 should be Fig.1$', True),
|
"span[@class='caption-number']", '^Figure:1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:2 should be Fig.2$', True),
|
"span[@class='caption-number']", '^Figure:2 $', True),
|
||||||
(".//table/caption", '^Tab_1 should be Table 1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Tab_2 should be Table 2$', True),
|
'^Tab_1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^Code-1 should be List 1$', True),
|
'^Tab_2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^Code-2 should be List 2$', True),
|
"span[@class='caption-number']", '^Code-1 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-2 $', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:1.1 should be Fig.1.1$', True),
|
"span[@class='caption-number']", '^Figure:1.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:1.2 should be Fig.1.2$', True),
|
"span[@class='caption-number']", '^Figure:1.2 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:1.3 should be Fig.1.3$', True),
|
"span[@class='caption-number']", '^Figure:1.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:1.4 should be Fig.1.4$', True),
|
"span[@class='caption-number']", '^Figure:1.4 $', True),
|
||||||
(".//table/caption", '^Tab_1.1 should be Table 1.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Tab_1.2 should be Table 1.2$', True),
|
'^Tab_1.1 $', True),
|
||||||
(".//table/caption", '^Tab_1.3 should be Table 1.3$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Tab_1.4 should be Table 1.4$', True),
|
'^Tab_1.2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^Code-1.1 should be List 1.1$', True),
|
'^Tab_1.3 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^Code-1.2 should be List 1.2$', True),
|
'^Tab_1.4 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^Code-1.3 should be List 1.3$', True),
|
"span[@class='caption-number']", '^Code-1.1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^Code-1.4 should be List 1.4$', True),
|
"span[@class='caption-number']", '^Code-1.2 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-1.3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-1.4 $', True),
|
||||||
],
|
],
|
||||||
'bar.html': [
|
'bar.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:2.1 should be Fig.2.1$', True),
|
"span[@class='caption-number']", '^Figure:2.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:2.3 should be Fig.2.3$', True),
|
"span[@class='caption-number']", '^Figure:2.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:2.4 should be Fig.2.4$', True),
|
"span[@class='caption-number']", '^Figure:2.4 $', True),
|
||||||
(".//table/caption", '^Tab_2.1 should be Table 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Tab_2.3 should be Table 2.3$', True),
|
'^Tab_2.1 $', True),
|
||||||
(".//table/caption", '^Tab_2.4 should be Table 2.4$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Tab_2.3 $', True),
|
||||||
'^Code-2.1 should be List 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Tab_2.4 $', True),
|
||||||
'^Code-2.3 should be List 2.3$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='code-block-caption']",
|
"span[@class='caption-number']", '^Code-2.1 $', True),
|
||||||
'^Code-2.4 should be List 2.4$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-2.3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-2.4 $', True),
|
||||||
],
|
],
|
||||||
'baz.html': [
|
'baz.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Figure:2.2 should be Fig.2.2$', True),
|
"span[@class='caption-number']", '^Figure:2.2 $', True),
|
||||||
(".//table/caption", '^Tab_2.2 should be Table 2.2$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Tab_2.2 $', True),
|
||||||
'^Code-2.2 should be List 2.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^Code-2.2 $', True),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,62 +792,72 @@ def test_numfig_with_secnum_depth(app, status, warning):
|
|||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1 should be Fig.1$', True),
|
"span[@class='caption-number']", '^Fig.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2 should be Fig.2$', True),
|
"span[@class='caption-number']", '^Fig.2 $', True),
|
||||||
(".//table/caption", '^Table 1 should be Table 1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 2 should be Table 2$', True),
|
'^Table 1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1 should be List 1$', True),
|
'^Table 2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 2 should be List 2$', True),
|
"span[@class='caption-number']", '^List 1 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2 $', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.1 should be Fig.1.1$', True),
|
"span[@class='caption-number']", '^Fig.1.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.1.1 should be Fig.1.2$', True),
|
"span[@class='caption-number']", '^Fig.1.1.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.1.2 should be Fig.1.3$', True),
|
"span[@class='caption-number']", '^Fig.1.1.2 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.1.2.1 should be Fig.1.4$', True),
|
"span[@class='caption-number']", '^Fig.1.2.1 $', True),
|
||||||
(".//table/caption", '^Table 1.1 should be Table 1.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 1.1.1 should be Table 1.2$', True),
|
'^Table 1.1 $', True),
|
||||||
(".//table/caption", '^Table 1.1.2 should be Table 1.3$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 1.2.1 should be Table 1.4$', True),
|
'^Table 1.1.1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1.1 should be List 1.1$', True),
|
'^Table 1.1.2 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//table/caption/span[@class='caption-number']",
|
||||||
'^List 1.1.1 should be List 1.2$', True),
|
'^Table 1.2.1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 1.1.2 should be List 1.3$', True),
|
"span[@class='caption-number']", '^List 1.1 $', True),
|
||||||
(".//div[@class='code-block-caption']",
|
(".//div[@class='code-block-caption']/"
|
||||||
'^List 1.2.1 should be List 1.4$', True),
|
"span[@class='caption-number']", '^List 1.1.1 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 1.1.2 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 1.2.1 $', True),
|
||||||
],
|
],
|
||||||
'bar.html': [
|
'bar.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.1.1 should be Fig.2.1$', True),
|
"span[@class='caption-number']", '^Fig.2.1.1 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.1.3 should be Fig.2.3$', True),
|
"span[@class='caption-number']", '^Fig.2.1.3 $', True),
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.2.1 should be Fig.2.4$', True),
|
"span[@class='caption-number']", '^Fig.2.2.1 $', True),
|
||||||
(".//table/caption", '^Table 2.1.1 should be Table 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//table/caption", '^Table 2.1.3 should be Table 2.3$', True),
|
'^Table 2.1.1 $', True),
|
||||||
(".//table/caption", '^Table 2.2.1 should be Table 2.4$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.1.3 $', True),
|
||||||
'^List 2.1.1 should be List 2.1$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.2.1 $', True),
|
||||||
'^List 2.1.3 should be List 2.3$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
(".//div[@class='code-block-caption']",
|
"span[@class='caption-number']", '^List 2.1.1 $', True),
|
||||||
'^List 2.2.1 should be List 2.4$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.1.3 $', True),
|
||||||
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.2.1 $', True),
|
||||||
],
|
],
|
||||||
'baz.html': [
|
'baz.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']",
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
'^Fig.2.1.2 should be Fig.2.2$', True),
|
"span[@class='caption-number']", '^Fig.2.1.2 $', True),
|
||||||
(".//table/caption", '^Table 2.1.2 should be Table 2.2$', True),
|
(".//table/caption/span[@class='caption-number']",
|
||||||
(".//div[@class='code-block-caption']",
|
'^Table 2.1.2 $', True),
|
||||||
'^List 2.1.2 should be List 2.2$', True),
|
(".//div[@class='code-block-caption']/"
|
||||||
|
"span[@class='caption-number']", '^List 2.1.2 $', True),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,11 @@ def test_code_block_dedent(app, status, warning):
|
|||||||
@with_app('html', testroot='directive-code')
|
@with_app('html', testroot='directive-code')
|
||||||
def test_code_block_caption_html(app, status, warning):
|
def test_code_block_caption_html(app, status, warning):
|
||||||
app.builder.build(['caption'])
|
app.builder.build(['caption'])
|
||||||
html = (app.outdir / 'caption.html').text()
|
html = (app.outdir / 'caption.html').text(encoding='utf-8')
|
||||||
caption = '<div class="code-block-caption">caption <em>test</em> rb</div>'
|
caption = (u'<div class="code-block-caption">'
|
||||||
|
u'<span class="caption-text">caption <em>test</em> rb'
|
||||||
|
u'</span><a class="headerlink" href="#id1" '
|
||||||
|
u'title="Permalink to this code">\xb6</a></div>')
|
||||||
assert caption in html
|
assert caption in html
|
||||||
|
|
||||||
|
|
||||||
@ -98,8 +101,11 @@ def test_literal_include_dedent(app, status, warning):
|
|||||||
@with_app('html', testroot='directive-code')
|
@with_app('html', testroot='directive-code')
|
||||||
def test_literalinclude_caption_html(app, status, warning):
|
def test_literalinclude_caption_html(app, status, warning):
|
||||||
app.builder.build('index')
|
app.builder.build('index')
|
||||||
html = (app.outdir / 'caption.html').text()
|
html = (app.outdir / 'caption.html').text(encoding='utf-8')
|
||||||
caption = '<div class="code-block-caption">caption <strong>test</strong> py</div>'
|
caption = (u'<div class="code-block-caption">'
|
||||||
|
u'<span class="caption-text">caption <strong>test</strong> py'
|
||||||
|
u'</span><a class="headerlink" href="#id2" '
|
||||||
|
u'title="Permalink to this code">\xb6</a></div>')
|
||||||
assert caption in html
|
assert caption in html
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user