Esempio n. 1
0
from sphinx.util.nodes import set_source_info

if False:
    # For type annotation
    from typing import Any, Dict, List  # NOQA
    from sphinx.application import Sphinx  # NOQA
    from sphinx.environment import BuildEnvironment  # NOQA

versionlabels = {
    'versionadded': _('New in version %s'),
    'versionchanged': _('Changed in version %s'),
    'deprecated': _('Deprecated since version %s'),
}  # type: Dict[unicode, unicode]

locale.versionlabels = DeprecatedDict(
    versionlabels, 'sphinx.locale.versionlabels is deprecated. '
    'Please use sphinx.domains.changeset.versionlabels instead.',
    RemovedInSphinx30Warning)

ChangeSet = NamedTuple('ChangeSet', [('type', str), ('docname', str),
                                     ('lineno', int), ('module', str),
                                     ('descname', str), ('content', str)])


class VersionChange(SphinxDirective):
    """
    Directive to describe a change/addition/deprecation in a specific version.
    """
    has_content = True
    required_arguments = 1
    optional_arguments = 1
    final_argument_whitespace = True
Esempio n. 2
0
          ''', re.VERBOSE)


pairindextypes = {
    'module':    _('module'),
    'keyword':   _('keyword'),
    'operator':  _('operator'),
    'object':    _('object'),
    'exception': _('exception'),
    'statement': _('statement'),
    'builtin':   _('built-in function'),
}  # Dict[unicode, unicode]

locale.pairindextypes = DeprecatedDict(
    pairindextypes,
    'sphinx.locale.pairindextypes is deprecated. '
    'Please use sphinx.domains.python.pairindextypes instead.',
    RemovedInSphinx30Warning
)


def _pseudo_parse_arglist(signode, arglist):
    # type: (addnodes.desc_signature, unicode) -> None
    """"Parse" a list of arguments separated by commas.

    Arguments can have "optional" annotations given by enclosing them in
    brackets.  Currently, this will split at any comma, even if it's inside a
    string literal (e.g. default argument value).
    """
    paramlist = addnodes.desc_parameterlist()
    stack = [paramlist]
    try:
Esempio n. 3
0
if False:
    # For type annotation
    from typing import Any, Dict, List, Tuple  # NOQA
    from sphinx.application import Sphinx  # NOQA


versionlabels = {
    'versionadded':   _('New in version %s'),
    'versionchanged': _('Changed in version %s'),
    'deprecated':     _('Deprecated since version %s'),
}  # type: Dict[unicode, unicode]

locale.versionlabels = DeprecatedDict(
    versionlabels,
    'sphinx.locale.versionlabels is deprecated. '
    'Please use sphinx.directives.other.versionlabels instead.',
    RemovedInSphinx30Warning
)


def int_or_nothing(argument):
    # type: (unicode) -> int
    if not argument:
        return 999
    return int(argument)


class TocTree(Directive):
    """
    Directive to notify Sphinx about the hierarchical structure of the docs,
    and to include a table-of-contents like tree in the current document.