From 40b127d46abd305ad71b678f1ff19847638a7afe Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 30 Jun 2021 16:19:43 +0200 Subject: [PATCH] Add third-party commonmark stubs (#5702) --- pyrightconfig.stricter.json | 1 + stubs/commonmark/METADATA.toml | 1 + stubs/commonmark/commonmark/__init__.pyi | 5 + stubs/commonmark/commonmark/blocks.pyi | 166 ++++++++++++++++++ stubs/commonmark/commonmark/cmark.pyi | 1 + stubs/commonmark/commonmark/common.pyi | 35 ++++ stubs/commonmark/commonmark/dump.pyi | 3 + stubs/commonmark/commonmark/entitytrans.pyi | 1 + stubs/commonmark/commonmark/inlines.pyi | 65 +++++++ stubs/commonmark/commonmark/main.pyi | 3 + stubs/commonmark/commonmark/node.pyi | 51 ++++++ .../commonmark/normalize_reference.pyi | 1 + .../commonmark/commonmark/render/__init__.pyi | 0 stubs/commonmark/commonmark/render/html.pyi | 37 ++++ .../commonmark/commonmark/render/renderer.pyi | 7 + stubs/commonmark/commonmark/render/rst.pyi | 26 +++ 16 files changed, 403 insertions(+) create mode 100644 stubs/commonmark/METADATA.toml create mode 100644 stubs/commonmark/commonmark/__init__.pyi create mode 100644 stubs/commonmark/commonmark/blocks.pyi create mode 100644 stubs/commonmark/commonmark/cmark.pyi create mode 100644 stubs/commonmark/commonmark/common.pyi create mode 100644 stubs/commonmark/commonmark/dump.pyi create mode 100644 stubs/commonmark/commonmark/entitytrans.pyi create mode 100644 stubs/commonmark/commonmark/inlines.pyi create mode 100644 stubs/commonmark/commonmark/main.pyi create mode 100644 stubs/commonmark/commonmark/node.pyi create mode 100644 stubs/commonmark/commonmark/normalize_reference.pyi create mode 100644 stubs/commonmark/commonmark/render/__init__.pyi create mode 100644 stubs/commonmark/commonmark/render/html.pyi create mode 100644 stubs/commonmark/commonmark/render/renderer.pyi create mode 100644 stubs/commonmark/commonmark/render/rst.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 5974705a5..729f56cc7 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -27,6 +27,7 @@ "stubs/backports_abc", "stubs/bleach", "stubs/boto", + "stubs/commonmark", "stubs/cryptography", "stubs/docutils", "stubs/Flask", diff --git a/stubs/commonmark/METADATA.toml b/stubs/commonmark/METADATA.toml new file mode 100644 index 000000000..16fd217d5 --- /dev/null +++ b/stubs/commonmark/METADATA.toml @@ -0,0 +1 @@ +version = "0.9" diff --git a/stubs/commonmark/commonmark/__init__.pyi b/stubs/commonmark/commonmark/__init__.pyi new file mode 100644 index 000000000..9d6feae3d --- /dev/null +++ b/stubs/commonmark/commonmark/__init__.pyi @@ -0,0 +1,5 @@ +from commonmark.blocks import Parser as Parser +from commonmark.dump import dumpAST as dumpAST, dumpJSON as dumpJSON +from commonmark.main import commonmark as commonmark +from commonmark.render.html import HtmlRenderer as HtmlRenderer +from commonmark.render.rst import ReStructuredTextRenderer as ReStructuredTextRenderer diff --git a/stubs/commonmark/commonmark/blocks.pyi b/stubs/commonmark/commonmark/blocks.pyi new file mode 100644 index 000000000..25504c4b9 --- /dev/null +++ b/stubs/commonmark/commonmark/blocks.pyi @@ -0,0 +1,166 @@ +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): ... + +class Block: + accepts_lines: Any + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...) -> None: ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t) -> None: ... + +class Document(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class List(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class BlockQuote(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class Item(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class Heading(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class ThematicBreak(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class CodeBlock(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class HtmlBlock(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class Paragraph(Block): + accepts_lines: bool + @staticmethod + def continue_(parser: Any | None = ..., container: Any | None = ...): ... + @staticmethod + def finalize(parser: Any | None = ..., block: Any | None = ...) -> None: ... + @staticmethod + def can_contain(t): ... + +class BlockStarts: + METHODS: Any + @staticmethod + def block_quote(parser, container: Any | None = ...): ... + @staticmethod + def atx_heading(parser, container: Any | None = ...): ... + @staticmethod + def fenced_code_block(parser, container: Any | None = ...): ... + @staticmethod + def html_block(parser, container: Any | None = ...): ... + @staticmethod + def setext_heading(parser, container: Any | None = ...): ... + @staticmethod + def thematic_break(parser, container: Any | None = ...): ... + @staticmethod + def list_item(parser, container: Any | None = ...): ... + @staticmethod + def indented_code_block(parser, container: Any | None = ...): ... + +class Parser: + doc: Any + block_starts: Any + tip: Any + oldtip: Any + current_line: str + line_number: int + offset: int + column: int + next_nonspace: int + next_nonspace_column: int + indent: int + indented: bool + blank: bool + partially_consumed_tab: bool + all_closed: bool + last_matched_container: Any + refmap: Any + last_line_length: int + inline_parser: Any + options: Any + def __init__(self, options=...) -> None: ... + def add_line(self) -> None: ... + def add_child(self, tag, offset): ... + 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): ... + +CAMEL_RE: Any diff --git a/stubs/commonmark/commonmark/cmark.pyi b/stubs/commonmark/commonmark/cmark.pyi new file mode 100644 index 000000000..7e7363e79 --- /dev/null +++ b/stubs/commonmark/commonmark/cmark.pyi @@ -0,0 +1 @@ +def main() -> None: ... diff --git a/stubs/commonmark/commonmark/common.pyi b/stubs/commonmark/commonmark/common.pyi new file mode 100644 index 000000000..c55a67969 --- /dev/null +++ b/stubs/commonmark/commonmark/common.pyi @@ -0,0 +1,35 @@ +import html +from typing import Any + +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 + +def unescape_char(s): ... +def unescape_string(s): ... +def normalize_uri(uri): ... + +UNSAFE_MAP: Any + +def replace_unsafe_char(s): ... +def escape_xml(s): ... diff --git a/stubs/commonmark/commonmark/dump.pyi b/stubs/commonmark/commonmark/dump.pyi new file mode 100644 index 000000000..821fb95b7 --- /dev/null +++ b/stubs/commonmark/commonmark/dump.pyi @@ -0,0 +1,3 @@ +def prepare(obj, topnode: bool = ...): ... +def dumpJSON(obj): ... +def dumpAST(obj, ind: int = ..., topnode: bool = ...) -> None: ... diff --git a/stubs/commonmark/commonmark/entitytrans.pyi b/stubs/commonmark/commonmark/entitytrans.pyi new file mode 100644 index 000000000..b8b0efae5 --- /dev/null +++ b/stubs/commonmark/commonmark/entitytrans.pyi @@ -0,0 +1 @@ +def _unescape(s: str) -> str: ... diff --git a/stubs/commonmark/commonmark/inlines.pyi b/stubs/commonmark/commonmark/inlines.pyi new file mode 100644 index 000000000..e53f22a10 --- /dev/null +++ b/stubs/commonmark/commonmark/inlines.pyi @@ -0,0 +1,65 @@ +import html +from typing import Any + +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 + +def text(s): ... +def smart_dashes(chars): ... + +class InlineParser: + subject: str + brackets: Any + 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: ... + @staticmethod + def removeDelimitersBetween(bottom, top) -> 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 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 diff --git a/stubs/commonmark/commonmark/main.pyi b/stubs/commonmark/commonmark/main.pyi new file mode 100644 index 000000000..c7c6b4219 --- /dev/null +++ b/stubs/commonmark/commonmark/main.pyi @@ -0,0 +1,3 @@ +from typing_extensions import Literal + +def commonmark(text: str, format: Literal["html", "json", "ast", "rst"] = ...) -> str: ... diff --git a/stubs/commonmark/commonmark/node.pyi b/stubs/commonmark/commonmark/node.pyi new file mode 100644 index 000000000..8760df613 --- /dev/null +++ b/stubs/commonmark/commonmark/node.pyi @@ -0,0 +1,51 @@ +from typing import Any + +reContainer: Any + +def is_container(node): ... + +class NodeWalker: + current: Any + root: Any + 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: ... + +class Node: + t: Any + parent: Any + first_child: Any + last_child: Any + prv: Any + nxt: Any + sourcepos: Any + 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 + is_fenced: bool + fence_char: Any + fence_length: int + fence_offset: Any + level: Any + on_enter: Any + on_exit: Any + def __init__(self, node_type, sourcepos) -> 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 unlink(self) -> None: ... + def insert_after(self, sibling) -> None: ... + def insert_before(self, sibling) -> None: ... + def walker(self): ... diff --git a/stubs/commonmark/commonmark/normalize_reference.pyi b/stubs/commonmark/commonmark/normalize_reference.pyi new file mode 100644 index 000000000..96a3414d1 --- /dev/null +++ b/stubs/commonmark/commonmark/normalize_reference.pyi @@ -0,0 +1 @@ +def normalize_reference(string): ... diff --git a/stubs/commonmark/commonmark/render/__init__.pyi b/stubs/commonmark/commonmark/render/__init__.pyi new file mode 100644 index 000000000..e69de29bb diff --git a/stubs/commonmark/commonmark/render/html.pyi b/stubs/commonmark/commonmark/render/html.pyi new file mode 100644 index 000000000..b98864128 --- /dev/null +++ b/stubs/commonmark/commonmark/render/html.pyi @@ -0,0 +1,37 @@ +from typing import Any + +from commonmark.render.renderer import Renderer + +reUnsafeProtocol: Any +reSafeDataProtocol: Any + +def potentially_unsafe(url): ... + +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: Any | None = ..., selfclosing: Any | None = ...) -> None: ... + def text(self, node, entering: Any | None = ...) -> None: ... + def softbreak(self, node: Any | None = ..., entering: Any | None = ...) -> None: ... + def linebreak(self, node: Any | None = ..., entering: Any | 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): ... diff --git a/stubs/commonmark/commonmark/render/renderer.pyi b/stubs/commonmark/commonmark/render/renderer.pyi new file mode 100644 index 000000000..b8e2e46f0 --- /dev/null +++ b/stubs/commonmark/commonmark/render/renderer.pyi @@ -0,0 +1,7 @@ +class Renderer: + buf: str + last_out: str + def render(self, ast): ... + def lit(self, s) -> None: ... + def cr(self) -> None: ... + def out(self, s) -> None: ... diff --git a/stubs/commonmark/commonmark/render/rst.pyi b/stubs/commonmark/commonmark/render/rst.pyi new file mode 100644 index 000000000..9357bfd9f --- /dev/null +++ b/stubs/commonmark/commonmark/render/rst.pyi @@ -0,0 +1,26 @@ +from typing import Any + +from commonmark.render.renderer import Renderer + +class ReStructuredTextRenderer(Renderer): + indent_char: Any + indent_length: int + def __init__(self, indent_char: str = ...) -> None: ... + def lit(self, s): ... + 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: ...