diff --git a/CHANGES b/CHANGES index 198a49291..0c66ae2e1 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,8 @@ Bugs fixed begin with -, / or +. Thanks to Takayuki Hirai. * #1753: C++, added missing support for more complex declarations. * #1700: Add ``:caption:`` option for :rst:dir:`toctree`. +* #1742: ``:name:`` option is provided for :rst:dir:`toctree`, :rst:dir:`code-block` and + :rst:dir:`literalinclude` dirctives. Release 1.3b3 (released Feb 24, 2015) diff --git a/doc/markup/code.rst b/doc/markup/code.rst index 9a503519d..c76726441 100644 --- a/doc/markup/code.rst +++ b/doc/markup/code.rst @@ -214,23 +214,26 @@ Includes The ``lineno-match`` option. -Showing a file name -^^^^^^^^^^^^^^^^^^^ +Caption and name +^^^^^^^^^^^^^^^^ .. versionadded:: 1.3 -A ``caption`` option can be given to show that name before the code block. For -example:: +A ``caption`` option can be given to show that name before the code block. +A ``name`` option can be provided implicit target name that can be referenced +by using :rst:role:`ref`. +For example:: .. code-block:: python :caption: this.py + :name: this-py print 'Explicit is better than implicit.' -:rst:dir:`literalinclude` also supports the ``caption`` option, with the -additional feature that if you leave the value empty, the shown filename will be -exactly the one given as an argument. +:rst:dir:`literalinclude` also supports the ``caption`` and ``name`` option. +``caption`` has a additional feature that if you leave the value empty, the shown +filename will be exactly the one given as an argument. Dedent diff --git a/doc/markup/toctree.rst b/doc/markup/toctree.rst index 7c6cbc44c..ff0af7535 100644 --- a/doc/markup/toctree.rst +++ b/doc/markup/toctree.rst @@ -85,10 +85,13 @@ tables of contents. The ``toctree`` directive is the central element. **Additional options** - You can use ``caption`` option to provide toctree caption:: + You can use ``caption`` option to provide toctree caption and you can use + ``name`` option to provide implicit target name that can be referenced by + using :rst:role:`ref`:: .. toctree:: :caption: Table of Contents + :name: mastertoc foo @@ -176,7 +179,7 @@ tables of contents. The ``toctree`` directive is the central element. Added "includehidden" option. .. versionchanged:: 1.3 - Added "caption" option. + Added "caption" and "name" option. Special names ------------- diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index ea28ff1ed..1f7a856a7 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -93,6 +93,7 @@ class CodeBlock(Directive): 'lineno-start': int, 'emphasize-lines': directives.unchanged_required, 'caption': directives.unchanged_required, + 'name': directives.unchanged, } def run(self): @@ -127,8 +128,13 @@ class CodeBlock(Directive): caption = self.options.get('caption') if caption: + self.options.setdefault('name', nodes.fully_normalize_name(caption)) literal = container_wrapper(self, literal, caption) + # literal will be note_implicit_target that is linked from caption and numref. + # when options['name'] is provided, it should be primary ID. + self.add_name(literal) + return [literal] @@ -159,6 +165,7 @@ class LiteralInclude(Directive): 'append': directives.unchanged_required, 'emphasize-lines': directives.unchanged_required, 'caption': directives.unchanged, + 'name': directives.unchanged, 'diff': directives.unchanged_required, } @@ -332,10 +339,14 @@ class LiteralInclude(Directive): caption = self.options.get('caption') if caption is not None: - if caption: - retnode = container_wrapper(self, retnode, caption) - else: - retnode = container_wrapper(self, retnode, self.arguments[0]) + if not caption: + caption = self.arguments[0] + self.options.setdefault('name', nodes.fully_normalize_name(caption)) + retnode = container_wrapper(self, retnode, caption) + + # retnode will be note_implicit_target that is linked from caption and numref. + # when options['name'] is provided, it should be primary ID. + self.add_name(retnode) return [retnode] diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 1acf9593e..d83c0ca90 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -40,7 +40,8 @@ class TocTree(Directive): final_argument_whitespace = False option_spec = { 'maxdepth': int, - 'caption': str, + 'name': directives.unchanged, + 'caption': directives.unchanged_required, 'glob': directives.flag, 'hidden': directives.flag, 'includehidden': directives.flag, @@ -54,7 +55,7 @@ class TocTree(Directive): glob = 'glob' in self.options caption = self.options.get('caption') if caption: - self.options['name'] = nodes.fully_normalize_name(caption) + self.options.setdefault('name', nodes.fully_normalize_name(caption)) ret = [] # (title, ref) pairs, where ref may be a document, or an external link, diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 83b10b6f9..8b685b43d 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -503,7 +503,7 @@ class ASTOperatorBuildIn(ASTBase): def get_name_no_template(self): return text_type(self) - def describe_signature(self, signode, mode, env, prefix): + def describe_signature(self, signode, mode, env, prefix, parentScope): _verify_description_mode(mode) identifier = text_type(self) if mode == 'lastIsName': @@ -528,7 +528,7 @@ class ASTOperatorType(ASTBase): def get_name_no_template(self): return text_type(self) - def describe_signature(self, signode, mode, env, prefix): + def describe_signature(self, signode, mode, env, prefix, parentScope): _verify_description_mode(mode) identifier = text_type(self) if mode == 'lastIsName': @@ -552,7 +552,7 @@ class ASTTemplateArgConstant(ASTBase): # juse it verbatim for now return u'X' + text_type(self) + u'E' - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) signode += nodes.Text(text_type(self)) @@ -569,7 +569,7 @@ class ASTNestedNameElementEmpty(ASTBase): def __unicode__(self): return u'' - def describe_signature(self, signode, mode, env, prefix): + def describe_signature(self, signode, mode, env, prefix, parentScope): pass @@ -624,15 +624,14 @@ class ASTNestedNameElement(ASTBase): def get_name_no_template(self): return text_type(self.identifier) - def describe_signature(self, signode, mode, env, prefix): + def describe_signature(self, signode, mode, env, prefix, parentScope): _verify_description_mode(mode) if mode == 'markType': targetText = prefix + text_type(self) pnode = addnodes.pending_xref( '', refdomain='cpp', reftype='type', reftarget=targetText, modname=None, classname=None) - if env: # during testing we don't have an env, do we? - pnode['cpp:parent'] = env.ref_context.get('cpp:parent') + pnode['cpp:parent'] = [parentScope] pnode += nodes.Text(text_type(self.identifier)) signode += pnode elif mode == 'lastIsName': @@ -647,7 +646,8 @@ class ASTNestedNameElement(ASTBase): if not first: signode += nodes.Text(', ') first = False - a.describe_signature(signode, 'markType', env) + a.describe_signature(signode, 'markType', env, + parentScope=parentScope) signode += nodes.Text('>') @@ -702,7 +702,7 @@ class ASTNestedName(ASTBase): def __unicode__(self): return u'::'.join([text_type(n) for n in self.names]) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) if mode == 'lastIsName': addname = u'::'.join([text_type(n) for n in self.names[:-1]]) @@ -710,7 +710,8 @@ class ASTNestedName(ASTBase): addname += u'::' name = text_type(self.names[-1]) signode += addnodes.desc_addname(addname, addname) - self.names[-1].describe_signature(signode, mode, env, '') + self.names[-1].describe_signature(signode, mode, env, '', + parentScope=parentScope) elif mode == 'noneIsName': name = text_type(self) signode += nodes.Text(name) @@ -729,7 +730,8 @@ class ASTNestedName(ASTBase): prefix += '::' first = False if name != '': - name.describe_signature(signode, mode, env, prefix) + name.describe_signature(signode, mode, env, prefix, + parentScope=parentScope) prefix += text_type(name) else: raise Exception('Unknown description mode: %s' % mode) @@ -759,7 +761,7 @@ class ASTTrailingTypeSpecFundamental(ASTBase): 'parser should have rejected it.' % self.name) return _id_fundamental_v2[self.name] - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): signode += nodes.Text(text_type(self.name)) @@ -786,11 +788,12 @@ class ASTTrailingTypeSpecName(ASTBase): res.append(text_type(self.nestedName)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): if self.prefix: signode += addnodes.desc_annotation(self.prefix, self.prefix) signode += nodes.Text(' ') - self.nestedName.describe_signature(signode, mode, env) + self.nestedName.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTFunctinoParameter(ASTBase): @@ -816,12 +819,13 @@ class ASTFunctinoParameter(ASTBase): else: return text_type(self.arg) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) if self.ellipsis: signode += nodes.Text('...') else: - self.arg.describe_signature(signode, mode, env) + self.arg.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTParametersQualifiers(ASTBase): @@ -905,15 +909,17 @@ class ASTParametersQualifiers(ASTBase): res.append(self.initializer) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) paramlist = addnodes.desc_parameterlist() for arg in self.args: param = addnodes.desc_parameter('', '', noemph=True) if mode == 'lastIsName': # i.e., outer-function params - arg.describe_signature(param, 'param', env) + arg.describe_signature(param, 'param', env, + parentScope=parentScope) else: - arg.describe_signature(param, 'markType', env) + arg.describe_signature(param, 'markType', env, + parentScope=parentScope) paramlist += param signode += paramlist @@ -1058,7 +1064,7 @@ class ASTDeclSpecs(ASTBase): res.append(r) return "".join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) modifiers = [] @@ -1076,7 +1082,8 @@ class ASTDeclSpecs(ASTBase): if self.trailingTypeSpec: if len(modifiers) > 0: signode += nodes.Text(' ') - self.trailingTypeSpec.describe_signature(signode, mode, env) + self.trailingTypeSpec.describe_signature(signode, mode, env, + parentScope=parentScope) modifiers = [] self.rightSpecs.describe_signature(modifiers) if len(modifiers) > 0: @@ -1176,10 +1183,11 @@ class ASTDeclaratorPtr(ASTBase): def is_function_type(self): return self.next.is_function_type() - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) signode += nodes.Text("*") - self.next.describe_signature(signode, mode, env) + self.next.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTDeclaratorRef(ASTBase): @@ -1228,10 +1236,11 @@ class ASTDeclaratorRef(ASTBase): def is_function_type(self): return self.next.is_function_type() - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) signode += nodes.Text("&") - self.next.describe_signature(signode, mode, env) + self.next.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTDeclaratorParamPack(ASTBase): @@ -1283,12 +1292,13 @@ class ASTDeclaratorParamPack(ASTBase): def is_function_type(self): return self.next.is_function_type() - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) signode += nodes.Text("...") if self.next.name: signode += nodes.Text(' ') - self.next.describe_signature(signode, mode, env) + self.next.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTDeclaratorParen(ASTBase): @@ -1348,12 +1358,14 @@ class ASTDeclaratorParen(ASTBase): def is_function_type(self): return self.inner.is_function_type() - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) signode += nodes.Text('(') - self.inner.describe_signature(signode, mode, env) + self.inner.describe_signature(signode, mode, env, + parentScope=parentScope) signode += nodes.Text(')') - self.next.describe_signature(signode, "noneIsName", env) + self.next.describe_signature(signode, "noneIsName", env, + parentScope=parentScope) class ASTDecleratorNameParamQual(ASTBase): @@ -1434,14 +1446,16 @@ class ASTDecleratorNameParamQual(ASTBase): res.append(text_type(self.paramQual)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) if self.declId: - self.declId.describe_signature(signode, mode, env) + self.declId.describe_signature(signode, mode, env, + parentScope=parentScope) for op in self.arrayOps: op.describe_signature(signode, mode, env) if self.paramQual: - self.paramQual.describe_signature(signode, mode, env) + self.paramQual.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTInitializer(ASTBase): @@ -1523,13 +1537,15 @@ class ASTType(ASTBase): res.append(text_type(self.decl)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) - self.declSpecs.describe_signature(signode, 'markType', env) + self.declSpecs.describe_signature(signode, 'markType', env, + parentScope=parentScope) if (self.decl.require_space_after_declSpecs() and len(text_type(self.declSpecs)) > 0): signode += nodes.Text(' ') - self.decl.describe_signature(signode, mode, env) + self.decl.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTTypeWithInit(ASTBase): @@ -1561,9 +1577,10 @@ class ASTTypeWithInit(ASTBase): res.append(text_type(self.init)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) - self.type.describe_signature(signode, mode, env) + self.type.describe_signature(signode, mode, env, + parentScope=parentScope) if self.init: self.init.describe_signature(signode, mode) @@ -1581,13 +1598,14 @@ class ASTBaseClass(ASTBase): res.append(text_type(self.name)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) if self.visibility != 'private': - signode += addnodes.desc_annotation( - self.visibility, self.visibility) + signode += addnodes.desc_annotation(self.visibility, + self.visibility) signode += nodes.Text(' ') - self.name.describe_signature(signode, mode, env) + self.name.describe_signature(signode, mode, env, + parentScope=parentScope) class ASTClass(ASTBase): @@ -1622,17 +1640,19 @@ class ASTClass(ASTBase): res.append(text_type(b)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) if self.visibility != 'public': signode += addnodes.desc_annotation( self.visibility, self.visibility) signode += nodes.Text(' ') - self.name.describe_signature(signode, mode, env) + self.name.describe_signature(signode, mode, env, + parentScope=parentScope) if len(self.bases) > 0: signode += nodes.Text(' : ') for b in self.bases: - b.describe_signature(signode, mode, env) + b.describe_signature(signode, mode, env, + parentScope=parentScope) signode += nodes.Text(', ') signode.pop() @@ -1664,17 +1684,19 @@ class ASTEnum(ASTBase): res.append(text_type(self.underlyingType)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) # self.scoped has been done by the CPPEnumObject if self.visibility != 'public': signode += addnodes.desc_annotation( self.visibility, self.visibility) signode += nodes.Text(' ') - self.name.describe_signature(signode, mode, env) + self.name.describe_signature(signode, mode, env, + parentScope=parentScope) if self.underlyingType: signode += nodes.Text(' : ') - self.underlyingType.describe_signature(signode, 'noneIsName', env) + self.underlyingType.describe_signature(signode, 'noneIsName', env, + parentScope=parentScope) class ASTEnumerator(ASTBase): @@ -1695,9 +1717,10 @@ class ASTEnumerator(ASTBase): res.append(text_type(self.init)) return u''.join(res) - def describe_signature(self, signode, mode, env): + def describe_signature(self, signode, mode, env, parentScope): _verify_description_mode(mode) - self.name.describe_signature(signode, mode, env) + self.name.describe_signature(signode, mode, env, + parentScope=parentScope) if self.init: self.init.describe_signature(signode, 'noneIsName') @@ -2456,7 +2479,7 @@ class CPPObject(ObjectDescription): def parse_definition(self, parser): raise NotImplementedError() - def describe_signature(self, signode, ast): + def describe_signature(self, signode, ast, parentScope): raise NotImplementedError() def handle_signature(self, sig, signode): @@ -2484,10 +2507,9 @@ class CPPObject(ObjectDescription): ]) set_lastname(name) raise ValueError - self.describe_signature(signode, ast) - ast.prefixedName = set_lastname(ast.name) assert ast.prefixedName + self.describe_signature(signode, ast, parentScope=ast.prefixedName) return ast @@ -2498,9 +2520,10 @@ class CPPTypeObject(CPPObject): def parse_definition(self, parser): return parser.parse_type_object() - def describe_signature(self, signode, ast): + def describe_signature(self, signode, ast, parentScope): signode += addnodes.desc_annotation('type ', 'type ') - ast.describe_signature(signode, 'lastIsName', self.env) + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPMemberObject(CPPObject): @@ -2510,8 +2533,9 @@ class CPPMemberObject(CPPObject): def parse_definition(self, parser): return parser.parse_member_object() - def describe_signature(self, signode, ast): - ast.describe_signature(signode, 'lastIsName', self.env) + def describe_signature(self, signode, ast, parentScope): + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPFunctionObject(CPPObject): @@ -2521,8 +2545,9 @@ class CPPFunctionObject(CPPObject): def parse_definition(self, parser): return parser.parse_function_object() - def describe_signature(self, signode, ast): - ast.describe_signature(signode, 'lastIsName', self.env) + def describe_signature(self, signode, ast, parentScope): + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPClassObject(CPPObject): @@ -2543,9 +2568,10 @@ class CPPClassObject(CPPObject): def parse_definition(self, parser): return parser.parse_class_object() - def describe_signature(self, signode, ast): + def describe_signature(self, signode, ast, parentScope): signode += addnodes.desc_annotation('class ', 'class ') - ast.describe_signature(signode, 'lastIsName', self.env) + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPEnumObject(CPPObject): @@ -2576,13 +2602,14 @@ class CPPEnumObject(CPPObject): assert False return ast - def describe_signature(self, signode, ast): + def describe_signature(self, signode, ast, parentScope): prefix = 'enum ' if ast.scoped: prefix += ast.scoped prefix += ' ' signode += addnodes.desc_annotation(prefix, prefix) - ast.describe_signature(signode, 'lastIsName', self.env) + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPEnumeratorObject(CPPObject): @@ -2592,9 +2619,10 @@ class CPPEnumeratorObject(CPPObject): def parse_definition(self, parser): return parser.parse_enumerator_object() - def describe_signature(self, signode, ast): + def describe_signature(self, signode, ast, parentScope): signode += addnodes.desc_annotation('enumerator ', 'enumerator ') - ast.describe_signature(signode, 'lastIsName', self.env) + ast.describe_signature(signode, 'lastIsName', self.env, + parentScope=parentScope) class CPPNamespaceObject(Directive): diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 6b94b3000..1184672b2 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -574,6 +574,12 @@ class StandardDomain(Domain): break else: continue + elif node.traverse(addnodes.toctree): + n = node.traverse(addnodes.toctree)[0] + if n.get('caption'): + sectname = n['caption'] + else: + continue else: # anonymous-only labels continue diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 931d95aaa..4e4c117fc 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -487,6 +487,10 @@ def get_figtype(node): from docutils import nodes if isinstance(node, nodes.figure): return 'figure' + elif isinstance(node, nodes.image) and isinstance(node.parent, nodes.figure): + # bare image node is not supported because it doesn't have caption and + # no-caption-target isn't a numbered figure. + return 'figure' elif isinstance(node, nodes.table): return 'table' elif isinstance(node, nodes.container): diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 393fb7d03..102ac6703 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -333,7 +333,8 @@ class HTMLTranslator(BaseTranslator): if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'): self.add_permalink_ref(node.parent, _('Permalink to this code')) elif isinstance(node.parent, nodes.figure): - self.add_permalink_ref(node.parent, _('Permalink to this image')) + self.add_permalink_ref( + node.parent.traverse(nodes.image)[0], _('Permalink to this image')) elif node.parent.get('toctree'): self.add_permalink_ref(node.parent.parent, _('Permalink to this toctree')) diff --git a/tests/root/contents.txt b/tests/root/contents.txt index dbc6f5be1..bee6a896e 100644 --- a/tests/root/contents.txt +++ b/tests/root/contents.txt @@ -10,6 +10,8 @@ Contents: .. toctree:: :maxdepth: 2 :numbered: + :caption: Table of Contents + :name: mastertoc extapi images @@ -54,3 +56,9 @@ This used to crash: .. toctree:: :hidden: + +Test for issue #1700 +==================== + +:ref:`mastertoc` + diff --git a/tests/root/markup.txt b/tests/root/markup.txt index 63afc3083..de1bcaecb 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -141,11 +141,17 @@ Adding \n to test unescaping. * :ref:`admonition-section` * :ref:`here ` * :ref:`my-figure` +* :ref:`my-figure-name` * :ref:`my-table` +* :ref:`my-table-name` * :ref:`my-code-block` +* :ref:`my-code-block-name` * :numref:`my-figure` +* :numref:`my-figure-name` * :numref:`my-table` +* :numref:`my-table-name` * :numref:`my-code-block` +* :numref:`my-code-block-name` * :doc:`subdir/includes` * ``:download:`` is tested in includes.txt * :option:`Python -c option ` @@ -172,6 +178,7 @@ Tables .. _my-table: .. table:: my table + :name: my-table-name +----+----------------+----+ | 1 | * Block elems | x | @@ -199,6 +206,7 @@ Figures .. _my-figure: .. figure:: img.png + :name: my-figure-name My caption of the figure @@ -237,6 +245,7 @@ Code blocks .. code-block:: ruby :linenos: :caption: my ruby code + :name: my-code-block-name def ruby? false diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index f9c334b38..bdc04a819 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -256,8 +256,8 @@ def test_numref_with_language_ja(app, status, warning): print(result) print(status.getvalue()) print(warning.getvalue()) - assert '\\renewcommand{\\figurename}{Fig. }\n' in result - assert '\\renewcommand{\\tablename}{Table }\n' in result + assert '\\renewcommand{\\figurename}{Fig. }' in result + assert '\\renewcommand{\\tablename}{Table }' in result assert '\\floatname{literal-block}{Listing }' in result assert '\\hyperref[index:fig1]{Fig. \\ref{index:fig1}}' in result assert '\\hyperref[baz:fig22]{Figure\\ref{baz:fig22}}' in result diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py index d8cb2794c..ba4687cc0 100644 --- a/tests/test_directive_code.py +++ b/tests/test_directive_code.py @@ -55,7 +55,7 @@ def test_code_block_caption_html(app, status, warning): html = (app.outdir / 'caption.html').text(encoding='utf-8') caption = (u'
' u'caption test rb' - u'\xb6
') assert caption in html @@ -178,7 +178,7 @@ def test_literalinclude_caption_html(app, status, warning): html = (app.outdir / 'caption.html').text(encoding='utf-8') caption = (u'
' u'caption test py' - u'\xb6
') assert caption in html diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 93f1c153a..886fe8031 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -38,7 +38,7 @@ def check(name, input, idv1output=None, idv2output=None, output=None): print("Result: ", res) print("Expected: ", output) raise DefinitionError("") - ast.describe_signature([], 'lastIsName', None) + ast.describe_signature([], 'lastIsName', None, parentScope=ast.name) # Artificially set the prefixedName, otherwise the get_id fails. # It would usually have been set in handle_signarue. ast.prefixedName = ast.name