Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
Fixes for markdown stubs (python#4758)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andersk authored Nov 13, 2020
1 parent 20a8472 commit 536a5c6
Show file tree
Hide file tree
Showing 26 changed files with 60 additions and 173 deletions.
1 change: 1 addition & 0 deletions third_party/2and3/markdown/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .core import Markdown as Markdown, markdown as markdown, markdownFromFile as markdownFromFile
from .extensions import Extension as Extension
25 changes: 3 additions & 22 deletions third_party/2and3/markdown/blockprocessors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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): ...
13 changes: 11 additions & 2 deletions third_party/2and3/markdown/core.pyi
Original file line number Diff line number Diff line change
@@ -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,
*,
Expand Down
16 changes: 8 additions & 8 deletions third_party/2and3/markdown/extensions/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
10 changes: 3 additions & 7 deletions third_party/2and3/markdown/extensions/abbr.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
5 changes: 1 addition & 4 deletions third_party/2and3/markdown/extensions/admonition.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
4 changes: 1 addition & 3 deletions third_party/2and3/markdown/extensions/attr_list.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
3 changes: 0 additions & 3 deletions third_party/2and3/markdown/extensions/codehilite.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
11 changes: 2 additions & 9 deletions third_party/2and3/markdown/extensions/def_list.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
2 changes: 0 additions & 2 deletions third_party/2and3/markdown/extensions/extra.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
4 changes: 1 addition & 3 deletions third_party/2and3/markdown/extensions/fenced_code.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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): ...
7 changes: 0 additions & 7 deletions third_party/2and3/markdown/extensions/footnotes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...): ...
Expand All @@ -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
Expand All @@ -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): ...
4 changes: 1 addition & 3 deletions third_party/2and3/markdown/extensions/legacy_attrs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
7 changes: 2 additions & 5 deletions third_party/2and3/markdown/extensions/legacy_em.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
8 changes: 2 additions & 6 deletions third_party/2and3/markdown/extensions/md_in_html.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
4 changes: 1 addition & 3 deletions third_party/2and3/markdown/extensions/meta.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
3 changes: 1 addition & 2 deletions third_party/2and3/markdown/extensions/nl2br.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
8 changes: 1 addition & 7 deletions third_party/2and3/markdown/extensions/sane_lists.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
6 changes: 0 additions & 6 deletions third_party/2and3/markdown/extensions/smarty.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,15 @@ 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: ...
def educateEllipses(self, md) -> None: ...
def educateAngledQuotes(self, md) -> None: ...
def educateQuotes(self, md) -> None: ...
inlinePatterns: Any
def extendMarkdown(self, md) -> None: ...

def makeExtension(**kwargs): ...
5 changes: 1 addition & 4 deletions third_party/2and3/markdown/extensions/tables.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
3 changes: 0 additions & 3 deletions third_party/2and3/markdown/extensions/toc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Loading

0 comments on commit 536a5c6

Please sign in to comment.