Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add API docs #1379

Merged
merged 61 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9fad090
Create API docs
pawamoy Aug 22, 2023
8e406cd
fixup! Create API docs
pawamoy Aug 24, 2023
5c510cb
fixup! Create API docs
pawamoy Aug 24, 2023
7af5634
fixup! Create API docs
pawamoy Aug 24, 2023
42cec09
fixup! Create API docs
pawamoy Aug 24, 2023
4166503
fixup! Create API docs
pawamoy Aug 24, 2023
d388012
fixup! Create API docs
pawamoy Sep 8, 2023
2e06483
fixup! Create API docs
pawamoy Sep 13, 2023
cb70465
fixup! Create API docs
pawamoy Sep 14, 2023
1140876
100% covergae of patch
waylan Sep 14, 2023
c78dacf
remove core.py from documented modules it is repeated
waylan Sep 15, 2023
6947744
refactor doc strings in core.py
waylan Sep 15, 2023
236ecd2
update spelling dictionary
waylan Sep 15, 2023
26383c2
Normalize docs of extension argument
waylan Sep 15, 2023
6b4810a
cleanup
waylan Sep 18, 2023
e40bd43
Added a bunch of internal links
waylan Sep 18, 2023
fc8dc2d
fix line length
waylan Sep 18, 2023
eb5c596
document attributes on markdown.Markdown.
waylan Sep 18, 2023
3757ed8
cleanup Markdown.references attribute
waylan Sep 18, 2023
d25f0ad
add output_format attribute
waylan Sep 20, 2023
6757ed7
add serializer attribute
waylan Sep 20, 2023
14823e6
CLean up autoref link styles for consistency
waylan Sep 20, 2023
dfa6944
some text cleanup
waylan Sep 21, 2023
f7b06d5
Update pre/tree/postprocessors
waylan Sep 21, 2023
d040b24
Update blockparser
waylan Sep 21, 2023
f53c551
Update util
waylan Sep 21, 2023
14e3850
update test_tools
waylan Sep 21, 2023
58f2e20
Cleanup
waylan Sep 21, 2023
290cf0d
more Cleanup
waylan Sep 21, 2023
ef34df7
Order objects by source
waylan Sep 22, 2023
6d2a365
Update serializers
waylan Sep 22, 2023
a22f3db
Add styles for labels
waylan Sep 25, 2023
cecec29
Update extensions
waylan Sep 25, 2023
8a0d9db
Update inlinepatterns
waylan Sep 26, 2023
72cb6e0
Update various extensions
waylan Sep 26, 2023
a4cff19
Some cleanup
waylan Sep 26, 2023
bcfd78e
more cleanup
waylan Sep 26, 2023
5388f83
Add changelog entry
waylan Sep 27, 2023
6f0f4a8
Update spelling dict
waylan Sep 27, 2023
09e152d
Add custom template for proper admonitions (no more details elements).
waylan Sep 27, 2023
92dfdcd
Coverage
waylan Sep 28, 2023
3448847
Add support for deprecated decorator
pawamoy Sep 28, 2023
2dacbed
Don't show inherited members in extension subclasses
pawamoy Sep 28, 2023
7f7648c
CLeanup deprecations and style label
waylan Sep 28, 2023
af74150
Add details to various extensions
waylan Sep 28, 2023
326b56f
spelling cleanup
waylan Sep 28, 2023
13e6254
Force attributes to always have separate signature
waylan Sep 29, 2023
9198aa5
Ensure attribute name is wrapped in code tag.
waylan Sep 29, 2023
fdbcd4f
Use attribute.source to preserve formatting in signature
waylan Sep 29, 2023
0d26314
preserve annotations in attrs, move source to end of content, & only …
waylan Sep 29, 2023
d36a222
Add a section header for the attr source
waylan Sep 29, 2023
87153b4
cleanup attributes
waylan Sep 29, 2023
1620acb
lint cleanup
waylan Sep 29, 2023
7e7242a
ext config requires list not tuple
waylan Oct 2, 2023
29debb4
document all regexes for inlinepatterns
waylan Oct 3, 2023
c5d8c0d
Add priority table to each build* function via an extention
waylan Oct 4, 2023
dea1158
wrap names in code spans
waylan Oct 4, 2023
cb78d4f
Some tweaks to styling
waylan Oct 4, 2023
675858a
build_block_parser returns a BlockParser not a Registry
waylan Oct 5, 2023
59c1299
finish documenting inlinepatterns
waylan Oct 5, 2023
c9bbb68
Add links to source on Github
waylan Oct 6, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ target/
.python-version

# virtualenv
.venv/
venv/
ENV/

Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ assert someitem in registry

: Add an item to the registry with the given name and priority.

Parameters:
Arguments:

* `item`: The item being registered.
* `name`: A string used to reference the item.
Expand Down
52 changes: 52 additions & 0 deletions docs/mkdocstrings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
}

/* Mark external links as such. */
a.external::after,
a.autorefs-external::after {
/* https://primer.style/octicons/arrow-up-right-24 */
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
-webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
content: ' ';

display: inline-block;
vertical-align: middle;
position: relative;

height: 1em;
width: 1em;
background-color: #005b81;
}

a.external:hover::after,
a.autorefs-external:hover::after {
background-color: #e32e00;
}

/* Cancel codehilite background in headings. */
.doc-heading .codehilite {
background: unset;
}
pawamoy marked this conversation as resolved.
Show resolved Hide resolved

/* Customize symbol names. */
code.doc-symbol-attribute::after {
content: "Attr";
}

code.doc-symbol-function::after {
content: "Func";
}

code.doc-symbol-method::after {
content: "Method";
}

code.doc-symbol-class::after {
content: "Class";
}

code.doc-symbol-module::after {
content: "Module";
}
24 changes: 19 additions & 5 deletions markdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,34 @@

A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
- Documentation: https://python-markdown.github.io/
- GitHub: https://github.com/Python-Markdown/markdown/
- PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).

Modules:
core: Core functionality.
preprocessors: Pre-processors.
blockparser: Core Markdown block parser.
blockprocessors: Block processors.
treeprocessors: Tree processors.
inlinepatterns: Inline patterns.
postprocessors: Post-processors.
serializers: Serializers.
util: Utility functions.
htmlparser: HTML parser.
test_tools: Testing utilities.
extensions: Markdown extensions.
"""

from .core import Markdown, markdown, markdownFromFile
Expand Down
28 changes: 13 additions & 15 deletions markdown/__main__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
"""
Python Markdown
# Python Markdown

A Python implementation of John Gruber's Markdown.
# A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
# Documentation: https://python-markdown.github.io/
# GitHub: https://github.com/Python-Markdown/markdown/
# PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
# Started by Manfred Stienstra (http://www.dwerg.net/).
# Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
# Currently maintained by Waylan Limberg (https://github.com/waylan),
# Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
# Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
# Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
"""
# License: BSD (see LICENSE.md for details).

import sys
import optparse
Expand Down
28 changes: 13 additions & 15 deletions markdown/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
"""
Python Markdown
# Python Markdown

A Python implementation of John Gruber's Markdown.
# A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
# Documentation: https://python-markdown.github.io/
# GitHub: https://github.com/Python-Markdown/markdown/
# PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
# Started by Manfred Stienstra (http://www.dwerg.net/).
# Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
# Currently maintained by Waylan Limberg (https://github.com/waylan),
# Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
# Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
# Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
"""
# License: BSD (see LICENSE.md for details).

# __version_info__ format:
# (major, minor, patch, dev/alpha/beta/rc/final, #)
Expand Down
62 changes: 43 additions & 19 deletions markdown/blockparser.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
"""
Python Markdown
# Python Markdown

A Python implementation of John Gruber's Markdown.
# A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
# Documentation: https://python-markdown.github.io/
# GitHub: https://github.com/Python-Markdown/markdown/
# PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
# Started by Manfred Stienstra (http://www.dwerg.net/).
# Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
# Currently maintained by Waylan Limberg (https://github.com/waylan),
# Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
# Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
# Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
"""
# License: BSD (see LICENSE.md for details).

from __future__ import annotations

import xml.etree.ElementTree as etree
from typing import TYPE_CHECKING, Sequence
from . import util

if TYPE_CHECKING:
from markdown import Markdown

Check warning on line 27 in markdown/blockparser.py

View check run for this annotation

Codecov / codecov/patch

markdown/blockparser.py#L27

Added line #L27 was not covered by tests


class State(list):
""" Track the current and nested state of the parser.
Expand Down Expand Up @@ -62,14 +66,21 @@

A wrapper class that stitches the various `BlockProcessors` together,
looping through them and creating an `ElementTree` object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong feeling about this. We should just try and be consistent. Or not, it's not super important.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I'm not sure what you are referring to here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant, whether to keep trailing new lines in docstrings.

Currently it seems the project follows these rules:

  • Leading and trailing space around summary.
  • Trailing blank line after body.

"""

def __init__(self, md):
def __init__(self, md: Markdown):
""" Initialize the block parser.

Arguments:
md: A Markdown instance.

"""
self.blockprocessors = util.Registry()
self.state = State()
self.md = md

def parseDocument(self, lines):
def parseDocument(self, lines: Sequence[str]) -> etree.ElementTree:
""" Parse a markdown document into an ElementTree.

Given a list of lines, an ElementTree object (not just a parent
Expand All @@ -78,13 +89,18 @@

This should only be called on an entire document, not pieces.

Arguments:
lines: A list of lines (strings).

Returns:
An element tree.
"""
# Create an `ElementTree` from the lines
self.root = etree.Element(self.md.doc_tag)
self.parseChunk(self.root, '\n'.join(lines))
return etree.ElementTree(self.root)

def parseChunk(self, parent, text):
def parseChunk(self, parent: etree.Element, text: str):
""" Parse a chunk of markdown text and attach to given `etree` node.

While the `text` argument is generally assumed to contain multiple
Expand All @@ -95,10 +111,14 @@
The `parent` `etree` Element passed in is altered in place.
Nothing is returned.

Arguments:
parent: The parent element.
text: The text to parse.

"""
self.parseBlocks(parent, text.split('\n\n'))

def parseBlocks(self, parent, blocks):
def parseBlocks(self, parent: etree.Element, blocks: Sequence[str]):
""" Process blocks of markdown text and attach to given `etree` node.

Given a list of `blocks`, each `blockprocessor` is stepped through
Expand All @@ -110,6 +130,10 @@
additional `BlockProcessors` which call this method to recursively
parse a nested block.

Arguments:
parent: The parent element.
blocks: The blocks of text to parse.

"""
while blocks:
for processor in self.blockprocessors:
Expand Down
28 changes: 14 additions & 14 deletions markdown/blockprocessors.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""
Python Markdown
# Python Markdown

A Python implementation of John Gruber's Markdown.
# A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/
# Documentation: https://python-markdown.github.io/
# GitHub: https://github.com/Python-Markdown/markdown/
# PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
# Started by Manfred Stienstra (http://www.dwerg.net/).
# Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
# Currently maintained by Waylan Limberg (https://github.com/waylan),
# Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)
# Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
# Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
# License: BSD (see LICENSE.md for details).

"""
CORE MARKDOWN BLOCKPARSER
===========================================================================

Expand Down
Loading
Loading