Fixes for markdown stubs (#4758)

* AbbrPreprocessor subclasses BlockProcessor
* Remove members inherited from base classes
* Add missing markdown.Extension alias
* Add missing Markdown members
* Fix Extension.config type
* Fix Pattern.handleMatch type
This commit is contained in:
Anders Kaseorg
2020-11-13 02:25:01 -08:00
committed by GitHub
parent 20a847218a
commit 536a5c6162
26 changed files with 60 additions and 173 deletions

View File

@@ -1 +1,2 @@
from .core import Markdown as Markdown, markdown as markdown, markdownFromFile as markdownFromFile
from .extensions import Extension as Extension

View File

@@ -19,19 +19,13 @@ class ListIndentProcessor(BlockProcessor):
LIST_TYPES: Any
INDENT_RE: Pattern
def __init__(self, *args) -> None: ...
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
def create_item(self, parent, block) -> None: ...
def get_level(self, parent, block): ...
class CodeBlockProcessor(BlockProcessor):
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class CodeBlockProcessor(BlockProcessor): ...
class BlockQuoteProcessor(BlockProcessor):
RE: Pattern
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
def clean(self, line): ...
class OListProcessor(BlockProcessor):
@@ -43,8 +37,6 @@ class OListProcessor(BlockProcessor):
CHILD_RE: Pattern
INDENT_RE: Pattern
def __init__(self, parser) -> None: ...
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
def get_items(self, block): ...
class UListProcessor(OListProcessor):
@@ -54,25 +46,14 @@ class UListProcessor(OListProcessor):
class HashHeaderProcessor(BlockProcessor):
RE: Pattern
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class SetextHeaderProcessor(BlockProcessor):
RE: Pattern
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class HRProcessor(BlockProcessor):
RE: str = ...
SEARCH_RE: Pattern
match: Any
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class EmptyBlockProcessor(BlockProcessor):
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class ParagraphProcessor(BlockProcessor):
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class EmptyBlockProcessor(BlockProcessor): ...
class ParagraphProcessor(BlockProcessor): ...

View File

@@ -1,14 +1,23 @@
from typing import Any, BinaryIO, Mapping, Optional, Sequence, Text, TextIO, Union
from typing import Any, BinaryIO, Callable, ClassVar, Dict, List, Mapping, Optional, Sequence, Text, TextIO, Union
from typing_extensions import Literal
from xml.etree.ElementTree import Element
from .blockparser import BlockParser
from .extensions import Extension
from .util import Registry
from .util import HtmlStash, Registry
class Markdown:
preprocessors: Registry
inlinePatterns: Registry
treeprocessors: Registry
postprocessors: Registry
parser: BlockParser
htmlStash: HtmlStash
output_formats: ClassVar[Dict[Literal["xhtml", "html"], Callable[[Element], Text]]]
output_format: Literal["xhtml", "html"]
serializer: Callable[[Element], Text]
tab_length: int
block_level_elements: List[str]
def __init__(
self,
*,

View File

@@ -1,13 +1,13 @@
from typing import Mapping, Sequence
from typing import Any, Dict, List, Mapping, Tuple
from markdown.core import Markdown
class Extension:
config: Mapping[str, str] = ...
def __init__(self, **kwargs: Mapping[str, str]) -> None: ...
def getConfig(self, key: str, default: str = ...) -> str: ...
def getConfigs(self) -> Mapping[str, str]: ...
def getConfigInfo(self) -> Sequence[Mapping[str, str]]: ...
def setConfig(self, key: str, value: str) -> None: ...
def setConfigs(self, items: Mapping[str, str]) -> None: ...
config: Mapping[str, List[Any]] = ...
def __init__(self, **kwargs: Any) -> None: ...
def getConfig(self, key: str, default: Any = ...) -> Any: ...
def getConfigs(self) -> Dict[str, Any]: ...
def getConfigInfo(self) -> List[Tuple[str, str]]: ...
def setConfig(self, key: str, value: Any) -> None: ...
def setConfigs(self, items: Mapping[str, Any]) -> None: ...
def extendMarkdown(self, md: Markdown) -> None: ...

View File

@@ -1,20 +1,16 @@
from typing import Any, Pattern
from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
from markdown.inlinepatterns import InlineProcessor
from markdown.preprocessors import Preprocessor
ABBR_REF_RE: Pattern
class AbbrExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class AbbrPreprocessor(Preprocessor):
def run(self, lines): ...
class AbbrExtension(Extension): ...
class AbbrPreprocessor(BlockProcessor): ...
class AbbrInlineProcessor(InlineProcessor):
title: Any
def __init__(self, pattern, title) -> None: ...
def handleMatch(self, m, data): ... # type: ignore
def makeExtension(**kwargs): ...

View File

@@ -3,16 +3,13 @@ from typing import Any, Pattern
from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
class AdmonitionExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class AdmonitionExtension(Extension): ...
class AdmonitionProcessor(BlockProcessor):
CLASSNAME: str = ...
CLASSNAME_TITLE: str = ...
RE: Pattern
RE_SPACES: Any
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
def get_class_and_title(self, match): ...
def makeExtension(**kwargs): ...

View File

@@ -12,11 +12,9 @@ class AttrListTreeprocessor(Treeprocessor):
BLOCK_RE: Pattern
INLINE_RE: Pattern
NAME_RE: Pattern
def run(self, doc) -> None: ...
def assign_attrs(self, elem, attrs) -> None: ...
def sanitize_name(self, name): ...
class AttrListExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class AttrListExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -35,11 +35,8 @@ class CodeHilite:
class HiliteTreeprocessor(Treeprocessor):
def code_unescape(self, text): ...
def run(self, root) -> None: ...
class CodeHiliteExtension(Extension):
config: Any
def __init__(self, **kwargs) -> None: ...
def extendMarkdown(self, md) -> None: ...
def makeExtension(**kwargs): ...

View File

@@ -6,15 +6,8 @@ from markdown.extensions import Extension
class DefListProcessor(BlockProcessor):
RE: Pattern
NO_INDENT_RE: Pattern
def test(self, parent, block): ...
def run(self, parent, blocks): ...
class DefListIndentProcessor(ListIndentProcessor):
ITEM_TYPES: Any
LIST_TYPES: Any
def create_item(self, parent, block) -> None: ...
class DefListExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class DefListIndentProcessor(ListIndentProcessor): ...
class DefListExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -5,8 +5,6 @@ from markdown.extensions import Extension
extensions: Any
class ExtraExtension(Extension):
config: Any
def __init__(self, **kwargs) -> None: ...
def extendMarkdown(self, md) -> None: ...
def makeExtension(**kwargs): ...

View File

@@ -3,8 +3,7 @@ from typing import Any, Pattern
from markdown.extensions import Extension
from markdown.preprocessors import Preprocessor
class FencedCodeExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class FencedCodeExtension(Extension): ...
class FencedBlockPreprocessor(Preprocessor):
FENCED_BLOCK_RE: Pattern
@@ -13,6 +12,5 @@ class FencedBlockPreprocessor(Preprocessor):
checked_for_codehilite: bool = ...
codehilite_conf: Any
def __init__(self, md) -> None: ...
def run(self, lines): ...
def makeExtension(**kwargs): ...

View File

@@ -13,14 +13,12 @@ TABBED_RE: Pattern
RE_REF_ID: Any
class FootnoteExtension(Extension):
config: Any
unique_prefix: int = ...
found_refs: Any
used_refs: Any
def __init__(self, **kwargs) -> None: ...
parser: Any
md: Any
def extendMarkdown(self, md) -> None: ...
footnotes: Any
def reset(self) -> None: ...
def unique_ref(self, reference, found: bool = ...): ...
@@ -34,13 +32,11 @@ class FootnoteExtension(Extension):
class FootnotePreprocessor(Preprocessor):
footnotes: Any
def __init__(self, footnotes) -> None: ...
def run(self, lines): ...
def detectTabbed(self, lines): ...
class FootnoteInlineProcessor(InlineProcessor):
footnotes: Any
def __init__(self, pattern, footnotes) -> None: ...
def handleMatch(self, m, data): ... # type: ignore
class FootnotePostTreeprocessor(Treeprocessor):
footnotes: Any
@@ -49,16 +45,13 @@ class FootnotePostTreeprocessor(Treeprocessor):
def get_num_duplicates(self, li): ...
def handle_duplicates(self, parent) -> None: ...
offset: int = ...
def run(self, root) -> None: ...
class FootnoteTreeprocessor(Treeprocessor):
footnotes: Any
def __init__(self, footnotes) -> None: ...
def run(self, root) -> None: ...
class FootnotePostprocessor(Postprocessor):
footnotes: Any
def __init__(self, footnotes) -> None: ...
def run(self, text): ...
def makeExtension(**kwargs): ...

View File

@@ -6,10 +6,8 @@ from markdown.treeprocessors import Treeprocessor
ATTR_RE: Pattern
class LegacyAttrs(Treeprocessor):
def run(self, doc) -> None: ...
def handleAttributes(self, el, txt): ...
class LegacyAttrExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class LegacyAttrExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -7,10 +7,7 @@ EMPHASIS_RE: str
STRONG_RE: str
STRONG_EM_RE: str
class LegacyUnderscoreProcessor(UnderscoreProcessor):
PATTERNS: Any
class LegacyEmExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class LegacyUnderscoreProcessor(UnderscoreProcessor): ...
class LegacyEmExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -3,11 +3,7 @@ from typing import Any, Optional
from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
class MarkdownInHtmlProcessor(BlockProcessor):
def test(self, parent, block): ...
def run(self, parent, blocks, tail: Optional[Any] = ..., nest: bool = ...) -> None: ...
class MarkdownInHtmlExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class MarkdownInHtmlProcessor(BlockProcessor): ...
class MarkdownInHtmlExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -11,10 +11,8 @@ END_RE: Pattern
class MetaExtension(Extension):
md: Any
def extendMarkdown(self, md) -> None: ...
def reset(self) -> None: ...
class MetaPreprocessor(Preprocessor):
def run(self, lines): ...
class MetaPreprocessor(Preprocessor): ...
def makeExtension(**kwargs): ...

View File

@@ -4,7 +4,6 @@ from markdown.extensions import Extension
BR_RE: str
class Nl2BrExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class Nl2BrExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -4,17 +4,11 @@ from markdown.blockprocessors import OListProcessor, UListProcessor
from markdown.extensions import Extension
class SaneOListProcessor(OListProcessor):
SIBLING_TAGS: Any
LAZY_OL: bool = ...
CHILD_RE: Pattern
def __init__(self, parser) -> None: ...
class SaneUListProcessor(UListProcessor):
SIBLING_TAGS: Any
CHILD_RE: Pattern
def __init__(self, parser) -> None: ...
class SaneListExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class SaneListExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -25,14 +25,9 @@ HTML_STRICT_RE: str
class SubstituteTextPattern(HtmlInlineProcessor):
replace: Any
md: Any
def __init__(self, pattern, replace, md) -> None: ...
@property
def markdown(self): ...
def handleMatch(self, m, data): ... # type: ignore
class SmartyExtension(Extension):
config: Any
substitutions: Any
def __init__(self, **kwargs) -> None: ...
def educateDashes(self, md) -> None: ...
@@ -40,6 +35,5 @@ class SmartyExtension(Extension):
def educateAngledQuotes(self, md) -> None: ...
def educateQuotes(self, md) -> None: ...
inlinePatterns: Any
def extendMarkdown(self, md) -> None: ...
def makeExtension(**kwargs): ...

View File

@@ -13,10 +13,7 @@ class TableProcessor(BlockProcessor):
border: bool = ...
separator: str = ...
def __init__(self, parser) -> None: ...
def test(self, parent, block): ...
def run(self, parent, blocks) -> None: ...
class TableExtension(Extension):
def extendMarkdown(self, md) -> None: ...
class TableExtension(Extension): ...
def makeExtension(**kwargs): ...

View File

@@ -34,14 +34,11 @@ class TocTreeprocessor(Treeprocessor):
def add_anchor(self, c, elem_id) -> None: ...
def add_permalink(self, c, elem_id) -> None: ...
def build_toc_div(self, toc_list): ...
def run(self, doc) -> None: ...
class TocExtension(Extension):
TreeProcessorClass: Any
config: Any
def __init__(self, **kwargs) -> None: ...
md: Any
def extendMarkdown(self, md) -> None: ...
def reset(self) -> None: ...
def makeExtension(**kwargs): ...

View File

@@ -6,14 +6,11 @@ from markdown.inlinepatterns import InlineProcessor
def build_url(label, base, end): ...
class WikiLinkExtension(Extension):
config: Any
def __init__(self, **kwargs) -> None: ...
md: Any
def extendMarkdown(self, md) -> None: ...
class WikiLinksInlineProcessor(InlineProcessor):
config: Any
def __init__(self, pattern, config) -> None: ...
def handleMatch(self, m, data): ... # type: ignore
def makeExtension(**kwargs): ...

View File

@@ -1,4 +1,5 @@
from typing import Any, Optional
from typing import Any, Match, Optional, Tuple, Union
from xml.etree.ElementTree import Element
def build_inlinepatterns(md, **kwargs): ...
@@ -39,58 +40,38 @@ class Pattern:
@property
def markdown(self): ...
def getCompiledRegExp(self): ...
def handleMatch(self, m) -> None: ...
def handleMatch(self, m: Match) -> Optional[Union[str, Element]]: ...
def type(self): ...
def unescape(self, text): ...
class InlineProcessor(Pattern):
pattern: Any
compiled_re: Any
safe_mode: bool = ...
md: Any
def __init__(self, pattern, md: Optional[Any] = ...) -> None: ...
def handleMatch(self, m, data) -> None: ... # type: ignore
def handleMatch(self, m: Match, data) -> Union[Tuple[Element, int, int], Tuple[None, None, None]]: ... # type: ignore
class SimpleTextPattern(Pattern):
def handleMatch(self, m): ...
class SimpleTextInlineProcessor(InlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class EscapeInlineProcessor(InlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class SimpleTextPattern(Pattern): ...
class SimpleTextInlineProcessor(InlineProcessor): ...
class EscapeInlineProcessor(InlineProcessor): ...
class SimpleTagPattern(Pattern):
tag: Any
def __init__(self, pattern, tag) -> None: ...
def handleMatch(self, m): ...
class SimpleTagInlineProcessor(InlineProcessor):
tag: Any
def __init__(self, pattern, tag) -> None: ...
def handleMatch(self, m, data): ... # type: ignore
class SubstituteTagPattern(SimpleTagPattern):
def handleMatch(self, m): ...
class SubstituteTagInlineProcessor(SimpleTagInlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class SubstituteTagPattern(SimpleTagPattern): ...
class SubstituteTagInlineProcessor(SimpleTagInlineProcessor): ...
class BacktickInlineProcessor(InlineProcessor):
ESCAPED_BSLASH: Any
tag: str = ...
def __init__(self, pattern) -> None: ...
def handleMatch(self, m, data): ... # type: ignore
class DoubleTagPattern(SimpleTagPattern):
def handleMatch(self, m): ...
class DoubleTagInlineProcessor(SimpleTagInlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class HtmlInlineProcessor(InlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
def unescape(self, text): ...
class DoubleTagPattern(SimpleTagPattern): ...
class DoubleTagInlineProcessor(SimpleTagInlineProcessor): ...
class HtmlInlineProcessor(InlineProcessor): ...
class AsteriskProcessor(InlineProcessor):
PATTERNS: Any
@@ -99,7 +80,6 @@ class AsteriskProcessor(InlineProcessor):
def build_double2(self, m, tags, idx): ...
def parse_sub_patterns(self, data, parent, last, idx) -> None: ...
def build_element(self, m, builder, tags, index): ...
def handleMatch(self, m, data): ... # type: ignore
class UnderscoreProcessor(AsteriskProcessor):
PATTERNS: Any
@@ -107,28 +87,17 @@ class UnderscoreProcessor(AsteriskProcessor):
class LinkInlineProcessor(InlineProcessor):
RE_LINK: Any
RE_TITLE_CLEAN: Any
def handleMatch(self, m, data): ... # type: ignore
def getLink(self, data, index): ...
def getText(self, data, index): ...
class ImageInlineProcessor(LinkInlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class ImageInlineProcessor(LinkInlineProcessor): ...
class ReferenceInlineProcessor(LinkInlineProcessor):
NEWLINE_CLEANUP_RE: Pattern
RE_LINK: Any
def handleMatch(self, m, data): ... # type: ignore
def evalId(self, data, index, text): ...
def makeTag(self, href, title, text): ...
class ShortReferenceInlineProcessor(ReferenceInlineProcessor):
def evalId(self, data, index, text): ...
class ImageReferenceInlineProcessor(ReferenceInlineProcessor):
def makeTag(self, href, title, text): ...
class AutolinkInlineProcessor(InlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class AutomailInlineProcessor(InlineProcessor):
def handleMatch(self, m, data): ... # type: ignore
class ShortReferenceInlineProcessor(ReferenceInlineProcessor): ...
class ImageReferenceInlineProcessor(ReferenceInlineProcessor): ...
class AutolinkInlineProcessor(InlineProcessor): ...
class AutomailInlineProcessor(InlineProcessor): ...

View File

@@ -8,13 +8,10 @@ class Postprocessor(util.Processor):
def run(self, text) -> None: ...
class RawHtmlPostprocessor(Postprocessor):
def run(self, text): ...
def isblocklevel(self, html): ...
class AndSubstitutePostprocessor(Postprocessor):
def run(self, text): ...
class AndSubstitutePostprocessor(Postprocessor): ...
class UnescapePostprocessor(Postprocessor):
RE: Pattern
def unescape(self, m): ...
def run(self, text): ...

View File

@@ -7,8 +7,7 @@ def build_preprocessors(md, **kwargs): ...
class Preprocessor(util.Processor):
def run(self, lines: List[str]) -> List[str]: ...
class NormalizeWhitespace(Preprocessor):
def run(self, lines: Iterable[str]) -> List[str]: ...
class NormalizeWhitespace(Preprocessor): ...
class HtmlBlockPreprocessor(Preprocessor):
right_tag_patterns: Any
@@ -17,10 +16,8 @@ class HtmlBlockPreprocessor(Preprocessor):
attrs_re: Any
left_tag_re: Any
markdown_in_raw: bool = ...
def run(self, lines: Iterable[str]) -> List[str]: ...
class ReferencePreprocessor(Preprocessor):
TITLE: str = ...
RE: Pattern
TITLE_RE: Pattern
def run(self, lines: List[str]) -> List[str]: ...

View File

@@ -9,15 +9,11 @@ class Treeprocessor(util.Processor):
def run(self, root) -> None: ...
class InlineProcessor(Treeprocessor):
md: Any
inlinePatterns: Any
ancestors: Any
def __init__(self, md) -> None: ...
@property
def markdown(self): ...
stashed_nodes: Any
parent_map: Any
def run(self, tree, ancestors: Optional[Any] = ...): ...
class PrettifyTreeprocessor(Treeprocessor):
def run(self, root) -> None: ...
class PrettifyTreeprocessor(Treeprocessor): ...