mkdocs-entangled-plugin 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/PKG-INFO +8 -2
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/README.md +5 -0
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/on_page_markdown.py +1 -1
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/plugin.py +0 -9
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/pyproject.toml +3 -3
- mkdocs_entangled_plugin-0.3.0/mkdocs_entangled/mawk.py +0 -100
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/LICENSE +0 -0
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/__init__.py +0 -0
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/config.py +0 -0
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/properties.py +0 -0
- {mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-entangled-plugin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Plugin for MkDocs helping with rendering Entangled (entangled.github.io) projects.
|
|
5
5
|
License: Apache 2.0
|
|
6
6
|
Author: Johan Hidding
|
|
@@ -9,13 +9,17 @@ Requires-Python: >=3.11,<4.0
|
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Requires-Dist: entangled-cli
|
|
12
|
+
Requires-Dist: entangled-cli (>=2.0.0a6,<3.0.0)
|
|
13
|
+
Requires-Dist: mawk (>=0.1.4,<0.2.0)
|
|
13
14
|
Requires-Dist: mkdocs (>=1.4.2,<2.0.0)
|
|
14
15
|
Description-Content-Type: text/markdown
|
|
15
16
|
|
|
16
17
|
# Welcome to MkDocs Entangled Plugin
|
|
17
18
|
Using this plugin, you can make your Entangled documents look better.
|
|
18
19
|
|
|
20
|
+
## Examples
|
|
21
|
+
Detailed examples are found in the [entangled/mkdocs-examples repository](https://entangled.github.io/mkdocs-examples).
|
|
22
|
+
|
|
19
23
|
## Install
|
|
20
24
|
|
|
21
25
|
Install this with `pip install mkdocs-entangled-plugin`. To use the entangled plugin, add the following lines to your `mkdocs.yml`:
|
|
@@ -30,6 +34,8 @@ markdown_extensions:
|
|
|
30
34
|
alternate_style: true
|
|
31
35
|
```
|
|
32
36
|
|
|
37
|
+
For more information, see [the documentation](https://entangled.github.io/mkdocs-plugin).
|
|
38
|
+
|
|
33
39
|
## Components
|
|
34
40
|
This plugin bundles functionality for literate programming with Entangled.
|
|
35
41
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Welcome to MkDocs Entangled Plugin
|
|
2
2
|
Using this plugin, you can make your Entangled documents look better.
|
|
3
3
|
|
|
4
|
+
## Examples
|
|
5
|
+
Detailed examples are found in the [entangled/mkdocs-examples repository](https://entangled.github.io/mkdocs-examples).
|
|
6
|
+
|
|
4
7
|
## Install
|
|
5
8
|
|
|
6
9
|
Install this with `pip install mkdocs-entangled-plugin`. To use the entangled plugin, add the following lines to your `mkdocs.yml`:
|
|
@@ -15,6 +18,8 @@ markdown_extensions:
|
|
|
15
18
|
alternate_style: true
|
|
16
19
|
```
|
|
17
20
|
|
|
21
|
+
For more information, see [the documentation](https://entangled.github.io/mkdocs-plugin).
|
|
22
|
+
|
|
18
23
|
## Components
|
|
19
24
|
This plugin bundles functionality for literate programming with Entangled.
|
|
20
25
|
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import logging
|
|
2
1
|
import mkdocs
|
|
3
2
|
from mkdocs.config.defaults import MkDocsConfig
|
|
4
3
|
from mkdocs.structure.pages import Page
|
|
5
4
|
from mkdocs.structure.files import Files
|
|
6
5
|
|
|
7
|
-
from entangled.commands import sync
|
|
8
|
-
from entangled.main import configure
|
|
9
|
-
|
|
10
6
|
from .on_page_markdown import on_page_markdown
|
|
11
7
|
from .config import EntangledConfig
|
|
12
8
|
|
|
13
9
|
class EntangledPlugin(mkdocs.plugins.BasePlugin[EntangledConfig]):
|
|
14
|
-
def on_pre_build(self, config: MkDocsConfig):
|
|
15
|
-
configure()
|
|
16
|
-
logging.info("Running `entangled sync`")
|
|
17
|
-
sync()
|
|
18
|
-
|
|
19
10
|
def on_page_markdown(self, markdown: str, *, page: Page, config: MkDocsConfig, files: Files):
|
|
20
11
|
return on_page_markdown(markdown, page=page, config=config, files=files)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "mkdocs-entangled-plugin"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Plugin for MkDocs helping with rendering Entangled (entangled.github.io) projects."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = ["Johan Hidding <j.hidding@esciencecenter.nl>"]
|
|
@@ -15,8 +15,8 @@ entangled = "mkdocs_entangled:EntangledPlugin"
|
|
|
15
15
|
[tool.poetry.dependencies]
|
|
16
16
|
python = "^3.11"
|
|
17
17
|
mkdocs = "^1.4.2"
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
entangled-cli = "^2.0.0a6"
|
|
19
|
+
mawk = "^0.1.4"
|
|
20
20
|
|
|
21
21
|
[tool.poetry.dev-dependencies]
|
|
22
22
|
mypy = "^1.2.0"
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
μAwk, a tiny awk-like interface in Python
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from typing import Callable, Optional
|
|
6
|
-
from functools import wraps, partial
|
|
7
|
-
import re
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"""Global counter to sort filters by the order in which they appear
|
|
11
|
-
in a class."""
|
|
12
|
-
_filter_creation_order = 0
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def match_filter(expr: str, handler: Callable[[re.Match], Optional[list[str]]], inp: str) -> Optional[list[str]]:
|
|
16
|
-
if m := re.match(expr, inp):
|
|
17
|
-
return handler(m)
|
|
18
|
-
return None
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def on_match(expr: str):
|
|
22
|
-
"""Decorator for doing search-and-replace based on a given regex.
|
|
23
|
-
|
|
24
|
-
The inner function should take as argument a `re.Match` object
|
|
25
|
-
and return a list of strings. The resulting decorated function
|
|
26
|
-
then becomes a function from string to list of strings.
|
|
27
|
-
|
|
28
|
-
If the input doesn't match the given regex, the original string
|
|
29
|
-
is returned.
|
|
30
|
-
|
|
31
|
-
The inner function may still decide to do nothing by returning None.
|
|
32
|
-
|
|
33
|
-
To erase the matched input return the empty list.
|
|
34
|
-
|
|
35
|
-
This decorator also works on class methods. It is then assumed that
|
|
36
|
-
the method has signature `(self, m: re.Match)`.
|
|
37
|
-
"""
|
|
38
|
-
def _decorator(f):
|
|
39
|
-
global _filter_creation_order
|
|
40
|
-
method = len(f.__qualname__.split('.')) > 1
|
|
41
|
-
if method:
|
|
42
|
-
@wraps(f)
|
|
43
|
-
def _impl(self, inp):
|
|
44
|
-
return match_filter(expr, partial(f, self), inp)
|
|
45
|
-
_impl._is_rule = _filter_creation_order # add tag to method
|
|
46
|
-
_filter_creation_order += 1
|
|
47
|
-
return _impl
|
|
48
|
-
else:
|
|
49
|
-
return wraps(f)(partial(match_filter, expr, f))
|
|
50
|
-
return _decorator
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def always(f):
|
|
54
|
-
"""Suppose you have a rule with `@on_match(r".*")`, then it is better
|
|
55
|
-
not to run the regex machinery at all and just pass on the string.
|
|
56
|
-
In that case it is better to use `@always`."""
|
|
57
|
-
global _filter_creation_order
|
|
58
|
-
method = len(f.__qualname__.split('.')) > 1
|
|
59
|
-
if method:
|
|
60
|
-
f._is_rule = _filter_creation_order # add tag to method
|
|
61
|
-
_filter_creation_order += 1
|
|
62
|
-
return f
|
|
63
|
-
else:
|
|
64
|
-
return f
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Rule = Callable[[str], list[str]]
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def run(rules: list[Rule], inp: str, exclusive=True) -> str:
|
|
71
|
-
"""Takes a list of rules, being function from `str` to `list[str]`.
|
|
72
|
-
The input string is split into lines, after which each line is fed
|
|
73
|
-
through the list of rules. All the results are colected into a list
|
|
74
|
-
of strings and then joined by newline.
|
|
75
|
-
"""
|
|
76
|
-
lines = inp.splitlines()
|
|
77
|
-
result = []
|
|
78
|
-
for l in lines:
|
|
79
|
-
for r in rules:
|
|
80
|
-
v = r(l)
|
|
81
|
-
if v is not None:
|
|
82
|
-
result.extend(v)
|
|
83
|
-
if exclusive:
|
|
84
|
-
break
|
|
85
|
-
else:
|
|
86
|
-
result.append(l)
|
|
87
|
-
return "\n".join(result)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class RuleSet:
|
|
91
|
-
"""To be used as a base class for classes that contain `on_match`
|
|
92
|
-
decorated methods."""
|
|
93
|
-
def list_rules(self):
|
|
94
|
-
members = (getattr(self, m) for m in dir(self) if m[0] != '_')
|
|
95
|
-
rules = [m for m in members if hasattr(m, '_is_rule')]
|
|
96
|
-
return sorted(rules, key=lambda r: r._is_rule)
|
|
97
|
-
|
|
98
|
-
def run(self, inp: str, exclusive=True) -> str:
|
|
99
|
-
"""Runs all rules in the class on input."""
|
|
100
|
-
return run(self.list_rules(), inp, exclusive)
|
|
File without changes
|
{mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{mkdocs_entangled_plugin-0.3.0 → mkdocs_entangled_plugin-0.4.0}/mkdocs_entangled/properties.py
RENAMED
|
File without changes
|
|
File without changes
|