diff --git a/stubs/commonmark/commonmark/blocks.pyi b/stubs/commonmark/commonmark/blocks.pyi index 7a5bbdc082ea..a442b74c452e 100644 --- a/stubs/commonmark/commonmark/blocks.pyi +++ b/stubs/commonmark/commonmark/blocks.pyi @@ -1,141 +1,144 @@ -from _typeshed import Incomplete -from typing import Any - -CODE_INDENT: int -reHtmlBlockOpen: Any -reHtmlBlockClose: Any -reThematicBreak: Any -reMaybeSpecial: Any -reNonSpace: Any -reBulletListMarker: Any -reOrderedListMarker: Any -reATXHeadingMarker: Any -reCodeFence: Any -reClosingCodeFence: Any -reSetextHeadingLine: Any -reLineEnding: Any - -def is_blank(s): ... -def is_space_or_tab(s): ... -def peek(ln, pos): ... -def ends_with_blank_line(block): ... -def parse_list_marker(parser, container): ... -def lists_match(list_data, item_data): ... +import re +from typing import Any, Final, Literal + +from .inlines import InlineParser +from .node import Node + +CODE_INDENT: Final[int] +reHtmlBlockOpen: Final[list[re.Pattern[str]]] +reHtmlBlockClose: Final[list[re.Pattern[str]]] +reThematicBreak: Final[re.Pattern[str]] +reMaybeSpecial: Final[re.Pattern[str]] +reNonSpace: Final[re.Pattern[str]] +reBulletListMarker: Final[re.Pattern[str]] +reOrderedListMarker: Final[re.Pattern[str]] +reATXHeadingMarker: Final[re.Pattern[str]] +reCodeFence: Final[re.Pattern[str]] +reClosingCodeFence: Final[re.Pattern[str]] +reSetextHeadingLine: Final[re.Pattern[str]] +reLineEnding: Final[re.Pattern[str]] + +def is_blank(s: str) -> bool: ... +def is_space_or_tab(s: str) -> bool: ... +def peek(ln: str, pos: int) -> str | None: ... +def ends_with_blank_line(block: Node) -> bool: ... +def parse_list_marker(parser: Parser, container: Node) -> dict[str, Any] | None: ... +def lists_match(list_data: dict[str, Any], item_data: dict[str, Any]) -> bool: ... class Block: - accepts_lines: Any + accepts_lines: bool | None @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...) -> None: ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> int | None: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t) -> None: ... + def can_contain(t: str) -> bool | None: ... class Document(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> bool: ... class List(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> bool: ... class BlockQuote(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> bool: ... class Item(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> bool: ... class Heading(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> Literal[False]: ... class ThematicBreak(Block): - accepts_lines: bool + accepts_lines: Literal[False] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> Literal[False]: ... class CodeBlock(Block): - accepts_lines: bool + accepts_lines: Literal[True] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0, 1, 2]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> Literal[False]: ... class HtmlBlock(Block): - accepts_lines: bool + accepts_lines: Literal[True] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> Literal[False]: ... class Paragraph(Block): - accepts_lines: bool + accepts_lines: Literal[True] @staticmethod - def continue_(parser: Incomplete | None = ..., container: Incomplete | None = ...): ... + def continue_(parser: Parser | None = None, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def finalize(parser: Incomplete | None = ..., block: Incomplete | None = ...) -> None: ... + def finalize(parser: Parser | None = None, block: Node | None = None) -> None: ... @staticmethod - def can_contain(t): ... + def can_contain(t: str) -> Literal[False]: ... class BlockStarts: - METHODS: Any + METHODS: list[str] @staticmethod - def block_quote(parser, container: Incomplete | None = ...): ... + def block_quote(parser: Parser, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def atx_heading(parser, container: Incomplete | None = ...): ... + def atx_heading(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... @staticmethod - def fenced_code_block(parser, container: Incomplete | None = ...): ... + def fenced_code_block(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... @staticmethod - def html_block(parser, container: Incomplete | None = ...): ... + def html_block(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... @staticmethod - def setext_heading(parser, container: Incomplete | None = ...): ... + def setext_heading(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... @staticmethod - def thematic_break(parser, container: Incomplete | None = ...): ... + def thematic_break(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... @staticmethod - def list_item(parser, container: Incomplete | None = ...): ... + def list_item(parser: Parser, container: Node | None = None) -> Literal[0, 1]: ... @staticmethod - def indented_code_block(parser, container: Incomplete | None = ...): ... + def indented_code_block(parser: Parser, container: Node | None = None) -> Literal[0, 2]: ... class Parser: - doc: Any - block_starts: Any - tip: Any - oldtip: Any + doc: Node + block_starts: BlockStarts + tip: Node + oldtip: Node current_line: str line_number: int offset: int @@ -147,21 +150,22 @@ class Parser: blank: bool partially_consumed_tab: bool all_closed: bool - last_matched_container: Any - refmap: Any + last_matched_container: Node + refmap: dict[str, Any] last_line_length: int - inline_parser: Any - options: Any - def __init__(self, options=...) -> None: ... + inline_parser: InlineParser + options: dict[str, Any] + blocks: dict[str, Block] + def __init__(self, options: dict[str, Any] = {}) -> None: ... def add_line(self) -> None: ... - def add_child(self, tag, offset): ... + def add_child(self, tag: str, offset: int) -> Node: ... def close_unmatched_blocks(self) -> None: ... def find_next_nonspace(self) -> None: ... def advance_next_nonspace(self) -> None: ... - def advance_offset(self, count, columns) -> None: ... - def incorporate_line(self, ln) -> None: ... - def finalize(self, block, line_number) -> None: ... - def process_inlines(self, block) -> None: ... - def parse(self, my_input): ... + def advance_offset(self, count: int, columns: bool) -> None: ... + def incorporate_line(self, ln: str) -> None: ... + def finalize(self, block: Node, line_number: int) -> None: ... + def process_inlines(self, block: Node) -> None: ... + def parse(self, my_input: str) -> Node: ... -CAMEL_RE: Any +CAMEL_RE: Final[re.Pattern[str]] diff --git a/stubs/commonmark/commonmark/common.pyi b/stubs/commonmark/commonmark/common.pyi index c55a67969ad1..e6dda39aef8f 100644 --- a/stubs/commonmark/commonmark/common.pyi +++ b/stubs/commonmark/commonmark/common.pyi @@ -1,35 +1,39 @@ import html -from typing import Any +import re +from typing import AnyStr, Final, Literal, overload HTMLunescape = html.unescape -ENTITY: str -TAGNAME: str -ATTRIBUTENAME: str -UNQUOTEDVALUE: str -SINGLEQUOTEDVALUE: str -DOUBLEQUOTEDVALUE: str -ATTRIBUTEVALUE: Any -ATTRIBUTEVALUESPEC: Any -ATTRIBUTE: Any -OPENTAG: Any -CLOSETAG: Any -HTMLCOMMENT: str -PROCESSINGINSTRUCTION: str -DECLARATION: Any -CDATA: str -HTMLTAG: Any -reHtmlTag: Any -reBackslashOrAmp: Any -ESCAPABLE: str -reEntityOrEscapedChar: Any -XMLSPECIAL: str -reXmlSpecial: Any +ENTITY: Final[str] +TAGNAME: Final[str] +ATTRIBUTENAME: Final[str] +UNQUOTEDVALUE: Final[str] +SINGLEQUOTEDVALUE: Final[str] +DOUBLEQUOTEDVALUE: Final[str] +ATTRIBUTEVALUE: Final[str] +ATTRIBUTEVALUESPEC: Final[str] +ATTRIBUTE: Final[str] +OPENTAG: Final[str] +CLOSETAG: Final[str] +HTMLCOMMENT: Final[str] +PROCESSINGINSTRUCTION: Final[str] +DECLARATION: Final[str] +CDATA: Final[str] +HTMLTAG: Final[str] +reHtmlTag: Final[re.Pattern[str]] +reBackslashOrAmp: Final[re.Pattern[str]] +ESCAPABLE: Final[str] +reEntityOrEscapedChar: Final[re.Pattern[str]] +XMLSPECIAL: Final[str] +reXmlSpecial: Final[re.Pattern[str]] -def unescape_char(s): ... -def unescape_string(s): ... -def normalize_uri(uri): ... +def unescape_char(s: AnyStr) -> AnyStr: ... +def unescape_string(s: str) -> str: ... +def normalize_uri(uri: str) -> str: ... -UNSAFE_MAP: Any +UNSAFE_MAP: Final[dict[str, str]] -def replace_unsafe_char(s): ... -def escape_xml(s): ... +def replace_unsafe_char(s: str) -> str: ... +@overload +def escape_xml(s: None) -> Literal[""]: ... +@overload +def escape_xml(s: str) -> str: ... diff --git a/stubs/commonmark/commonmark/dump.pyi b/stubs/commonmark/commonmark/dump.pyi index 821fb95b7f5d..d6dd0350b16f 100644 --- a/stubs/commonmark/commonmark/dump.pyi +++ b/stubs/commonmark/commonmark/dump.pyi @@ -1,3 +1,7 @@ -def prepare(obj, topnode: bool = ...): ... -def dumpJSON(obj): ... -def dumpAST(obj, ind: int = ..., topnode: bool = ...) -> None: ... +from typing import Any + +from .node import Node + +def prepare(obj: Node, topnode: bool = ...) -> list[dict[str, Any]]: ... +def dumpJSON(obj: Node) -> str: ... +def dumpAST(obj: Node, ind: int = ..., topnode: bool = ...) -> None: ... diff --git a/stubs/commonmark/commonmark/inlines.pyi b/stubs/commonmark/commonmark/inlines.pyi index e53f22a10cf8..5202a01bdc97 100644 --- a/stubs/commonmark/commonmark/inlines.pyi +++ b/stubs/commonmark/commonmark/inlines.pyi @@ -1,65 +1,68 @@ import html -from typing import Any +import re +from typing import Any, Final, Literal + +from .node import Node HTMLunescape = html.unescape -ESCAPED_CHAR: Any -rePunctuation: Any -reLinkTitle: Any -reLinkDestinationBraces: Any -reEscapable: Any -reEntityHere: Any -reTicks: Any -reTicksHere: Any -reEllipses: Any -reDash: Any -reEmailAutolink: Any -reAutolink: Any -reSpnl: Any -reWhitespaceChar: Any -reWhitespace: Any -reUnicodeWhitespaceChar: Any -reFinalSpace: Any -reInitialSpace: Any -reSpaceAtEndOfLine: Any -reLinkLabel: Any -reMain: Any +ESCAPED_CHAR: Final[str] +rePunctuation: Final[re.Pattern[str]] +reLinkTitle: Final[re.Pattern[str]] +reLinkDestinationBraces: Final[re.Pattern[str]] +reEscapable: Final[re.Pattern[str]] +reEntityHere: Final[re.Pattern[str]] +reTicks: Final[re.Pattern[str]] +reTicksHere: Final[re.Pattern[str]] +reEllipses: Final[re.Pattern[str]] +reDash: Final[re.Pattern[str]] +reEmailAutolink: Final[re.Pattern[str]] +reAutolink: Final[re.Pattern[str]] +reSpnl: Final[re.Pattern[str]] +reWhitespaceChar: Final[re.Pattern[str]] +reWhitespace: Final[re.Pattern[str]] +reUnicodeWhitespaceChar: Final[re.Pattern[str]] +reFinalSpace: Final[re.Pattern[str]] +reInitialSpace: Final[re.Pattern[str]] +reSpaceAtEndOfLine: Final[re.Pattern[str]] +reLinkLabel: Final[re.Pattern[str]] +reMain: Final[re.Pattern[str]] -def text(s): ... -def smart_dashes(chars): ... +def text(s: str) -> Node: ... +def smart_dashes(chars: str) -> str: ... class InlineParser: subject: str - brackets: Any + brackets: dict[str, Any] | None pos: int - refmap: Any - options: Any - def __init__(self, options=...) -> None: ... - def match(self, regexString): ... - def peek(self): ... - def spnl(self): ... - def parseBackticks(self, block): ... - def parseBackslash(self, block): ... - def parseAutolink(self, block): ... - def parseHtmlTag(self, block): ... - def scanDelims(self, c): ... - delimiters: Any - def handleDelim(self, cc, block): ... - def removeDelimiter(self, delim) -> None: ... + refmap: dict[str, Any] + options: dict[str, Any] + def __init__(self, options: dict[str, Any] = {}) -> None: ... + def match(self, regexString: str | re.Pattern[str]) -> str | None: ... + def peek(self) -> str | None: ... + def spnl(self) -> Literal[True]: ... + def parseBackticks(self, block: Node) -> bool: ... + def parseBackslash(self, block: Node) -> Literal[True]: ... + def parseAutolink(self, block: Node) -> bool: ... + def parseHtmlTag(self, block: Node) -> bool: ... + def scanDelims(self, c: str) -> dict[str, Any] | None: ... + delimiters: dict[str, Any] + def handleDelim(self, cc: str, block: Node) -> bool: ... + def removeDelimiter(self, delim: dict[str, Any]) -> None: ... @staticmethod - def removeDelimitersBetween(bottom, top) -> None: ... + def removeDelimitersBetween(bottom: dict[str, Any], top: dict[str, Any]) -> None: ... def processEmphasis(self, stack_bottom) -> None: ... - def parseLinkTitle(self): ... - def parseLinkDestination(self): ... - def parseLinkLabel(self): ... - def parseOpenBracket(self, block): ... - def parseBang(self, block): ... - def parseCloseBracket(self, block): ... + def parseLinkTitle(self) -> str | None: ... + def parseLinkDestination(self) -> str | None: ... + def parseLinkLabel(self) -> int: ... + def parseOpenBracket(self, block: Node) -> Literal[True]: ... + def parseBang(self, block: Node) -> Literal[True]: ... + def parseCloseBracket(self, block: Node) -> Literal[True]: ... def addBracket(self, node, index, image) -> None: ... def removeBracket(self) -> None: ... - def parseEntity(self, block): ... - def parseString(self, block): ... - def parseNewline(self, block): ... - def parseReference(self, s, refmap): ... - def parseInline(self, block): ... - def parseInlines(self, block) -> None: ... - parse: Any + def parseEntity(self, block: Node) -> bool: ... + def parseString(self, block: Node) -> bool: ... + def parseNewline(self, block: Node) -> Literal[True]: ... + def parseReference(self, s: str, refmap: dict[str, Any]) -> int: ... + def parseInline(self, block: Node) -> bool: ... + def parseInlines(self, block: Node) -> None: ... + parse = parseInlines diff --git a/stubs/commonmark/commonmark/main.pyi b/stubs/commonmark/commonmark/main.pyi index c1768b9203ad..34059e6d22cd 100644 --- a/stubs/commonmark/commonmark/main.pyi +++ b/stubs/commonmark/commonmark/main.pyi @@ -1,3 +1,3 @@ from typing import Literal -def commonmark(text: str, format: Literal["html", "json", "ast", "rst"] = ...) -> str: ... +def commonmark(text: str, format: Literal["html", "json", "ast", "rst"] = "html") -> str: ... diff --git a/stubs/commonmark/commonmark/node.pyi b/stubs/commonmark/commonmark/node.pyi index 8760df613cd1..ffab8f5c98f1 100644 --- a/stubs/commonmark/commonmark/node.pyi +++ b/stubs/commonmark/commonmark/node.pyi @@ -1,51 +1,53 @@ -from typing import Any +import re +from typing import Final +from typing_extensions import Self -reContainer: Any +reContainer: Final[re.Pattern[str]] -def is_container(node): ... +def is_container(node: Node) -> bool: ... class NodeWalker: - current: Any - root: Any + current: Node | None + root: Node entering: bool - def __init__(self, root) -> None: ... - def __next__(self): ... - next: Any - def __iter__(self): ... - def nxt(self): ... - def resume_at(self, node, entering) -> None: ... + def __init__(self, root: Node) -> None: ... + def __next__(self) -> tuple[Node, bool]: ... + next = __next__ + def __iter__(self) -> Self: ... + def nxt(self) -> dict[str, Node | bool] | None: ... + def resume_at(self, node: Node, entering: bool) -> None: ... class Node: - t: Any - parent: Any - first_child: Any - last_child: Any - prv: Any - nxt: Any - sourcepos: Any + t: str + parent: Node | None + first_child: Node | None + last_child: Node | None + prv: Node | None + nxt: Node | None + sourcepos: list[list[int]] | None last_line_blank: bool last_line_checked: bool is_open: bool string_content: str - literal: Any - list_data: Any - info: Any - destination: Any - title: Any + literal: str | None + list_data: dict[str, str | int | bool | None] + info: str | None + destination: str | None + title: str | None is_fenced: bool - fence_char: Any + fence_char: str | None fence_length: int - fence_offset: Any - level: Any - on_enter: Any - on_exit: Any - def __init__(self, node_type, sourcepos) -> None: ... + fence_offset: int | None + level: int | None + on_enter: str | None + on_exit: str | None + def __init__(self, node_type: str, sourcepos: list[list[int]] | None) -> None: ... def pretty(self) -> None: ... def normalize(self) -> None: ... - def is_container(self): ... - def append_child(self, child) -> None: ... - def prepend_child(self, child) -> None: ... + def is_container(self) -> bool: ... + def append_child(self, child: Node) -> None: ... + def prepend_child(self, child: Node) -> None: ... def unlink(self) -> None: ... - def insert_after(self, sibling) -> None: ... - def insert_before(self, sibling) -> None: ... - def walker(self): ... + def insert_after(self, sibling: Node) -> None: ... + def insert_before(self, sibling: Node) -> None: ... + def walker(self) -> NodeWalker: ... diff --git a/stubs/commonmark/commonmark/normalize_reference.pyi b/stubs/commonmark/commonmark/normalize_reference.pyi index 96a3414d109b..0386213d006b 100644 --- a/stubs/commonmark/commonmark/normalize_reference.pyi +++ b/stubs/commonmark/commonmark/normalize_reference.pyi @@ -1 +1 @@ -def normalize_reference(string): ... +def normalize_reference(string: str) -> str: ... diff --git a/stubs/commonmark/commonmark/render/html.pyi b/stubs/commonmark/commonmark/render/html.pyi index 02637833a4ae..618c0f5edd2e 100644 --- a/stubs/commonmark/commonmark/render/html.pyi +++ b/stubs/commonmark/commonmark/render/html.pyi @@ -1,38 +1,43 @@ -from _typeshed import Incomplete -from typing import Any +import re +from builtins import list as _list # conflicts with a method named "list" +from typing import Any, Final, Literal, overload +from commonmark.node import Node from commonmark.render.renderer import Renderer -reUnsafeProtocol: Any -reSafeDataProtocol: Any +reUnsafeProtocol: Final[re.Pattern[str]] +reSafeDataProtocol: Final[re.Pattern[str]] -def potentially_unsafe(url): ... +def potentially_unsafe(url: str) -> bool | None: ... class HtmlRenderer(Renderer): disable_tags: int last_out: str - options: Any - def __init__(self, options=...) -> None: ... - def escape(self, text): ... - def tag(self, name, attrs: Incomplete | None = ..., selfclosing: Incomplete | None = ...) -> None: ... - def text(self, node, entering: Incomplete | None = ...) -> None: ... - def softbreak(self, node: Incomplete | None = ..., entering: Incomplete | None = ...) -> None: ... - def linebreak(self, node: Incomplete | None = ..., entering: Incomplete | None = ...) -> None: ... - def link(self, node, entering) -> None: ... - def image(self, node, entering) -> None: ... - def emph(self, node, entering) -> None: ... - def strong(self, node, entering) -> None: ... - def paragraph(self, node, entering) -> None: ... - def heading(self, node, entering) -> None: ... - def code(self, node, entering) -> None: ... - def code_block(self, node, entering) -> None: ... - def thematic_break(self, node, entering) -> None: ... - def block_quote(self, node, entering) -> None: ... - def list(self, node, entering) -> None: ... - def item(self, node, entering) -> None: ... - def html_inline(self, node, entering) -> None: ... - def html_block(self, node, entering) -> None: ... - def custom_inline(self, node, entering) -> None: ... - def custom_block(self, node, entering) -> None: ... - def out(self, s) -> None: ... - def attrs(self, node): ... + options: dict[str, Any] + def __init__(self, options: dict[str, Any] = {}) -> None: ... + @overload + def escape(self, text: None) -> Literal[""]: ... + @overload + def escape(self, text: str) -> str: ... + def tag(self, name: str, attrs: _list[_list[str]] | None = None, selfclosing: bool | None = None) -> None: ... + def text(self, node: Node, entering: bool | None = None) -> None: ... + def softbreak(self, node: Node | None = None, entering: bool | None = None) -> None: ... + def linebreak(self, node: Node | None = None, entering: bool | None = None) -> None: ... + def link(self, node: Node, entering: bool | None) -> None: ... + def image(self, node: Node, entering: bool | None) -> None: ... + def emph(self, node: Node, entering: bool | None) -> None: ... + def strong(self, node: Node, entering: bool | None) -> None: ... + def paragraph(self, node: Node, entering: bool | None) -> None: ... + def heading(self, node: Node, entering: bool | None) -> None: ... + def code(self, node: Node, entering: bool | None) -> None: ... + def code_block(self, node: Node, entering: bool | None) -> None: ... + def thematic_break(self, node: Node, entering: bool | None) -> None: ... + def block_quote(self, node: Node, entering: bool | None) -> None: ... + def list(self, node: Node, entering: bool | None) -> None: ... + def item(self, node: Node, entering: bool | None) -> None: ... + def html_inline(self, node: Node, entering: bool | None) -> None: ... + def html_block(self, node: Node, entering: bool | None) -> None: ... + def custom_inline(self, node: Node, entering: bool | None) -> None: ... + def custom_block(self, node: Node, entering: bool | None) -> None: ... + def out(self, s: str | None) -> None: ... + def attrs(self, node: Node) -> _list[_list[str]]: ... diff --git a/stubs/commonmark/commonmark/render/renderer.pyi b/stubs/commonmark/commonmark/render/renderer.pyi index b8e2e46f0969..db1ec57a4573 100644 --- a/stubs/commonmark/commonmark/render/renderer.pyi +++ b/stubs/commonmark/commonmark/render/renderer.pyi @@ -1,7 +1,9 @@ +from commonmark.node import Node + class Renderer: buf: str last_out: str - def render(self, ast): ... - def lit(self, s) -> None: ... + def render(self, ast: Node) -> str: ... + def lit(self, s: str) -> None: ... def cr(self) -> None: ... - def out(self, s) -> None: ... + def out(self, s: str) -> None: ... diff --git a/stubs/commonmark/commonmark/render/rst.pyi b/stubs/commonmark/commonmark/render/rst.pyi index 9357bfd9fc37..fd181c8779b5 100644 --- a/stubs/commonmark/commonmark/render/rst.pyi +++ b/stubs/commonmark/commonmark/render/rst.pyi @@ -1,26 +1,25 @@ -from typing import Any - +from commonmark.node import Node from commonmark.render.renderer import Renderer class ReStructuredTextRenderer(Renderer): - indent_char: Any + indent_char: str indent_length: int - def __init__(self, indent_char: str = ...) -> None: ... - def lit(self, s): ... + def __init__(self, indent_char: str = " ") -> None: ... + def lit(self, s: str) -> None: ... def cr(self) -> None: ... - def indent_lines(self, literal, indent_length: int = ...): ... - def document(self, node, entering) -> None: ... - def softbreak(self, node, entering) -> None: ... - def linebreak(self, node, entering) -> None: ... - def text(self, node, entering) -> None: ... - def emph(self, node, entering) -> None: ... - def strong(self, node, entering) -> None: ... - def paragraph(self, node, entering) -> None: ... - def link(self, node, entering) -> None: ... - def image(self, node, entering) -> None: ... - def code(self, node, entering) -> None: ... - def code_block(self, node, entering) -> None: ... - def list(self, node, entering) -> None: ... - def item(self, node, entering) -> None: ... - def block_quote(self, node, entering) -> None: ... - def heading(self, node, entering) -> None: ... + def indent_lines(self, literal: str, indent_length: int = 4) -> str: ... + def document(self, node: Node | None, entering: bool | None) -> None: ... + def softbreak(self, node: Node | None, entering: bool | None) -> None: ... + def linebreak(self, node: Node | None, entering: bool | None) -> None: ... + def text(self, node: Node, entering: bool | None) -> None: ... + def emph(self, node: Node | None, entering: bool | None) -> None: ... + def strong(self, node: Node | None, entering: bool | None) -> None: ... + def paragraph(self, node: Node, entering: bool | None) -> None: ... + def link(self, node: Node | None, entering: bool | None) -> None: ... + def image(self, node: Node, entering: bool | None) -> None: ... + def code(self, node: Node, entering: bool | None) -> None: ... + def code_block(self, node: Node, entering: bool | None) -> None: ... + def list(self, node: Node | None, entering: bool | None) -> None: ... + def item(self, node: Node, entering: bool | None) -> None: ... + def block_quote(self, node: Node | None, entering: bool | None) -> None: ... + def heading(self, node: Node, entering: bool | None) -> None: ...