mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Handle older docutils
This commit is contained in:
parent
f21b9d5892
commit
29a3fd0acb
@ -29,11 +29,11 @@ def register_sections_as_label(app, document):
|
|||||||
for node in document.traverse(nodes.section):
|
for node in document.traverse(nodes.section):
|
||||||
labelid = node['ids'][0]
|
labelid = node['ids'][0]
|
||||||
docname = app.env.docname
|
docname = app.env.docname
|
||||||
|
ref_name = getattr(node[0], 'rawsource', node[0].astext())
|
||||||
if app.config.autosectionlabel_prefix_document:
|
if app.config.autosectionlabel_prefix_document:
|
||||||
name = nodes.fully_normalize_name(
|
name = nodes.fully_normalize_name(docname + ':' + ref_name)
|
||||||
docname + ':' + node[0].rawsource)
|
|
||||||
else:
|
else:
|
||||||
name = nodes.fully_normalize_name(node[0].rawsource)
|
name = nodes.fully_normalize_name(ref_name)
|
||||||
sectname = clean_astext(node[0])
|
sectname = clean_astext(node[0])
|
||||||
|
|
||||||
if name in labels:
|
if name in labels:
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -35,6 +36,16 @@ def test_autosectionlabel_html(app, status, warning):
|
|||||||
'<span class="std std-ref">For UNIX users</span></a></li>')
|
'<span class="std std-ref">For UNIX users</span></a></li>')
|
||||||
assert re.search(html, content, re.S)
|
assert re.search(html, content, re.S)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
os.environ.get('DOCUTILS', None) not in ('0.13.1', '0.14'),
|
||||||
|
reason='Requires docutils >= 0.13.1',
|
||||||
|
)
|
||||||
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel')
|
||||||
|
def test_autosectionlabel_html_apostrophe(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
|
||||||
|
content = (app.outdir / 'index.html').text()
|
||||||
html = ('<li><a class="reference internal" '
|
html = ('<li><a class="reference internal" '
|
||||||
'href="#this-one-s-got-an-apostrophe">'
|
'href="#this-one-s-got-an-apostrophe">'
|
||||||
'<span class="std std-ref">This one’s got an apostrophe'
|
'<span class="std std-ref">This one’s got an apostrophe'
|
||||||
@ -46,3 +57,13 @@ def test_autosectionlabel_html(app, status, warning):
|
|||||||
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
||||||
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
def test_autosectionlabel_prefix_document_html(app, status, warning):
|
||||||
return test_autosectionlabel_html(app, status, warning)
|
return test_autosectionlabel_html(app, status, warning)
|
||||||
|
|
||||||
|
|
||||||
|
# Re-use test definition from above, just change the test root directory
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
os.environ.get('DOCUTILS', None) not in ('0.13.1', '0.14'),
|
||||||
|
reason='Requires docutils >= 0.13.1',
|
||||||
|
)
|
||||||
|
@pytest.mark.sphinx('html', testroot='ext-autosectionlabel-prefix-document')
|
||||||
|
def test_autosectionlabel_prefix_document_html_apostrophe(app, status, warning):
|
||||||
|
return test_autosectionlabel_html_apostrophe(app, status, warning)
|
||||||
|
Loading…
Reference in New Issue
Block a user