-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[docutils] Add missing stubs for transforms
dir
#14234
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
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Iterable, Mapping | ||
from typing import Any, ClassVar, Final | ||
from typing_extensions import TypeAlias | ||
|
||
from docutils.nodes import Node, document | ||
from docutils import ApplicationError, TransformSpec, nodes | ||
from docutils.languages import LanguageImporter | ||
|
||
_TransformTuple: TypeAlias = tuple[str, type[Transform], nodes.Node | None, dict[str, Any]] | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class TransformError(ApplicationError): ... | ||
|
||
class Transform: | ||
def __init__(self, document: document, startnode: Node | None = None): ... | ||
def __getattr__(self, name: str, /) -> Incomplete: ... | ||
default_priority: ClassVar[int | None] | ||
document: nodes.document | ||
startnode: nodes.Node | None | ||
language: LanguageImporter | ||
def __init__(self, document: nodes.document, startnode: nodes.Node | None = None) -> None: ... | ||
def __getattr__(self, name: str, /) -> Incomplete: ... # method apply is not implemented | ||
|
||
class Transformer: | ||
def __init__(self, document: document): ... | ||
class Transformer(TransformSpec): | ||
transforms: list[_TransformTuple] | ||
document: nodes.document | ||
applied: list[_TransformTuple] | ||
sorted: bool | ||
components: Mapping[str, TransformSpec] | ||
serialno: int | ||
def __init__(self, document: nodes.document): ... | ||
def add_transform(self, transform_class: type[Transform], priority: int | None = None, **kwargs) -> None: ... | ||
def __getattr__(self, name: str, /) -> Incomplete: ... | ||
|
||
def __getattr__(name: str): ... # incomplete module | ||
def add_transforms(self, transform_list: Iterable[type[Transform]]) -> None: ... | ||
def add_pending(self, pending: nodes.pending, priority: int | None = None) -> None: ... | ||
def get_priority_string(self, priority: int) -> str: ... | ||
def populate_from_components(self, components: Iterable[TransformSpec]) -> None: ... | ||
def apply_transforms(self) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import ClassVar, Final | ||
|
||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class Filter(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import re | ||
from typing import ClassVar, Final | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class TitlePromoter(Transform): | ||
def promote_title(self, node: nodes.Element) -> bool: ... | ||
def promote_subtitle(self, node: nodes.Element) -> bool: ... | ||
def candidate_index(self, node: nodes.Element) -> tuple[nodes.Node, int] | tuple[None, None]: ... | ||
|
||
class DocTitle(TitlePromoter): | ||
default_priority: ClassVar[int] | ||
def set_metadata(self) -> None: ... | ||
def apply(self) -> None: ... | ||
|
||
class SectionSubTitle(TitlePromoter): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class DocInfo(Transform): | ||
default_priority: ClassVar[int] | ||
biblio_nodes: ClassVar[dict[str, type[nodes.Element]]] | ||
rcs_keyword_substitutions: ClassVar[list[tuple[re.Pattern[str], str]]] | ||
def apply(self) -> None: ... | ||
def extract_bibliographic(self, field_list): ... | ||
def check_empty_biblio_field(self, field, name) -> bool: ... | ||
def check_compound_biblio_field(self, field, name) -> bool: ... | ||
def extract_authors(self, field, name, docinfo) -> None: ... | ||
def authors_from_one_paragraph(self, field) -> list[list[nodes.Text]]: ... | ||
def authors_from_bullet_list(self, field): ... | ||
def authors_from_paragraphs(self, field): ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import ClassVar, Final | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class CallBack(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class ClassAttribute(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class Transitions(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
def visit_transition(self, node: nodes.transition) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from _typeshed import Incomplete, Unused | ||
from collections.abc import Iterable, Sequence | ||
from typing import ClassVar, Final, NoReturn | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class SectNum(Transform): | ||
default_priority: ClassVar[int] | ||
maxdepth: int | ||
startvalue: int | ||
prefix: str | ||
suffix: str | ||
def apply(self) -> None: ... | ||
def update_section_numbers(self, node: nodes.Element, prefix: Iterable[str] = (), depth: int = 0) -> None: ... | ||
|
||
class Contents(Transform): | ||
default_priority: ClassVar[int] | ||
toc_id: Incomplete | ||
backlinks: Incomplete | ||
def apply(self) -> None: ... | ||
def build_contents( | ||
self, node: nodes.Element, level: int = 0 | ||
) -> nodes.bullet_list | list[None]: ... # return empty list if entries is empty | ||
def copy_and_filter(self, node: nodes.Node) -> Sequence[nodes.Node]: ... | ||
|
||
class ContentsFilter(nodes.TreeCopyVisitor): | ||
def get_entry_text(self) -> Sequence[nodes.Node]: ... | ||
def visit_citation_reference(self, node: Unused) -> NoReturn: ... | ||
def visit_footnote_reference(self, node: Unused) -> NoReturn: ... | ||
def visit_image(self, node: nodes.image) -> NoReturn: ... | ||
def ignore_node_but_process_children(self, node: Unused) -> NoReturn: ... | ||
visit_problematic = ignore_node_but_process_children | ||
visit_reference = ignore_node_but_process_children | ||
visit_target = ignore_node_but_process_children |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import re | ||
from typing import ClassVar, Final | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class Headers(Transform): | ||
default_priority: ClassVar[int] | ||
pep_url: ClassVar[str] | ||
pep_cvs_url: ClassVar[str] | ||
rcs_keyword_substitutions: ClassVar[tuple[tuple[re.Pattern[str], str], ...]] | ||
def apply(self) -> None: ... | ||
|
||
class Contents(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class TargetNotes(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
def cleanup_callback(self, pending: nodes.pending) -> None: ... | ||
|
||
class PEPZero(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class PEPZeroSpecial(nodes.SparseNodeVisitor): | ||
pep_url: ClassVar[str] | ||
def unknown_visit(self, node: nodes.Node) -> None: ... | ||
def visit_reference(self, node: nodes.reference) -> None: ... | ||
def visit_field_list(self, node: nodes.field_list) -> None: ... | ||
pep_table: bool | ||
entry: int | ||
def visit_tgroup(self, node: nodes.tgroup) -> None: ... | ||
def visit_colspec(self, node: nodes.colspec) -> None: ... | ||
def visit_row(self, node: nodes.row) -> None: ... | ||
def visit_entry(self, node: nodes.entry) -> None: ... | ||
|
||
non_masked_addresses: tuple[str, ...] | ||
|
||
def mask_email(ref: nodes.reference, pepno: int | None = None) -> nodes.Node: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Iterable | ||
from typing import ClassVar, Final, overload | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class PropagateTargets(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class AnonymousHyperlinks(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class IndirectHyperlinks(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
def resolve_indirect_target(self, target: nodes.Element) -> None: ... | ||
def nonexistent_indirect_target(self, target: nodes.Element) -> None: ... | ||
def circular_indirect_reference(self, target: nodes.Element) -> None: ... | ||
def indirect_target_error(self, target: nodes.Element, explanation) -> None: ... | ||
def resolve_indirect_references(self, target: nodes.Element) -> None: ... | ||
|
||
class ExternalTargets(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class InternalTargets(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
def resolve_reference_ids(self, target: nodes.Element) -> None: ... | ||
|
||
class Footnotes(Transform): | ||
default_priority: ClassVar[int] | ||
autofootnote_labels: list[str] | None | ||
symbols: ClassVar[list[str]] | ||
def apply(self) -> None: ... | ||
def number_footnotes(self, startnum: int) -> int: ... | ||
def number_footnote_references(self, startnum: int) -> None: ... | ||
def symbolize_footnotes(self) -> None: ... | ||
def resolve_footnotes_and_citations(self) -> None: ... | ||
@overload | ||
def resolve_references(self, note: nodes.footnote, reflist: Iterable[nodes.footnote_reference]) -> None: ... | ||
@overload | ||
def resolve_references(self, note: nodes.citation, reflist: Iterable[nodes.citation_reference]) -> None: ... | ||
@overload | ||
def resolve_references(self, note: nodes.title, reflist: Iterable[nodes.title_reference]) -> None: ... | ||
|
||
class CircularSubstitutionDefinitionError(Exception): ... | ||
|
||
class Substitutions(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class TargetNotes(Transform): | ||
default_priority: ClassVar[int] | ||
classes: Incomplete | ||
def __init__(self, document: nodes.document, startnode: nodes.Node) -> None: ... | ||
def apply(self) -> None: ... | ||
def make_target_footnote(self, refuri: str, refs: list[Incomplete], notes: dict[Incomplete, Incomplete]): ... | ||
|
||
class DanglingReferences(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class DanglingReferencesVisitor(nodes.SparseNodeVisitor): | ||
document: nodes.document | ||
def __init__(self, document: nodes.document, unknown_reference_resolvers) -> None: ... | ||
def unknown_visit(self, node: nodes.Node) -> None: ... | ||
def visit_reference(self, node: nodes.reference) -> None: ... | ||
def visit_footnote_reference(self, node: nodes.footnote_reference) -> None: ... | ||
def visit_citation_reference(self, node: nodes.citation_reference) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from _typeshed import Incomplete | ||
from collections.abc import Generator, Iterable | ||
from typing import ClassVar, Final, Literal | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
class Decorations(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
def generate_header(self) -> None: ... | ||
def generate_footer(self) -> list[nodes.paragraph] | None: ... | ||
|
||
class ExposeInternals(Transform): | ||
default_priority: ClassVar[int] | ||
def not_Text(self, node: object) -> bool: ... # node passing to isinstance() method | ||
def apply(self) -> None: ... | ||
|
||
class Messages(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class FilterMessages(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class TestMessages(Transform): | ||
__test__: bool | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class StripComments(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... | ||
|
||
class StripClassesAndElements(Transform): | ||
default_priority: ClassVar[int] | ||
strip_elements: set[Incomplete] | ||
def apply(self) -> None: ... | ||
def check_classes(self, node: object) -> bool: ... | ||
|
||
class SmartQuotes(Transform): | ||
default_priority: ClassVar[int] | ||
nodes_to_skip: ClassVar[tuple[type[nodes.Node], ...]] | ||
literal_nodes: ClassVar[tuple[type[nodes.Node | nodes.Body], ...]] | ||
smartquotes_action: ClassVar[str] | ||
unsupported_languages: set[str] | ||
def __init__(self, document: nodes.document, startnode: nodes.Node | None) -> None: ... | ||
def get_tokens(self, txtnodes: Iterable[nodes.Node]) -> Generator[tuple[Literal["literal", "plain"], str]]: ... | ||
def apply(self) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import ClassVar, Final | ||
from typing_extensions import deprecated | ||
|
||
from docutils import nodes | ||
from docutils.transforms import Transform | ||
|
||
__docformat__: Final = "reStructuredText" | ||
|
||
@deprecated("docutils.transforms.writer_aux.Compound is deprecated and will be removed in Docutils 0.21 or later.") | ||
class Compound(Transform): | ||
default_priority: ClassVar[int] | ||
def __init__(self, document: nodes.document, startnode: nodes.Node | None = None) -> None: ... | ||
def apply(self) -> None: ... | ||
|
||
class Admonitions(Transform): | ||
default_priority: ClassVar[int] | ||
def apply(self) -> None: ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sphinx primer hits show that this class can still be sub-classed and these methods overridden. Therefore I would suggest just using the standard annotations for the visit methods instead of
Unused
andNoReturn
. In fact, I would suggest removing them here and adding them toNodeVisitor
, similar to what we do inast.pyi
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, and they were already added to
NodeVisitor