Skip to content

Commit

Permalink
Merge branch '3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Aug 1, 2020
2 parents 49018ec + 5e6da19 commit 9969239
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Expand Up @@ -54,6 +54,7 @@ Incompatible changes
Deprecated
----------

* ``sphinx.writers.texinfo.TexinfoWriter.desc``
* C, parsing of pre-v3 style type directives and roles, along with the options
:confval:`c_allow_pre_v3` and :confval:`c_warn_on_allowed_pre_v3`.

Expand Down Expand Up @@ -120,6 +121,8 @@ Bugs fixed
translation
* #7768: i18n: The ``root`` element for :confval:`figure_language_filename` is
not a path that user specifies in the document
* #7993: texinfo: TypeError is raised for nested object descriptions
* #7993: texinfo: a warning not supporting desc_signature_line node is shown
* #7869: :rst:role:`abbr` role without an explanation will show the explanation
from the previous abbr role
* C and C++, removed ``noindex`` directive option as it did
Expand Down
5 changes: 5 additions & 0 deletions doc/extdev/deprecated.rst
Expand Up @@ -56,6 +56,11 @@ The following is a list of deprecated interfaces.
- 6.0
- ``docutils.utils.smartyquotes``

* - ``sphinx.writers.texinfo.TexinfoWriter.desc``
- 3.2
- 5.0
- ``sphinx.writers.texinfo.TexinfoWriter.descs``

* - The first argument for
``sphinx.ext.autosummary.generate.AutosummaryRenderer`` has been changed
to Sphinx object
Expand Down
2 changes: 1 addition & 1 deletion sphinx/util/inspect.py
Expand Up @@ -482,7 +482,7 @@ def evaluate_signature(sig: inspect.Signature, globalns: Dict = None, localns: D
"""Evaluate unresolved type annotations in a signature object."""
def evaluate_forwardref(ref: ForwardRef, globalns: Dict, localns: Dict) -> Any:
"""Evaluate a forward reference."""
if sys.version_info > (3, 10):
if sys.version_info > (3, 9):
return ref._evaluate(globalns, localns, frozenset())
else:
return ref._evaluate(globalns, localns)
Expand Down
32 changes: 24 additions & 8 deletions sphinx/writers/texinfo.py
Expand Up @@ -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
Expand Down Expand Up @@ -188,6 +190,7 @@ def __init__(self, document: nodes.document, builder: "TexinfoBuilder") -> None:

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
Expand Down Expand Up @@ -1364,12 +1367,12 @@ def visit_acks(self, node: Element) -> None:

# -- 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')

Expand Down Expand Up @@ -1398,6 +1401,12 @@ def depart_desc_signature(self, node: Element) -> None:
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

Expand Down Expand Up @@ -1453,9 +1462,8 @@ def visit_desc_annotation(self, node: Element) -> None:
# -- 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:
Expand Down Expand Up @@ -1525,3 +1533,11 @@ def visit_math_block(self, node: Element) -> None:
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

0 comments on commit 9969239

Please sign in to comment.