-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8241ad
commit 2741fe4
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,4 +126,7 @@ venv.bak/ | |
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
.apyre/ | ||
|
||
# PyCharm | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .extension import MKClickExtension, makeExtension | ||
|
||
__version__ = '0.0.1' | ||
__all__ = ["MKClickExtension", "makeExtension"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from markdown import Markdown | ||
from markdown.extensions import Extension | ||
from markdown.preprocessors import Preprocessor | ||
|
||
import xml.etree.ElementTree as etree | ||
import re | ||
|
||
class ClickProcessor(Preprocessor): | ||
|
||
PATTERN = re.compile(r'^:::click module=([:a-zA-Z0-9_.]+):([:a-zA-Z0-9_.]+)::: *$') | ||
|
||
def run(self, lines: [str]) -> [str]: | ||
new_lines = [] | ||
for line in lines: | ||
m = self.PATTERN.search(line) | ||
if m: | ||
path, command = m.groups() | ||
new_lines.append("Found a command:") | ||
new_lines.append(f" - Path={path}") | ||
new_lines.append(f" - Command={command}") | ||
else: | ||
new_lines.append(line) | ||
|
||
return new_lines | ||
|
||
class MKClickExtension(Extension): | ||
def extendMarkdown(self, md: Markdown) -> None: | ||
md.registerExtension(self) | ||
processor = ClickProcessor(md.parser) | ||
md.preprocessors.register(processor, "mk_clik", 141) | ||
|
||
def makeExtension(): | ||
return MKClickExtension() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# (C) Datadog, Inc. 2020-present | ||
# All rights reserved | ||
# Licensed under the Apache license (see LICENSE) | ||
from setuptools import setup | ||
|
||
VERSION = '0.0.1' | ||
|
||
REQUIRES = [] | ||
|
||
setup( | ||
name='mkdocs-click', | ||
version=VERSION, | ||
description='An mkdocs extension to document click methods', | ||
keywords='mkdocs datadog click', | ||
url='https://github.com/DataDog/mkdocs-click', | ||
author='Datadog', | ||
author_email='[email protected]', | ||
license='Apache', | ||
packages=['mkdocs_click'], | ||
install_requires=REQUIRES, | ||
python_requires='>=3.0', | ||
include_package_data=True, | ||
entry_points={ | ||
'markdown.extensions': ['mkdocs-click = mkdocs_click.:MKClickExtension'] | ||
} | ||
) | ||
|