Improve docutils stubs (#7256)

This commit is contained in:
Martin Fischer
2022-02-21 01:49:11 +01:00
committed by GitHub
parent 94127ca2f5
commit a287cfd925
27 changed files with 153 additions and 5 deletions

View File

@@ -6,5 +6,15 @@ docutils.io.FileOutput.__getattr__
docutils.io.FileOutput.__init__
docutils.io.Input.__getattr__
docutils.io.Input.__init__
docutils.languages.LanguageImporter.__getattr__
docutils.nodes.Element.__getattr__
docutils.nodes.Node.__getattr__
docutils.nodes.document.__getattr__
docutils.nodes.document.__init__
docutils.parsers.rst.Directive.__getattr__
docutils.parsers.rst.nodes
docutils.transforms.Transform.__getattr__
docutils.transforms.Transformer.__getattr__
docutils.utils.Reporter.__getattr__
# the constructor appears to be mostly internal API, public API users are meant to use docutils.utils.new_reporter instead
docutils.utils.Reporter.__init__

View File

@@ -1,3 +1,14 @@
from typing import Any
from typing import Any, Protocol
def __getattr__(name: str) -> Any: ... # incomplete
from docutils.utils import Reporter
class _LanguageModule(Protocol):
labels: dict[str, str]
author_separators: list[str]
bibliographic_fields: list[str]
class LanguageImporter:
def __call__(self, language_code: str, reporter: Reporter | None = ...) -> _LanguageModule: ...
def __getattr__(self, __name: str) -> Any: ... # incomplete
get_language: LanguageImporter

View File

@@ -1,3 +1,23 @@
from typing import Any
from docutils.transforms import Transformer
class Node:
parent: Node | None
source: str | None
line: int | None
document: document | None
def __getattr__(self, __name: str) -> Any: ... # incomplete
class Element(Node):
def __init__(self, rawsource: str = ..., *children: Node, **attributes): ...
def __getattr__(self, __name: str) -> Any: ... # incomplete
class Structural: ...
class Root: ...
class document(Root, Structural, Element):
transformer: Transformer
def __getattr__(self, __name: str) -> Any: ... # incomplete
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -1,14 +1,15 @@
from typing import Any, ClassVar
from docutils import Component
from docutils.nodes import document as _document
class Parser(Component):
component_type: ClassVar[str]
config_section: ClassVar[str]
inputstring: Any # defined after call to setup_parse()
document: Any # defined after call to setup_parse()
def parse(self, inputstring: str, document) -> None: ...
def setup_parse(self, inputstring: str, document) -> None: ...
def parse(self, inputstring: str, document: _document) -> None: ...
def setup_parse(self, inputstring: str, document: _document) -> None: ...
def finish_parse(self) -> None: ...
_parser_aliases: dict[str, str]

View File

@@ -0,0 +1,12 @@
from typing import Any
from docutils.languages import _LanguageModule
from docutils.nodes import document
from docutils.parsers.rst import Directive
from docutils.utils import SystemMessage
def register_directive(name: str, directive: type[Directive]) -> None: ...
def directive(
directive_name: str, language_module: _LanguageModule, document: document
) -> tuple[type[Directive] | None, list[SystemMessage]]: ...
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -2,6 +2,8 @@ from typing import Any, Callable
import docutils.nodes
import docutils.parsers.rst.states
from docutils.languages import _LanguageModule
from docutils.utils import Reporter, SystemMessage
_RoleFn = Callable[
[str, str, str, int, docutils.parsers.rst.states.Inliner, dict[str, Any], list[str]],
@@ -9,4 +11,7 @@ _RoleFn = Callable[
]
def register_local_role(name: str, role_fn: _RoleFn) -> None: ...
def role(
role_name: str, language_module: _LanguageModule, lineno: int, reporter: Reporter
) -> tuple[_RoleFn | None, list[SystemMessage]]: ...
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -1,3 +1,14 @@
from typing import Any
from docutils.nodes import Node, document
class Transform:
def __init__(self, document: document, startnode: Node | None = ...): ...
def __getattr__(self, __name: str) -> Any: ... # incomplete
class Transformer:
def __init__(self, document: document): ...
def add_transform(self, transform_class: type[Transform], priority: int | None = ..., **kwargs) -> None: ...
def __getattr__(self, __name: str) -> Any: ... # incomplete
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -1,7 +1,11 @@
import optparse
from collections.abc import Iterable
from typing import Any
from typing_extensions import Literal
from docutils import ApplicationError
from docutils.io import FileOutput
from docutils.nodes import document
_list = list
@@ -13,4 +17,24 @@ class DependencyList:
def add(self, *filenames: str) -> None: ...
def close(self) -> None: ...
_SystemMessageLevel = Literal[0, 1, 2, 3, 4]
class Reporter:
DEBUG_LEVEL: Literal[0]
INFO_LEVEL: Literal[1]
WARNING_LEVEL: Literal[2]
ERROR_LEVEL: Literal[3]
SEVERE_LEVEL: Literal[4]
source: str
report_level: _SystemMessageLevel
halt_level: _SystemMessageLevel
def __getattr__(self, __name: str) -> Any: ... # incomplete
class SystemMessage(ApplicationError):
level: _SystemMessageLevel
def __init__(self, system_message: object, level: _SystemMessageLevel): ...
def new_reporter(source_path: str, settings: optparse.Values) -> Reporter: ...
def new_document(source_path: str, settings: optparse.Values | None = ...) -> document: ...
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -0,0 +1,3 @@
from typing import Any
def __getattr__(name: str) -> Any: ... # incomplete