Skip to content

Commit 6b5ca0b

Browse files
authoredMay 3, 2023
[docutils] Add items to docutils.node (#10102)
* Add class paragraph * Add class TextElement * Add Element.index(), .remove(), and .insert()
1 parent 0b60e7f commit 6b5ca0b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎stubs/docutils/docutils/nodes.pyi

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import sys
12
import xml.dom.minidom
23
from _typeshed import Incomplete
34
from abc import abstractmethod
45
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
56
from typing import Any, ClassVar, Protocol, TypeVar, overload
6-
from typing_extensions import Literal, Self
7+
from typing_extensions import Literal, Self, SupportsIndex
78

89
from docutils.transforms import Transformer
910

@@ -79,6 +80,7 @@ class Node:
7980

8081
class Element(Node):
8182
children: list[Node]
83+
rawsource: str
8284
def __init__(self, rawsource: str = "", *children: Node, **attributes): ...
8385
def __len__(self) -> int: ...
8486
def __contains__(self, key: str | Node) -> bool: ...
@@ -105,8 +107,14 @@ class Element(Node):
105107
def deepcopy(self) -> Self: ...
106108
def pformat(self, indent: str = " ", level: int = 0) -> str: ...
107109
def astext(self) -> str: ...
110+
def index(self, item: Node, start: int = 0, stop: int = sys.maxsize) -> int: ...
111+
def remove(self, item: Node) -> None: ...
112+
def insert(self, index: SupportsIndex, item: Node | Iterable[Node] | None) -> None: ...
108113
def __getattr__(self, __name: str) -> Incomplete: ...
109114

115+
class TextElement(Element):
116+
def __init__(self, rawsource: str = "", text: str = "", *children: Node, **attributes) -> None: ...
117+
110118
class Text(Node, str):
111119
tagname: ClassVar[str]
112120
children: tuple[()]
@@ -135,6 +143,8 @@ class document(Root, Structural, Element):
135143
def astext(self) -> str: ...
136144
def __getattr__(self, __name: str) -> Incomplete: ...
137145

146+
class paragraph(General, TextElement): ...
147+
138148
class NodeVisitor:
139149
def __init__(self, document: document): ...
140150
def __getattr__(self, __name: str) -> Incomplete: ...

0 commit comments

Comments
 (0)
Please sign in to comment.