"""
This type stub file was generated by pyright.
"""

import re
import unicodedata
from __future__ import annotations
from typing import Any, TYPE_CHECKING, cast
from docutils import nodes
from docutils.transforms import Transform, Transformer
from docutils.transforms.parts import ContentsFilter
from docutils.transforms.universal import SmartQuotes
from docutils.utils import normalize_language_tag
from docutils.utils.smartquotes import smartchars
from sphinx import addnodes
from sphinx.locale import _, __
from sphinx.util import logging
from sphinx.util.docutils import new_document
from sphinx.util.i18n import format_date
from sphinx.util.nodes import apply_source_workaround, is_smartquotable
from collections.abc import Generator
from docutils.nodes import Node, Text
from sphinx.application import Sphinx
from sphinx.config import Config
from sphinx.domains.std import StandardDomain
from sphinx.environment import BuildEnvironment

"""Docutils transforms used by Sphinx when reading documents."""
if TYPE_CHECKING:
    ...
logger = ...
default_substitutions = ...
class SphinxTransform(Transform):
    """A base class of Transforms.

    Compared with ``docutils.transforms.Transform``, this class improves accessibility to
    Sphinx APIs.
    """
    @property
    def app(self) -> Sphinx:
        """Reference to the :class:`.Sphinx` object."""
        ...
    
    @property
    def env(self) -> BuildEnvironment:
        """Reference to the :class:`.BuildEnvironment` object."""
        ...
    
    @property
    def config(self) -> Config:
        """Reference to the :class:`.Config` object."""
        ...
    


class SphinxTransformer(Transformer):
    """
    A transformer for Sphinx.
    """
    document: nodes.document
    env: BuildEnvironment | None = ...
    def set_environment(self, env: BuildEnvironment) -> None:
        ...
    
    def apply_transforms(self) -> None:
        ...
    


class DefaultSubstitutions(SphinxTransform):
    """
    Replace some substitutions if they aren't defined in the document.
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class MoveModuleTargets(SphinxTransform):
    """
    Move module targets that are the first thing in a section to the section
    title.

    XXX Python specific
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class HandleCodeBlocks(SphinxTransform):
    """
    Several code block related transformations.
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class AutoNumbering(SphinxTransform):
    """
    Register IDs of tables, figures and literal_blocks to assign numbers.
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class SortIds(SphinxTransform):
    """
    Sort section IDs so that the "id[0-9]+" one comes last.
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


TRANSLATABLE_NODES = ...
class ApplySourceWorkaround(SphinxTransform):
    """
    Update source and rawsource attributes
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class AutoIndexUpgrader(SphinxTransform):
    """
    Detect old style (4 column based indices) and automatically upgrade to new style.
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class ExtraTranslatableNodes(SphinxTransform):
    """
    Make nodes translatable
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class UnreferencedFootnotesDetector(SphinxTransform):
    """
    Detect unreferenced footnotes and emit warnings
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class DoctestTransform(SphinxTransform):
    """Set "doctest" style to each doctest_block node"""
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class FilterSystemMessages(SphinxTransform):
    """Filter system messages from a doctree."""
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class SphinxContentsFilter(ContentsFilter):
    """
    Used with BuildEnvironment.add_toc_from() to discard cross-file links
    within table-of-contents link nodes.
    """
    visit_pending_xref = ...
    def visit_image(self, node: nodes.image) -> None:
        ...
    


class SphinxSmartQuotes(SmartQuotes, SphinxTransform):
    """
    Customized SmartQuotes to avoid transform for some extra node types.

    refs: sphinx.parsers.RSTParser
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    
    def is_available(self) -> bool:
        ...
    
    def get_tokens(self, txtnodes: list[Text]) -> Generator[tuple[str, str], None, None]:
        ...
    


class DoctreeReadEvent(SphinxTransform):
    """Emit :event:`doctree-read` event."""
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class ManpageLink(SphinxTransform):
    """Find manpage section numbers and names"""
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class GlossarySorter(SphinxTransform):
    """Sort glossaries that have the ``sorted`` flag."""
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


class ReorderConsecutiveTargetAndIndexNodes(SphinxTransform):
    """Index nodes interspersed between target nodes prevent other
    Transformations from combining those target nodes,
    e.g. ``PropagateTargets``.  This transformation reorders them:

    Given the following ``document`` as input::

        <document>
            <target ids="id1" ...>
            <index entries="...1...">
            <target ids="id2" ...>
            <target ids="id3" ...>
            <index entries="...2...">
            <target ids="id4" ...>

    The transformed result will be::

        <document>
            <index entries="...1...">
            <index entries="...2...">
            <target ids="id1" ...>
            <target ids="id2" ...>
            <target ids="id3" ...>
            <target ids="id4" ...>
    """
    default_priority = ...
    def apply(self, **kwargs: Any) -> None:
        ...
    


def setup(app: Sphinx) -> dict[str, Any]:
    ...

