diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-08-01 12:08:23 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-08-01 12:08:23 +0300 |
commit | 9969239b2255bb145052d7e5aef56e44db15cb5b (patch) | |
tree | 89d2fc289b81dcbfde7722726f6a90d5811ad653 /sphinx/writers/texinfo.py | |
parent | 49018ec68d15d116728e57714a746057baf79006 (diff) | |
parent | 5e6da19f0e44a0ae83944fb6ce18f18f781e1a6e (diff) |
Merge branch '3.x'
Diffstat (limited to 'sphinx/writers/texinfo.py')
-rw-r--r-- | sphinx/writers/texinfo.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 317c6231b..5a7f616ad 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -10,14 +10,16 @@ import re import textwrap +import warnings from os import path -from typing import Any, Dict, Iterable, Iterator, List, Pattern, Set, Tuple, Union +from typing import Any, Dict, Iterable, Iterator, List, Optional, Pattern, Set, Tuple, Union from typing import TYPE_CHECKING, cast from docutils import nodes, writers from docutils.nodes import Element, Node, Text from sphinx import addnodes, __display_version__ +from sphinx.deprecation import RemovedInSphinx50Warning from sphinx.domains import IndexEntry from sphinx.domains.index import IndexDomain from sphinx.errors import ExtensionError @@ -188,6 +190,7 @@ class TexinfoTranslator(SphinxTranslator): self.body = [] # type: List[str] self.context = [] # type: List[str] + self.descs = [] # type: List[addnodes.desc] self.previous_section = None # type: nodes.section self.section_level = 0 self.seen_title = False @@ -1364,12 +1367,12 @@ class TexinfoTranslator(SphinxTranslator): # -- Desc - def visit_desc(self, node: Element) -> None: - self.desc = node + def visit_desc(self, node: addnodes.desc) -> None: + self.descs.append(node) self.at_deffnx = '@deffn' - def depart_desc(self, node: Element) -> None: - self.desc = None + def depart_desc(self, node: addnodes.desc) -> None: + self.descs.pop() self.ensure_eol() self.body.append('@end deffn\n') @@ -1398,6 +1401,12 @@ class TexinfoTranslator(SphinxTranslator): self.escape_hyphens -= 1 self.desc_type_name = None + def visit_desc_signature_line(self, node: Element) -> None: + pass + + def depart_desc_signature_line(self, node: Element) -> None: + pass + def visit_desc_name(self, node: Element) -> None: pass @@ -1453,9 +1462,8 @@ class TexinfoTranslator(SphinxTranslator): # -- instead of -- # @deffn {Class} class Foo txt = node.astext().strip() - if txt == self.desc['desctype'] or \ - txt == self.desc['objtype'] or \ - txt in self.desc_type_name.split(): + if ((self.descs and txt == self.descs[-1]['objtype']) or + (self.desc_type_name and txt in self.desc_type_name.split())): raise nodes.SkipNode def depart_desc_annotation(self, node: Element) -> None: @@ -1525,3 +1533,11 @@ class TexinfoTranslator(SphinxTranslator): self.body.append('\n\n@example\n%s\n@end example\n\n' % self.escape_arg(node.astext())) raise nodes.SkipNode + + @property + def desc(self) -> Optional[addnodes.desc]: + warnings.warn('TexinfoWriter.desc is deprecated.', RemovedInSphinx50Warning) + if len(self.descs): + return self.descs[-1] + else: + return None |