Skip to content

Commit

Permalink
Improve docutils stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
not-my-profile committed Feb 18, 2022
1 parent 644d554 commit efd8d4f
Show file tree
Hide file tree
Showing 27 changed files with 150 additions and 4 deletions.
10 changes: 9 additions & 1 deletion stubs/docutils/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ 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__
docutils.utils.Reporter.__init__
13 changes: 12 additions & 1 deletion stubs/docutils/docutils/languages/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
from docutils.utils import Reporter

class _LanguageModule:
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
20 changes: 20 additions & 0 deletions stubs/docutils/docutils/nodes.pyi
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions stubs/docutils/docutils/parsers/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from typing import Any, ClassVar

from docutils import Component
from docutils.nodes import 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]
Expand Down
12 changes: 12 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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], list[SystemMessage]]: ...
def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/body.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/html.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/images.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/misc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/parts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/references.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/tables.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
5 changes: 5 additions & 0 deletions stubs/docutils/docutils/parsers/rst/roles.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ 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]],
tuple[list[docutils.nodes.reference], list[docutils.nodes.reference]],
]

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
11 changes: 11 additions & 0 deletions stubs/docutils/docutils/transforms/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions stubs/docutils/docutils/utils/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/docutils_xml.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/html4css1.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/html5_polyglot.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/latex2e.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/manpage.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/null.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/odf_odt.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/pep_html.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/pseudoxml.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/s5_html.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/writers/xetex.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete

0 comments on commit efd8d4f

Please sign in to comment.