Skip to content

[docutils] Add missing stubs #14438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[docutils] Add missing stubs
  • Loading branch information
donBarbos committed Jul 22, 2025
commit 0c2804cc6dc7ffb9bf0ce5812447577503f37416
9 changes: 6 additions & 3 deletions stubs/docutils/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ docutils.nodes.NodeVisitor.depart_\w+ # Methods are discovered dynamically on c
docutils.nodes.NodeVisitor.visit_\w+ # Methods are discovered dynamically on commonly-used subclasses
# these methods take a rawsource parameter that has been deprecated and is completely ignored, so we omit it from the stub
docutils.nodes.Text.__new__
docutils.parsers.commonmark_wrapper # doesn't exist at runtime of stubtests
docutils.parsers.recommonmark_wrapper # doesn't exist at runtime of stubtests
docutils.parsers.rst.directives.admonitions.BaseAdmonition.node_class # must be overridden by base classes (pseudo-abstract)
docutils.statemachine.State.nested_sm # is initialised in __init__
docutils.statemachine.State.nested_sm_kwargs # is initialised in __init__
docutils.statemachine.ViewList.__iter__ # doesn't exist at runtime, but the class is iterable due to __getitem__
docutils.transforms.Transform.apply # method apply is not implemented
docutils.transforms.Transform.__getattr__
docutils.TransformSpec.unknown_reference_resolvers
docutils.writers.odf_odt.pygmentsformatter # this file is missing at runtime

# Files that don't exist at runtime of stubtests, raises ImportError:
docutils.parsers.commonmark_wrapper
docutils.parsers.recommonmark_wrapper
docutils.writers.odf_odt.pygmentsformatter # import `pygments` third-party library
4 changes: 0 additions & 4 deletions stubs/docutils/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
version = "0.21.*"
upstream_repository = "https://sourceforge.net/p/docutils/code"
partial_stub = true

[tool.stubtest]
ignore_missing_stub = true
9 changes: 9 additions & 0 deletions stubs/docutils/docutils/__main__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar

import docutils

class CliSettingsSpec(docutils.SettingsSpec):
config_section: ClassVar[str]
config_section_dependencies: ClassVar[tuple[str, ...]]

def main() -> None: ...
10 changes: 5 additions & 5 deletions stubs/docutils/docutils/languages/eo.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from typing import Final, Literal

__docformat__: str
labels: Incomplete
bibliographic_fields: Incomplete
author_separators: Incomplete
__docformat__: Final = "reStructuredText"
labels: dict[str, str]
bibliographic_fields: dict[str, str]
author_separators: list[Literal[";", ","]]
4 changes: 3 additions & 1 deletion stubs/docutils/docutils/nodes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import xml.dom.minidom
from abc import abstractmethod
from collections import Counter
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, overload
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload
from typing_extensions import Self, TypeAlias

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

__docformat__: Final = "reStructuredText"

# Functional Node Base Classes

class Node:
Expand Down
3 changes: 3 additions & 0 deletions stubs/docutils/docutils/parsers/rst/directives/misc.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import StrPath
from pathlib import Path
from re import Match, Pattern
from typing import ClassVar, Final
Expand All @@ -7,6 +8,8 @@ from docutils.parsers.rst.states import SpecializedBody

__docformat__: Final = "reStructuredText"

def adapt_path(path: str, source: StrPath = "", root_prefix: StrPath = "/") -> str: ...

class Include(Directive):
standard_include_path: Path

Expand Down
2 changes: 2 additions & 0 deletions stubs/docutils/docutils/parsers/rst/states.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class Body(RSTState):
pats: Incomplete
patterns: ClassVar[dict[str, str | Pattern[str]]]
initial_transitions: ClassVar[tuple[str, ...]]
sequence: str
format: str
def indent(self, match, context, next_state): ...
def block_quote(self, indented, line_offset): ...
attribution_pattern: Incomplete
Expand Down
2 changes: 2 additions & 0 deletions stubs/docutils/docutils/utils/math/math2html.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class FormulaConfig:
symbolfunctions: ClassVar[dict[str, str]]
textfunctions: ClassVar[dict[str, str]]
unmodified: ClassVar[dict[str, list[str]]]
key: str
value: str

class CommandLineParser:
options: Incomplete
Expand Down
33 changes: 33 additions & 0 deletions stubs/docutils/docutils/writers/latex2e/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
from _typeshed import Incomplete, StrPath, Unused
from collections.abc import Callable, Iterable
from io import TextIOWrapper
from pathlib import Path
from typing import ClassVar, Final, Literal, NoReturn, TypeVar
from typing_extensions import deprecated
Expand All @@ -14,6 +15,8 @@ from docutils.writers import Writer as _Writer
_K = TypeVar("_K")
_V = TypeVar("_V")

__docformat__: Final = "reStructuredText"

LATEX_WRITER_DIR: Final[Path]

class Writer(_Writer[str]):
Expand Down Expand Up @@ -62,6 +65,33 @@ class PreambleCmds:
title_legacy: ClassVar[str]
toc_list: ClassVar[str]
ttem: ClassVar[str]
duclass: ClassVar[str]
providelength: ClassVar[str]
abstract: ClassVar[str]
dedication: ClassVar[str]
docinfo: ClassVar[str]
error: ClassVar[str]
highlight_rules: ClassVar[str]
admonition: ClassVar[str]
fieldlist: ClassVar[str]
footnotes: ClassVar[str]
inline: ClassVar[str]
legend: ClassVar[str]
lineblock: ClassVar[str]
optionlist: ClassVar[str]
rubric: ClassVar[str]
sidebar: ClassVar[str]
title: ClassVar[str]
subtitle: ClassVar[str]
documentsubtitle: ClassVar[str]
titlereference: ClassVar[str]
transition: ClassVar[str]
secnumdepth: ClassVar[str]

fp: TextIOWrapper
line: str
block_name: str
definitions: str

class CharMaps:
alltt: ClassVar[dict[int, str]]
Expand Down Expand Up @@ -181,6 +211,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
def encode(self, text: str) -> str: ...
def attval(self, text: str, whitespace: re.Pattern[str] = ...) -> str: ...
def is_inline(self, node: nodes.Node) -> bool: ...
def ids_to_labels(
self, node: nodes.Element, set_anchor: bool = True, protect: bool = False, newline: bool = False
) -> list[Incomplete]: ...
def append_hypertargets(self, node: nodes.Element) -> None: ...
def set_align_from_classes(self, node) -> None: ...
def insert_align_declaration(self, node: nodes.Element, default: str | None = None) -> None: ...
Expand Down
5 changes: 2 additions & 3 deletions stubs/docutils/docutils/writers/odf_odt/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from xml.etree import ElementTree
from docutils import nodes, writers
from docutils.frontend import Values
from docutils.languages import _LanguageModule
from docutils.readers import standalone

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

# TODO: readers is incomplete
# from docutils.readers import standalone
# class Reader(standalone.Reader): ...
class Reader(standalone.Reader[str | bytes]): ...
1 change: 1 addition & 0 deletions stubs/docutils/docutils/writers/xetex/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Babel(latex2e.Babel):
quote_index: int
quotes: tuple[str, ...]
literal_double_quote: str
key: str
def __init__(self, language_code: str, reporter: Reporter) -> None: ...

class XeLaTeXTranslator(latex2e.LaTeXTranslator):
Expand Down
Loading
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