Skip to content

Contributed stubs for markdown package #4426

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions third_party/2and3/markdown/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .core import Markdown as Markdown, markdown as markdown, markdownFromFile as markdownFromFile
49 changes: 49 additions & 0 deletions third_party/2and3/markdown/core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing import BinaryIO, Mapping, Optional, Sequence, Text, TextIO, Union
from typing_extensions import Literal

from .extensions import Extension

class Markdown:
def __init__(
self,
*,
extensions: Optional[Sequence[Union[str, Extension]]] = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be marked as keyword-only

extension_configs: Optional[Mapping[str, Mapping[str, str]]] = ...,
output_format: Optional[Literal["xhtml", "html"]] = ...,
tab_length: Optional[int] = ...,
) -> None: ...
def build_parser(self) -> Markdown: ...
def registerExtensions(
self, extensions: Sequence[Union[Extension, str]], configs: Mapping[str, Mapping[str, str]]
) -> Markdown: ...
def build_extension(self, ext_name: Text, configs: Mapping[str, str]) -> Extension: ...
def registerExtension(self, extension: Extension) -> Markdown: ...
def reset(self: Markdown) -> Markdown: ...
def set_output_format(self, format: Literal["xhtml", "html"]) -> Markdown: ...
def is_block_level(self, tag: str) -> bool: ...
def convert(self, source: Text) -> Text: ...
def convertFile(
self,
input: Optional[Union[str, TextIO, BinaryIO]] = ...,
output: Optional[Union[str, TextIO, BinaryIO]] = ...,
encoding: Optional[str] = ...,
) -> Markdown: ...

def markdown(
text: Text,
*,
extensions: Optional[Sequence[Union[str, Extension]]] = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extensions and on should be keyword only

extension_configs: Optional[Mapping[str, Mapping[str, str]]] = ...,
output_format: Optional[Literal["xhtml", "html"]] = ...,
tab_length: Optional[int] = ...,
) -> Text: ...
def markdownFromFile(
*,
input: Optional[Union[str, TextIO, BinaryIO]] = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these should also be keyword only

output: Optional[Union[str, TextIO, BinaryIO]] = ...,
encoding: Optional[str] = ...,
extensions: Optional[Sequence[Union[str, Extension]]] = ...,
extension_configs: Optional[Mapping[str, Mapping[str, str]]] = ...,
output_format: Optional[Literal["xhtml", "html"]] = ...,
tab_length: Optional[int] = ...,
) -> None: ...
13 changes: 13 additions & 0 deletions third_party/2and3/markdown/extensions/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Mapping, Sequence

from ..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: ...
def extendMarkdown(self, md: Markdown) -> None: ...