Skip to content

Commit 22f1a0c

Browse files
authored
[docutils] Add missing stubs (#14438)
1 parent eb96b7d commit 22f1a0c

File tree

11 files changed

+66
-16
lines changed

11 files changed

+66
-16
lines changed

stubs/docutils/@tests/stubtest_allowlist.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ docutils.nodes.NodeVisitor.depart_\w+ # Methods are discovered dynamically on c
44
docutils.nodes.NodeVisitor.visit_\w+ # Methods are discovered dynamically on commonly-used subclasses
55
# these methods take a rawsource parameter that has been deprecated and is completely ignored, so we omit it from the stub
66
docutils.nodes.Text.__new__
7-
docutils.parsers.commonmark_wrapper # doesn't exist at runtime of stubtests
8-
docutils.parsers.recommonmark_wrapper # doesn't exist at runtime of stubtests
97
docutils.parsers.rst.directives.admonitions.BaseAdmonition.node_class # must be overridden by base classes (pseudo-abstract)
108
docutils.statemachine.State.nested_sm # is initialised in __init__
119
docutils.statemachine.State.nested_sm_kwargs # is initialised in __init__
1210
docutils.statemachine.ViewList.__iter__ # doesn't exist at runtime, but the class is iterable due to __getitem__
11+
docutils.transforms.Transform.apply # method apply is not implemented
1312
docutils.transforms.Transform.__getattr__
1413
docutils.TransformSpec.unknown_reference_resolvers
15-
docutils.writers.odf_odt.pygmentsformatter # this file is missing at runtime
14+
15+
# Files that don't exist at runtime of stubtests, raises ImportError:
16+
docutils.parsers.commonmark_wrapper
17+
docutils.parsers.recommonmark_wrapper
18+
docutils.writers.odf_odt.pygmentsformatter # import `pygments` third-party library

stubs/docutils/METADATA.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
version = "0.21.*"
22
upstream_repository = "https://sourceforge.net/p/docutils/code"
3-
partial_stub = true
4-
5-
[tool.stubtest]
6-
ignore_missing_stub = true

stubs/docutils/docutils/__main__.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import ClassVar
2+
3+
import docutils
4+
5+
class CliSettingsSpec(docutils.SettingsSpec):
6+
config_section: ClassVar[str]
7+
config_section_dependencies: ClassVar[tuple[str, ...]]
8+
9+
def main() -> None: ...
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from _typeshed import Incomplete
1+
from typing import Final, Literal
22

3-
__docformat__: str
4-
labels: Incomplete
5-
bibliographic_fields: Incomplete
6-
author_separators: Incomplete
3+
__docformat__: Final = "reStructuredText"
4+
labels: dict[str, str]
5+
bibliographic_fields: dict[str, str]
6+
author_separators: list[Literal[";", ","]]

stubs/docutils/docutils/nodes.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import xml.dom.minidom
33
from abc import abstractmethod
44
from collections import Counter
55
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
6-
from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, overload
6+
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload
77
from typing_extensions import Self, TypeAlias
88

99
from docutils.frontend import Values
@@ -15,6 +15,8 @@ _N = TypeVar("_N", bound=Node)
1515
class _DomModule(Protocol):
1616
Document: type[xml.dom.minidom.Document]
1717

18+
__docformat__: Final = "reStructuredText"
19+
1820
# Functional Node Base Classes
1921

2022
class Node:

stubs/docutils/docutils/parsers/rst/directives/misc.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import StrPath
12
from pathlib import Path
23
from re import Match, Pattern
34
from typing import ClassVar, Final
@@ -7,6 +8,8 @@ from docutils.parsers.rst.states import SpecializedBody
78

89
__docformat__: Final = "reStructuredText"
910

11+
def adapt_path(path: str, source: StrPath = "", root_prefix: StrPath = "/") -> str: ...
12+
1013
class Include(Directive):
1114
standard_include_path: Path
1215

stubs/docutils/docutils/parsers/rst/states.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ class Body(RSTState):
186186
pats: Incomplete
187187
patterns: ClassVar[dict[str, str | Pattern[str]]]
188188
initial_transitions: ClassVar[tuple[str, ...]]
189+
sequence: str
190+
format: str
189191
def indent(self, match, context, next_state): ...
190192
def block_quote(self, indented, line_offset): ...
191193
attribution_pattern: Incomplete

stubs/docutils/docutils/utils/math/math2html.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class FormulaConfig:
5151
symbolfunctions: ClassVar[dict[str, str]]
5252
textfunctions: ClassVar[dict[str, str]]
5353
unmodified: ClassVar[dict[str, list[str]]]
54+
key: str
55+
value: str
5456

5557
class CommandLineParser:
5658
options: Incomplete

stubs/docutils/docutils/writers/latex2e/__init__.pyi

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
from _typeshed import Incomplete, StrPath, Unused
33
from collections.abc import Callable, Iterable
4+
from io import TextIOWrapper
45
from pathlib import Path
56
from typing import ClassVar, Final, Literal, NoReturn, TypeVar
67
from typing_extensions import deprecated
@@ -14,6 +15,8 @@ from docutils.writers import Writer as _Writer
1415
_K = TypeVar("_K")
1516
_V = TypeVar("_V")
1617

18+
__docformat__: Final = "reStructuredText"
19+
1720
LATEX_WRITER_DIR: Final[Path]
1821

1922
class Writer(_Writer[str]):
@@ -62,6 +65,33 @@ class PreambleCmds:
6265
title_legacy: ClassVar[str]
6366
toc_list: ClassVar[str]
6467
ttem: ClassVar[str]
68+
duclass: ClassVar[str]
69+
providelength: ClassVar[str]
70+
abstract: ClassVar[str]
71+
dedication: ClassVar[str]
72+
docinfo: ClassVar[str]
73+
error: ClassVar[str]
74+
highlight_rules: ClassVar[str]
75+
admonition: ClassVar[str]
76+
fieldlist: ClassVar[str]
77+
footnotes: ClassVar[str]
78+
inline: ClassVar[str]
79+
legend: ClassVar[str]
80+
lineblock: ClassVar[str]
81+
optionlist: ClassVar[str]
82+
rubric: ClassVar[str]
83+
sidebar: ClassVar[str]
84+
title: ClassVar[str]
85+
subtitle: ClassVar[str]
86+
documentsubtitle: ClassVar[str]
87+
titlereference: ClassVar[str]
88+
transition: ClassVar[str]
89+
secnumdepth: ClassVar[str]
90+
91+
fp: TextIOWrapper
92+
line: str
93+
block_name: str
94+
definitions: str
6595

6696
class CharMaps:
6797
alltt: ClassVar[dict[int, str]]
@@ -181,6 +211,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
181211
def encode(self, text: str) -> str: ...
182212
def attval(self, text: str, whitespace: re.Pattern[str] = ...) -> str: ...
183213
def is_inline(self, node: nodes.Node) -> bool: ...
214+
def ids_to_labels(
215+
self, node: nodes.Element, set_anchor: bool = True, protect: bool = False, newline: bool = False
216+
) -> list[Incomplete]: ...
184217
def append_hypertargets(self, node: nodes.Element) -> None: ...
185218
def set_align_from_classes(self, node) -> None: ...
186219
def insert_align_declaration(self, node: nodes.Element, default: str | None = None) -> None: ...

stubs/docutils/docutils/writers/odf_odt/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ from xml.etree import ElementTree
99
from docutils import nodes, writers
1010
from docutils.frontend import Values
1111
from docutils.languages import _LanguageModule
12+
from docutils.readers import standalone
1213

1314
__docformat__: Final = "reStructuredText"
1415
VERSION: Final[str]
@@ -420,6 +421,4 @@ class ODFTranslator(nodes.GenericNodeVisitor):
420421
def visit_sidebar(self, node: nodes.sidebar) -> None: ...
421422
def depart_sidebar(self, node: nodes.sidebar) -> None: ...
422423

423-
# TODO: readers is incomplete
424-
# from docutils.readers import standalone
425-
# class Reader(standalone.Reader): ...
424+
class Reader(standalone.Reader[str | bytes]): ...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy