97 lines
2.4 KiB
Python
97 lines
2.4 KiB
Python
"""
|
|
This type stub file was generated by pyright.
|
|
"""
|
|
|
|
from typing import Any, TYPE_CHECKING
|
|
from docutils import nodes
|
|
from docutils.core import Publisher
|
|
from docutils.io import FileInput, Input
|
|
from docutils.readers import standalone
|
|
from docutils.writers import UnfilteredWriter
|
|
from docutils.frontend import Values
|
|
from docutils.parsers import Parser
|
|
from docutils.transforms import Transform
|
|
from sphinx.application import Sphinx
|
|
from sphinx.environment import BuildEnvironment
|
|
|
|
"""Input/Output files"""
|
|
if TYPE_CHECKING:
|
|
...
|
|
logger = ...
|
|
class SphinxBaseReader(standalone.Reader):
|
|
"""
|
|
A base class of readers for Sphinx.
|
|
|
|
This replaces reporter by Sphinx's on generating document.
|
|
"""
|
|
transforms: list[type[Transform]] = ...
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
...
|
|
|
|
def setup(self, app: Sphinx) -> None:
|
|
...
|
|
|
|
def get_transforms(self) -> list[type[Transform]]:
|
|
...
|
|
|
|
def new_document(self) -> nodes.document:
|
|
"""
|
|
Creates a new document object which has a special reporter object good
|
|
for logging.
|
|
"""
|
|
...
|
|
|
|
|
|
|
|
class SphinxStandaloneReader(SphinxBaseReader):
|
|
"""
|
|
A basic document reader for Sphinx.
|
|
"""
|
|
def setup(self, app: Sphinx) -> None:
|
|
...
|
|
|
|
def read(self, source: Input, parser: Parser, settings: Values) -> nodes.document:
|
|
...
|
|
|
|
def read_source(self, env: BuildEnvironment) -> str:
|
|
"""Read content from source and do post-process."""
|
|
...
|
|
|
|
|
|
|
|
class SphinxI18nReader(SphinxBaseReader):
|
|
"""
|
|
A document reader for i18n.
|
|
|
|
This returns the source line number of original text as current source line number
|
|
to let users know where the error happened.
|
|
Because the translated texts are partial and they don't have correct line numbers.
|
|
"""
|
|
def setup(self, app: Sphinx) -> None:
|
|
...
|
|
|
|
|
|
|
|
class SphinxDummyWriter(UnfilteredWriter):
|
|
"""Dummy writer module used for generating doctree."""
|
|
supported = ...
|
|
def translate(self) -> None:
|
|
...
|
|
|
|
|
|
|
|
def SphinxDummySourceClass(source: Any, *args: Any, **kwargs: Any) -> Any:
|
|
"""Bypass source object as is to cheat Publisher."""
|
|
...
|
|
|
|
class SphinxFileInput(FileInput):
|
|
"""A basic FileInput for Sphinx."""
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
...
|
|
|
|
|
|
|
|
def create_publisher(app: Sphinx, filetype: str) -> Publisher:
|
|
...
|
|
|