mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7301: capital characters are not allowed for node_id
This commit is contained in:
parent
70c61e44c3
commit
7aa5584a47
1
CHANGES
1
CHANGES
@ -26,6 +26,7 @@ Bugs fixed
|
|||||||
* #6477: Escape first "!" in a cross reference linking no longer possible
|
* #6477: Escape first "!" in a cross reference linking no longer possible
|
||||||
* #7219: py domain: The index entry generated by ``py:function`` directive is
|
* #7219: py domain: The index entry generated by ``py:function`` directive is
|
||||||
different with one from ``index`` directive with "builtin" type
|
different with one from ``index`` directive with "builtin" type
|
||||||
|
* #7301: capital characters are not allowed for node_id
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -445,6 +445,7 @@ def _make_id(string: str) -> str:
|
|||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
|
|
||||||
|
* Allow to use capital alphabet characters
|
||||||
* Allow to use dots (".") and underscores ("_") for an identifier
|
* Allow to use dots (".") and underscores ("_") for an identifier
|
||||||
without a leading character.
|
without a leading character.
|
||||||
|
|
||||||
@ -452,8 +453,7 @@ def _make_id(string: str) -> str:
|
|||||||
# Maintainer: docutils-develop@lists.sourceforge.net
|
# Maintainer: docutils-develop@lists.sourceforge.net
|
||||||
# Copyright: This module has been placed in the public domain.
|
# Copyright: This module has been placed in the public domain.
|
||||||
"""
|
"""
|
||||||
id = string.lower()
|
id = string.translate(_non_id_translate_digraphs)
|
||||||
id = id.translate(_non_id_translate_digraphs)
|
|
||||||
id = id.translate(_non_id_translate)
|
id = id.translate(_non_id_translate)
|
||||||
# get rid of non-ascii characters.
|
# get rid of non-ascii characters.
|
||||||
# 'ascii' lowercase to prevent problems with turkish locale.
|
# 'ascii' lowercase to prevent problems with turkish locale.
|
||||||
@ -464,7 +464,7 @@ def _make_id(string: str) -> str:
|
|||||||
return str(id)
|
return str(id)
|
||||||
|
|
||||||
|
|
||||||
_non_id_chars = re.compile('[^a-z0-9._]+')
|
_non_id_chars = re.compile('[^a-zA-Z0-9._]+')
|
||||||
_non_id_at_ends = re.compile('^[-0-9._]+|-+$')
|
_non_id_at_ends = re.compile('^[-0-9._]+|-+$')
|
||||||
_non_id_translate = {
|
_non_id_translate = {
|
||||||
0x00f8: u'o', # o with stroke
|
0x00f8: u'o', # o with stroke
|
||||||
|
@ -320,13 +320,13 @@ def test_epub_anchor_id(app):
|
|||||||
app.build()
|
app.build()
|
||||||
|
|
||||||
html = (app.outdir / 'index.xhtml').read_text()
|
html = (app.outdir / 'index.xhtml').read_text()
|
||||||
assert ('<p id="std-setting-staticfiles_finders">'
|
assert ('<p id="std-setting-STATICFILES_FINDERS">'
|
||||||
'<span id="std-setting-STATICFILES_FINDERS"></span>'
|
'<span id="std-setting-STATICFILES_FINDERS"></span>'
|
||||||
'blah blah blah</p>' in html)
|
'blah blah blah</p>' in html)
|
||||||
assert ('<span id="std-setting-staticfiles_section"></span>'
|
assert ('<span id="std-setting-STATICFILES_SECTION"></span>'
|
||||||
'<span id="std-setting-STATICFILES_SECTION"></span>'
|
'<span id="std-setting-STATICFILES_SECTION"></span>'
|
||||||
'<h1>blah blah blah</h1>' in html)
|
'<h1>blah blah blah</h1>' in html)
|
||||||
assert 'see <a class="reference internal" href="#std-setting-staticfiles_finders">' in html
|
assert 'see <a class="reference internal" href="#std-setting-STATICFILES_FINDERS">' in html
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('epub', testroot='html_assets')
|
@pytest.mark.sphinx('epub', testroot='html_assets')
|
||||||
|
@ -176,7 +176,7 @@ def test_html4_output(app, status, warning):
|
|||||||
r'-| |-'),
|
r'-| |-'),
|
||||||
],
|
],
|
||||||
'autodoc.html': [
|
'autodoc.html': [
|
||||||
(".//dl[@class='py class']/dt[@id='autodoc_target.class']", ''),
|
(".//dl[@class='py class']/dt[@id='autodoc_target.Class']", ''),
|
||||||
(".//dl[@class='py function']/dt[@id='autodoc_target.function']/em/span", r'\*\*'),
|
(".//dl[@class='py function']/dt[@id='autodoc_target.function']/em/span", r'\*\*'),
|
||||||
(".//dl[@class='py function']/dt[@id='autodoc_target.function']/em/span", r'kwds'),
|
(".//dl[@class='py function']/dt[@id='autodoc_target.function']/em/span", r'kwds'),
|
||||||
(".//dd/p", r'Return spam\.'),
|
(".//dd/p", r'Return spam\.'),
|
||||||
@ -219,7 +219,7 @@ def test_html4_output(app, status, warning):
|
|||||||
"[@class='rfc reference external']/strong", 'RFC 1'),
|
"[@class='rfc reference external']/strong", 'RFC 1'),
|
||||||
(".//a[@href='https://tools.ietf.org/html/rfc1.html']"
|
(".//a[@href='https://tools.ietf.org/html/rfc1.html']"
|
||||||
"[@class='rfc reference external']/strong", 'Request for Comments #1'),
|
"[@class='rfc reference external']/strong", 'Request for Comments #1'),
|
||||||
(".//a[@href='objects.html#envvar-home']"
|
(".//a[@href='objects.html#envvar-HOME']"
|
||||||
"[@class='reference internal']/code/span[@class='pre']", 'HOME'),
|
"[@class='reference internal']/code/span[@class='pre']", 'HOME'),
|
||||||
(".//a[@href='#with']"
|
(".//a[@href='#with']"
|
||||||
"[@class='reference internal']/code/span[@class='pre']", '^with$'),
|
"[@class='reference internal']/code/span[@class='pre']", '^with$'),
|
||||||
@ -275,18 +275,18 @@ def test_html4_output(app, status, warning):
|
|||||||
(".//p", 'Il dit : « C’est “super” ! »'),
|
(".//p", 'Il dit : « C’est “super” ! »'),
|
||||||
],
|
],
|
||||||
'objects.html': [
|
'objects.html': [
|
||||||
(".//dt[@id='mod.cls.meth1']", ''),
|
(".//dt[@id='mod.Cls.meth1']", ''),
|
||||||
(".//dt[@id='errmod.error']", ''),
|
(".//dt[@id='errmod.Error']", ''),
|
||||||
(".//dt/code", r'long\(parameter,\s* list\)'),
|
(".//dt/code", r'long\(parameter,\s* list\)'),
|
||||||
(".//dt/code", 'another one'),
|
(".//dt/code", 'another one'),
|
||||||
(".//a[@href='#mod.cls'][@class='reference internal']", ''),
|
(".//a[@href='#mod.Cls'][@class='reference internal']", ''),
|
||||||
(".//dl[@class='std userdesc']", ''),
|
(".//dl[@class='std userdesc']", ''),
|
||||||
(".//dt[@id='userdesc-myobj']", ''),
|
(".//dt[@id='userdesc-myobj']", ''),
|
||||||
(".//a[@href='#userdesc-myobj'][@class='reference internal']", ''),
|
(".//a[@href='#userdesc-myobj'][@class='reference internal']", ''),
|
||||||
# docfields
|
# docfields
|
||||||
(".//a[@class='reference internal'][@href='#timeint']/em", 'TimeInt'),
|
(".//a[@class='reference internal'][@href='#TimeInt']/em", 'TimeInt'),
|
||||||
(".//a[@class='reference internal'][@href='#time']", 'Time'),
|
(".//a[@class='reference internal'][@href='#Time']", 'Time'),
|
||||||
(".//a[@class='reference internal'][@href='#errmod.error']/strong", 'Error'),
|
(".//a[@class='reference internal'][@href='#errmod.Error']/strong", 'Error'),
|
||||||
# C references
|
# C references
|
||||||
(".//span[@class='pre']", 'CFunction()'),
|
(".//span[@class='pre']", 'CFunction()'),
|
||||||
(".//a[@href='#c.Sphinx_DoSomething']", ''),
|
(".//a[@href='#c.Sphinx_DoSomething']", ''),
|
||||||
@ -323,7 +323,7 @@ def test_html4_output(app, status, warning):
|
|||||||
'perl'),
|
'perl'),
|
||||||
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
|
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
|
||||||
'\\+p'),
|
'\\+p'),
|
||||||
(".//a[@class='reference internal'][@href='#cmdoption-perl-objc']/code/span",
|
(".//a[@class='reference internal'][@href='#cmdoption-perl-ObjC']/code/span",
|
||||||
'--ObjC\\+\\+'),
|
'--ObjC\\+\\+'),
|
||||||
(".//a[@class='reference internal'][@href='#cmdoption-perl-plugin.option']/code/span",
|
(".//a[@class='reference internal'][@href='#cmdoption-perl-plugin.option']/code/span",
|
||||||
'--plugin.option'),
|
'--plugin.option'),
|
||||||
|
@ -120,25 +120,25 @@ def test_domain_js_find_obj(app, status, warning):
|
|||||||
|
|
||||||
assert (find_obj(None, None, 'NONEXISTANT', 'class') == (None, None))
|
assert (find_obj(None, None, 'NONEXISTANT', 'class') == (None, None))
|
||||||
assert (find_obj(None, None, 'NestedParentA', 'class') ==
|
assert (find_obj(None, None, 'NestedParentA', 'class') ==
|
||||||
('NestedParentA', ('roles', 'nestedparenta', 'class')))
|
('NestedParentA', ('roles', 'NestedParentA', 'class')))
|
||||||
assert (find_obj(None, None, 'NestedParentA.NestedChildA', 'class') ==
|
assert (find_obj(None, None, 'NestedParentA.NestedChildA', 'class') ==
|
||||||
('NestedParentA.NestedChildA',
|
('NestedParentA.NestedChildA',
|
||||||
('roles', 'nestedparenta.nestedchilda', 'class')))
|
('roles', 'NestedParentA.NestedChildA', 'class')))
|
||||||
assert (find_obj(None, 'NestedParentA', 'NestedChildA', 'class') ==
|
assert (find_obj(None, 'NestedParentA', 'NestedChildA', 'class') ==
|
||||||
('NestedParentA.NestedChildA',
|
('NestedParentA.NestedChildA',
|
||||||
('roles', 'nestedparenta.nestedchilda', 'class')))
|
('roles', 'NestedParentA.NestedChildA', 'class')))
|
||||||
assert (find_obj(None, None, 'NestedParentA.NestedChildA.subchild_1', 'func') ==
|
assert (find_obj(None, None, 'NestedParentA.NestedChildA.subchild_1', 'func') ==
|
||||||
('NestedParentA.NestedChildA.subchild_1',
|
('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'function')))
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'function')))
|
||||||
assert (find_obj(None, 'NestedParentA', 'NestedChildA.subchild_1', 'func') ==
|
assert (find_obj(None, 'NestedParentA', 'NestedChildA.subchild_1', 'func') ==
|
||||||
('NestedParentA.NestedChildA.subchild_1',
|
('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'function')))
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'function')))
|
||||||
assert (find_obj(None, 'NestedParentA.NestedChildA', 'subchild_1', 'func') ==
|
assert (find_obj(None, 'NestedParentA.NestedChildA', 'subchild_1', 'func') ==
|
||||||
('NestedParentA.NestedChildA.subchild_1',
|
('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'function')))
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'function')))
|
||||||
assert (find_obj('module_a.submodule', 'ModTopLevel', 'mod_child_2', 'meth') ==
|
assert (find_obj('module_a.submodule', 'ModTopLevel', 'mod_child_2', 'meth') ==
|
||||||
('module_a.submodule.ModTopLevel.mod_child_2',
|
('module_a.submodule.ModTopLevel.mod_child_2',
|
||||||
('module', 'module_a.submodule.modtoplevel.mod_child_2', 'method')))
|
('module', 'module_a.submodule.ModTopLevel.mod_child_2', 'method')))
|
||||||
assert (find_obj('module_b.submodule', 'ModTopLevel', 'module_a.submodule', 'mod') ==
|
assert (find_obj('module_b.submodule', 'ModTopLevel', 'module_a.submodule', 'mod') ==
|
||||||
('module_a.submodule',
|
('module_a.submodule',
|
||||||
('module', 'module-module_a.submodule', 'module')))
|
('module', 'module-module_a.submodule', 'module')))
|
||||||
@ -205,7 +205,7 @@ def test_js_class(app):
|
|||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()])]))
|
[desc_content, ()])]))
|
||||||
assert_node(doctree[0], addnodes.index,
|
assert_node(doctree[0], addnodes.index,
|
||||||
entries=[("single", "Application() (class)", "application", "", None)])
|
entries=[("single", "Application() (class)", "Application", "", None)])
|
||||||
assert_node(doctree[1], addnodes.desc, domain="js", objtype="class", noindex=False)
|
assert_node(doctree[1], addnodes.desc, domain="js", objtype="class", noindex=False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,11 +171,11 @@ def test_resolve_xref_for_properties(app, status, warning):
|
|||||||
app.builder.build_all()
|
app.builder.build_all()
|
||||||
|
|
||||||
content = (app.outdir / 'module.html').read_text()
|
content = (app.outdir / 'module.html').read_text()
|
||||||
assert ('Link to <a class="reference internal" href="#module_a.submodule.modtoplevel.prop"'
|
assert ('Link to <a class="reference internal" href="#module_a.submodule.ModTopLevel.prop"'
|
||||||
' title="module_a.submodule.ModTopLevel.prop">'
|
' title="module_a.submodule.ModTopLevel.prop">'
|
||||||
'<code class="xref py py-attr docutils literal notranslate"><span class="pre">'
|
'<code class="xref py py-attr docutils literal notranslate"><span class="pre">'
|
||||||
'prop</span> <span class="pre">attribute</span></code></a>' in content)
|
'prop</span> <span class="pre">attribute</span></code></a>' in content)
|
||||||
assert ('Link to <a class="reference internal" href="#module_a.submodule.modtoplevel.prop"'
|
assert ('Link to <a class="reference internal" href="#module_a.submodule.ModTopLevel.prop"'
|
||||||
' title="module_a.submodule.ModTopLevel.prop">'
|
' title="module_a.submodule.ModTopLevel.prop">'
|
||||||
'<code class="xref py py-meth docutils literal notranslate"><span class="pre">'
|
'<code class="xref py py-meth docutils literal notranslate"><span class="pre">'
|
||||||
'prop</span> <span class="pre">method</span></code></a>' in content)
|
'prop</span> <span class="pre">method</span></code></a>' in content)
|
||||||
@ -192,20 +192,20 @@ def test_domain_py_find_obj(app, status, warning):
|
|||||||
|
|
||||||
assert (find_obj(None, None, 'NONEXISTANT', 'class') == [])
|
assert (find_obj(None, None, 'NONEXISTANT', 'class') == [])
|
||||||
assert (find_obj(None, None, 'NestedParentA', 'class') ==
|
assert (find_obj(None, None, 'NestedParentA', 'class') ==
|
||||||
[('NestedParentA', ('roles', 'nestedparenta', 'class'))])
|
[('NestedParentA', ('roles', 'NestedParentA', 'class'))])
|
||||||
assert (find_obj(None, None, 'NestedParentA.NestedChildA', 'class') ==
|
assert (find_obj(None, None, 'NestedParentA.NestedChildA', 'class') ==
|
||||||
[('NestedParentA.NestedChildA', ('roles', 'nestedparenta.nestedchilda', 'class'))])
|
[('NestedParentA.NestedChildA', ('roles', 'NestedParentA.NestedChildA', 'class'))])
|
||||||
assert (find_obj(None, 'NestedParentA', 'NestedChildA', 'class') ==
|
assert (find_obj(None, 'NestedParentA', 'NestedChildA', 'class') ==
|
||||||
[('NestedParentA.NestedChildA', ('roles', 'nestedparenta.nestedchilda', 'class'))])
|
[('NestedParentA.NestedChildA', ('roles', 'NestedParentA.NestedChildA', 'class'))])
|
||||||
assert (find_obj(None, None, 'NestedParentA.NestedChildA.subchild_1', 'meth') ==
|
assert (find_obj(None, None, 'NestedParentA.NestedChildA.subchild_1', 'meth') ==
|
||||||
[('NestedParentA.NestedChildA.subchild_1',
|
[('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'method'))])
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
|
||||||
assert (find_obj(None, 'NestedParentA', 'NestedChildA.subchild_1', 'meth') ==
|
assert (find_obj(None, 'NestedParentA', 'NestedChildA.subchild_1', 'meth') ==
|
||||||
[('NestedParentA.NestedChildA.subchild_1',
|
[('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'method'))])
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
|
||||||
assert (find_obj(None, 'NestedParentA.NestedChildA', 'subchild_1', 'meth') ==
|
assert (find_obj(None, 'NestedParentA.NestedChildA', 'subchild_1', 'meth') ==
|
||||||
[('NestedParentA.NestedChildA.subchild_1',
|
[('NestedParentA.NestedChildA.subchild_1',
|
||||||
('roles', 'nestedparenta.nestedchilda.subchild_1', 'method'))])
|
('roles', 'NestedParentA.NestedChildA.subchild_1', 'method'))])
|
||||||
|
|
||||||
|
|
||||||
def test_get_full_qualified_name():
|
def test_get_full_qualified_name():
|
||||||
@ -525,61 +525,61 @@ def test_pymethod_options(app):
|
|||||||
|
|
||||||
# method
|
# method
|
||||||
assert_node(doctree[1][1][0], addnodes.index,
|
assert_node(doctree[1][1][0], addnodes.index,
|
||||||
entries=[('single', 'meth1() (Class method)', 'class.meth1', '', None)])
|
entries=[('single', 'meth1() (Class method)', 'Class.meth1', '', None)])
|
||||||
assert_node(doctree[1][1][1], ([desc_signature, ([desc_name, "meth1"],
|
assert_node(doctree[1][1][1], ([desc_signature, ([desc_name, "meth1"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth1' in domain.objects
|
assert 'Class.meth1' in domain.objects
|
||||||
assert domain.objects['Class.meth1'] == ('index', 'class.meth1', 'method')
|
assert domain.objects['Class.meth1'] == ('index', 'Class.meth1', 'method')
|
||||||
|
|
||||||
# :classmethod:
|
# :classmethod:
|
||||||
assert_node(doctree[1][1][2], addnodes.index,
|
assert_node(doctree[1][1][2], addnodes.index,
|
||||||
entries=[('single', 'meth2() (Class class method)', 'class.meth2', '', None)])
|
entries=[('single', 'meth2() (Class class method)', 'Class.meth2', '', None)])
|
||||||
assert_node(doctree[1][1][3], ([desc_signature, ([desc_annotation, "classmethod "],
|
assert_node(doctree[1][1][3], ([desc_signature, ([desc_annotation, "classmethod "],
|
||||||
[desc_name, "meth2"],
|
[desc_name, "meth2"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth2' in domain.objects
|
assert 'Class.meth2' in domain.objects
|
||||||
assert domain.objects['Class.meth2'] == ('index', 'class.meth2', 'method')
|
assert domain.objects['Class.meth2'] == ('index', 'Class.meth2', 'method')
|
||||||
|
|
||||||
# :staticmethod:
|
# :staticmethod:
|
||||||
assert_node(doctree[1][1][4], addnodes.index,
|
assert_node(doctree[1][1][4], addnodes.index,
|
||||||
entries=[('single', 'meth3() (Class static method)', 'class.meth3', '', None)])
|
entries=[('single', 'meth3() (Class static method)', 'Class.meth3', '', None)])
|
||||||
assert_node(doctree[1][1][5], ([desc_signature, ([desc_annotation, "static "],
|
assert_node(doctree[1][1][5], ([desc_signature, ([desc_annotation, "static "],
|
||||||
[desc_name, "meth3"],
|
[desc_name, "meth3"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth3' in domain.objects
|
assert 'Class.meth3' in domain.objects
|
||||||
assert domain.objects['Class.meth3'] == ('index', 'class.meth3', 'method')
|
assert domain.objects['Class.meth3'] == ('index', 'Class.meth3', 'method')
|
||||||
|
|
||||||
# :async:
|
# :async:
|
||||||
assert_node(doctree[1][1][6], addnodes.index,
|
assert_node(doctree[1][1][6], addnodes.index,
|
||||||
entries=[('single', 'meth4() (Class method)', 'class.meth4', '', None)])
|
entries=[('single', 'meth4() (Class method)', 'Class.meth4', '', None)])
|
||||||
assert_node(doctree[1][1][7], ([desc_signature, ([desc_annotation, "async "],
|
assert_node(doctree[1][1][7], ([desc_signature, ([desc_annotation, "async "],
|
||||||
[desc_name, "meth4"],
|
[desc_name, "meth4"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth4' in domain.objects
|
assert 'Class.meth4' in domain.objects
|
||||||
assert domain.objects['Class.meth4'] == ('index', 'class.meth4', 'method')
|
assert domain.objects['Class.meth4'] == ('index', 'Class.meth4', 'method')
|
||||||
|
|
||||||
# :property:
|
# :property:
|
||||||
assert_node(doctree[1][1][8], addnodes.index,
|
assert_node(doctree[1][1][8], addnodes.index,
|
||||||
entries=[('single', 'meth5() (Class property)', 'class.meth5', '', None)])
|
entries=[('single', 'meth5() (Class property)', 'Class.meth5', '', None)])
|
||||||
assert_node(doctree[1][1][9], ([desc_signature, ([desc_annotation, "property "],
|
assert_node(doctree[1][1][9], ([desc_signature, ([desc_annotation, "property "],
|
||||||
[desc_name, "meth5"])],
|
[desc_name, "meth5"])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth5' in domain.objects
|
assert 'Class.meth5' in domain.objects
|
||||||
assert domain.objects['Class.meth5'] == ('index', 'class.meth5', 'method')
|
assert domain.objects['Class.meth5'] == ('index', 'Class.meth5', 'method')
|
||||||
|
|
||||||
# :abstractmethod:
|
# :abstractmethod:
|
||||||
assert_node(doctree[1][1][10], addnodes.index,
|
assert_node(doctree[1][1][10], addnodes.index,
|
||||||
entries=[('single', 'meth6() (Class method)', 'class.meth6', '', None)])
|
entries=[('single', 'meth6() (Class method)', 'Class.meth6', '', None)])
|
||||||
assert_node(doctree[1][1][11], ([desc_signature, ([desc_annotation, "abstract "],
|
assert_node(doctree[1][1][11], ([desc_signature, ([desc_annotation, "abstract "],
|
||||||
[desc_name, "meth6"],
|
[desc_name, "meth6"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth6' in domain.objects
|
assert 'Class.meth6' in domain.objects
|
||||||
assert domain.objects['Class.meth6'] == ('index', 'class.meth6', 'method')
|
assert domain.objects['Class.meth6'] == ('index', 'Class.meth6', 'method')
|
||||||
|
|
||||||
|
|
||||||
def test_pyclassmethod(app):
|
def test_pyclassmethod(app):
|
||||||
@ -594,13 +594,13 @@ def test_pyclassmethod(app):
|
|||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
assert_node(doctree[1][1][0], addnodes.index,
|
assert_node(doctree[1][1][0], addnodes.index,
|
||||||
entries=[('single', 'meth() (Class class method)', 'class.meth', '', None)])
|
entries=[('single', 'meth() (Class class method)', 'Class.meth', '', None)])
|
||||||
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "classmethod "],
|
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "classmethod "],
|
||||||
[desc_name, "meth"],
|
[desc_name, "meth"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth' in domain.objects
|
assert 'Class.meth' in domain.objects
|
||||||
assert domain.objects['Class.meth'] == ('index', 'class.meth', 'method')
|
assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method')
|
||||||
|
|
||||||
|
|
||||||
def test_pystaticmethod(app):
|
def test_pystaticmethod(app):
|
||||||
@ -615,13 +615,13 @@ def test_pystaticmethod(app):
|
|||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
assert_node(doctree[1][1][0], addnodes.index,
|
assert_node(doctree[1][1][0], addnodes.index,
|
||||||
entries=[('single', 'meth() (Class static method)', 'class.meth', '', None)])
|
entries=[('single', 'meth() (Class static method)', 'Class.meth', '', None)])
|
||||||
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "static "],
|
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "static "],
|
||||||
[desc_name, "meth"],
|
[desc_name, "meth"],
|
||||||
[desc_parameterlist, ()])],
|
[desc_parameterlist, ()])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.meth' in domain.objects
|
assert 'Class.meth' in domain.objects
|
||||||
assert domain.objects['Class.meth'] == ('index', 'class.meth', 'method')
|
assert domain.objects['Class.meth'] == ('index', 'Class.meth', 'method')
|
||||||
|
|
||||||
|
|
||||||
def test_pyattribute(app):
|
def test_pyattribute(app):
|
||||||
@ -638,13 +638,13 @@ def test_pyattribute(app):
|
|||||||
[desc_content, (addnodes.index,
|
[desc_content, (addnodes.index,
|
||||||
desc)])]))
|
desc)])]))
|
||||||
assert_node(doctree[1][1][0], addnodes.index,
|
assert_node(doctree[1][1][0], addnodes.index,
|
||||||
entries=[('single', 'attr (Class attribute)', 'class.attr', '', None)])
|
entries=[('single', 'attr (Class attribute)', 'Class.attr', '', None)])
|
||||||
assert_node(doctree[1][1][1], ([desc_signature, ([desc_name, "attr"],
|
assert_node(doctree[1][1][1], ([desc_signature, ([desc_name, "attr"],
|
||||||
[desc_annotation, ": str"],
|
[desc_annotation, ": str"],
|
||||||
[desc_annotation, " = ''"])],
|
[desc_annotation, " = ''"])],
|
||||||
[desc_content, ()]))
|
[desc_content, ()]))
|
||||||
assert 'Class.attr' in domain.objects
|
assert 'Class.attr' in domain.objects
|
||||||
assert domain.objects['Class.attr'] == ('index', 'class.attr', 'attribute')
|
assert domain.objects['Class.attr'] == ('index', 'Class.attr', 'attribute')
|
||||||
|
|
||||||
|
|
||||||
def test_pydecorator_signature(app):
|
def test_pydecorator_signature(app):
|
||||||
|
@ -353,23 +353,23 @@ def test_productionlist(app, status, warning):
|
|||||||
linkText = span.text.strip()
|
linkText = span.text.strip()
|
||||||
cases.append((text, link, linkText))
|
cases.append((text, link, linkText))
|
||||||
assert cases == [
|
assert cases == [
|
||||||
('A', 'Bare.html#grammar-token-a', 'A'),
|
('A', 'Bare.html#grammar-token-A', 'A'),
|
||||||
('B', 'Bare.html#grammar-token-b', 'B'),
|
('B', 'Bare.html#grammar-token-B', 'B'),
|
||||||
('P1:A', 'P1.html#grammar-token-p1-a', 'P1:A'),
|
('P1:A', 'P1.html#grammar-token-P1-A', 'P1:A'),
|
||||||
('P1:B', 'P1.html#grammar-token-p1-b', 'P1:B'),
|
('P1:B', 'P1.html#grammar-token-P1-B', 'P1:B'),
|
||||||
('P2:A', 'P1.html#grammar-token-p1-a', 'P1:A'),
|
('P2:A', 'P1.html#grammar-token-P1-A', 'P1:A'),
|
||||||
('P2:B', 'P2.html#grammar-token-p2-b', 'P2:B'),
|
('P2:B', 'P2.html#grammar-token-P2-B', 'P2:B'),
|
||||||
('Explicit title A, plain', 'Bare.html#grammar-token-a', 'MyTitle'),
|
('Explicit title A, plain', 'Bare.html#grammar-token-A', 'MyTitle'),
|
||||||
('Explicit title A, colon', 'Bare.html#grammar-token-a', 'My:Title'),
|
('Explicit title A, colon', 'Bare.html#grammar-token-A', 'My:Title'),
|
||||||
('Explicit title P1:A, plain', 'P1.html#grammar-token-p1-a', 'MyTitle'),
|
('Explicit title P1:A, plain', 'P1.html#grammar-token-P1-A', 'MyTitle'),
|
||||||
('Explicit title P1:A, colon', 'P1.html#grammar-token-p1-a', 'My:Title'),
|
('Explicit title P1:A, colon', 'P1.html#grammar-token-P1-A', 'My:Title'),
|
||||||
('Tilde A', 'Bare.html#grammar-token-a', 'A'),
|
('Tilde A', 'Bare.html#grammar-token-A', 'A'),
|
||||||
('Tilde P1:A', 'P1.html#grammar-token-p1-a', 'A'),
|
('Tilde P1:A', 'P1.html#grammar-token-P1-A', 'A'),
|
||||||
('Tilde explicit title P1:A', 'P1.html#grammar-token-p1-a', '~MyTitle'),
|
('Tilde explicit title P1:A', 'P1.html#grammar-token-P1-A', '~MyTitle'),
|
||||||
('Tilde, explicit title P1:A', 'P1.html#grammar-token-p1-a', 'MyTitle'),
|
('Tilde, explicit title P1:A', 'P1.html#grammar-token-P1-A', 'MyTitle'),
|
||||||
('Dup', 'Dup2.html#grammar-token-dup', 'Dup'),
|
('Dup', 'Dup2.html#grammar-token-Dup', 'Dup'),
|
||||||
('FirstLine', 'firstLineRule.html#grammar-token-firstline', 'FirstLine'),
|
('FirstLine', 'firstLineRule.html#grammar-token-FirstLine', 'FirstLine'),
|
||||||
('SecondLine', 'firstLineRule.html#grammar-token-secondline', 'SecondLine'),
|
('SecondLine', 'firstLineRule.html#grammar-token-SecondLine', 'SecondLine'),
|
||||||
]
|
]
|
||||||
|
|
||||||
text = (app.outdir / 'LineContinuation.html').read_text()
|
text = (app.outdir / 'LineContinuation.html').read_text()
|
||||||
|
@ -161,5 +161,5 @@ def test_create_index_by_key(app):
|
|||||||
index = IndexEntries(app.env).create_index(app.builder)
|
index = IndexEntries(app.env).create_index(app.builder)
|
||||||
assert len(index) == 3
|
assert len(index) == 3
|
||||||
assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])])
|
assert index[0] == ('D', [('docutils', [[('main', '#term-docutils')], [], None])])
|
||||||
assert index[1] == ('P', [('Python', [[('main', '#term-python')], [], None])])
|
assert index[1] == ('P', [('Python', [[('main', '#term-Python')], [], None])])
|
||||||
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-0')], [], 'ス'])])
|
assert index[2] == ('ス', [('スフィンクス', [[('main', '#term-0')], [], 'ス'])])
|
||||||
|
@ -946,14 +946,14 @@ def test_xml_role_xref(app):
|
|||||||
['LINK TO', "I18N ROCK'N ROLE XREF", ',', 'CONTENTS', ',',
|
['LINK TO', "I18N ROCK'N ROLE XREF", ',', 'CONTENTS', ',',
|
||||||
'SOME NEW TERM', '.'],
|
'SOME NEW TERM', '.'],
|
||||||
['i18n-role-xref', 'index',
|
['i18n-role-xref', 'index',
|
||||||
'glossary_terms#term-some-term'])
|
'glossary_terms#term-Some-term'])
|
||||||
|
|
||||||
para2 = sec2.findall('paragraph')
|
para2 = sec2.findall('paragraph')
|
||||||
assert_elem(
|
assert_elem(
|
||||||
para2[0],
|
para2[0],
|
||||||
['LINK TO', 'SOME OTHER NEW TERM', 'AND', 'SOME NEW TERM', '.'],
|
['LINK TO', 'SOME OTHER NEW TERM', 'AND', 'SOME NEW TERM', '.'],
|
||||||
['glossary_terms#term-some-other-term',
|
['glossary_terms#term-Some-other-term',
|
||||||
'glossary_terms#term-some-term'])
|
'glossary_terms#term-Some-term'])
|
||||||
assert_elem(
|
assert_elem(
|
||||||
para2[1],
|
para2[1],
|
||||||
['LINK TO', 'SAME TYPE LINKS', 'AND',
|
['LINK TO', 'SAME TYPE LINKS', 'AND',
|
||||||
|
@ -188,13 +188,13 @@ def test_clean_astext():
|
|||||||
[
|
[
|
||||||
('', '', 'id0'),
|
('', '', 'id0'),
|
||||||
('term', '', 'term-0'),
|
('term', '', 'term-0'),
|
||||||
('term', 'Sphinx', 'term-sphinx'),
|
('term', 'Sphinx', 'term-Sphinx'),
|
||||||
('', 'io.StringIO', 'io.stringio'), # contains a dot
|
('', 'io.StringIO', 'io.StringIO'), # contains a dot
|
||||||
('', 'sphinx.setup_command', 'sphinx.setup_command'), # contains a dot & underscore
|
('', 'sphinx.setup_command', 'sphinx.setup_command'), # contains a dot & underscore
|
||||||
('', '_io.StringIO', 'io.stringio'), # starts with underscore
|
('', '_io.StringIO', 'io.StringIO'), # starts with underscore
|
||||||
('', 'sphinx', 'sphinx'), # alphabets in unicode fullwidth characters
|
('', 'sphinx', 'sphinx'), # alphabets in unicode fullwidth characters
|
||||||
('', '悠好', 'id0'), # multibytes text (in Chinese)
|
('', '悠好', 'id0'), # multibytes text (in Chinese)
|
||||||
('', 'Hello=悠好=こんにちは', 'hello'), # alphabets and multibytes text
|
('', 'Hello=悠好=こんにちは', 'Hello'), # alphabets and multibytes text
|
||||||
('', 'fünf', 'funf'), # latin1 (umlaut)
|
('', 'fünf', 'funf'), # latin1 (umlaut)
|
||||||
('', '0sphinx', 'sphinx'), # starts with number
|
('', '0sphinx', 'sphinx'), # starts with number
|
||||||
('', 'sphinx-', 'sphinx'), # ends with hyphen
|
('', 'sphinx-', 'sphinx'), # ends with hyphen
|
||||||
@ -206,7 +206,7 @@ def test_make_id(app, prefix, term, expected):
|
|||||||
|
|
||||||
def test_make_id_already_registered(app):
|
def test_make_id_already_registered(app):
|
||||||
document = create_new_document()
|
document = create_new_document()
|
||||||
document.ids['term-sphinx'] = True # register "term-sphinx" manually
|
document.ids['term-Sphinx'] = True # register "term-Sphinx" manually
|
||||||
assert make_id(app.env, document, 'term', 'Sphinx') == 'term-0'
|
assert make_id(app.env, document, 'term', 'Sphinx') == 'term-0'
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user