mkdocs-entangled-plugin 0.5.0__tar.gz → 0.7.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.5.0 → mkdocs_entangled_plugin-0.7.0}/PKG-INFO +4 -4
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/on_page_markdown.py +22 -19
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/pyproject.toml +6 -3
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/.gitignore +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/LICENSE +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/README.md +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/__init__.py +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/config.py +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/plugin.py +0 -0
- {mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/py.typed +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: mkdocs-entangled-plugin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Plugin for MkDocs helping with rendering Entangled (entangled.github.io) projects.
|
|
5
5
|
Author-email: Johan Hidding <j.hidding@esciencecenter.nl>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
License-File: LICENSE
|
|
8
|
-
Requires-Python: <4,>=3.
|
|
9
|
-
Requires-Dist: entangled-cli<3,>=2.
|
|
8
|
+
Requires-Python: <4,>=3.13
|
|
9
|
+
Requires-Dist: entangled-cli<3,>=2.5
|
|
10
10
|
Requires-Dist: mawk<0.2,>=0.1.7
|
|
11
11
|
Requires-Dist: mkdocs<2,>=1.4.2
|
|
12
12
|
Description-Content-Type: text/markdown
|
{mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/on_page_markdown.py
RENAMED
|
@@ -8,18 +8,13 @@ from mkdocs.config.defaults import MkDocsConfig
|
|
|
8
8
|
from mkdocs.structure.pages import Page
|
|
9
9
|
from mkdocs.structure.files import Files
|
|
10
10
|
|
|
11
|
-
from entangled.
|
|
12
|
-
from entangled.properties import get_attribute, Id, Attribute, Class
|
|
13
|
-
from entangled.
|
|
14
|
-
from entangled.
|
|
11
|
+
from entangled.model import ReferenceMap, Content, PlainText, ReferenceId, CodeBlock, content_to_text
|
|
12
|
+
from entangled.model.properties import get_attribute, Id, Attribute, Class
|
|
13
|
+
from entangled.config import ConfigUpdate, read_config
|
|
14
|
+
from entangled.interface import Context, read_markdown
|
|
15
|
+
from entangled.io import FileCache
|
|
15
16
|
from repl_session import read_session
|
|
16
17
|
|
|
17
|
-
config.read()
|
|
18
|
-
|
|
19
|
-
# The Entangled config needs to be read before importing the Markdown reader
|
|
20
|
-
# This is very bad I know, and should be fixed in some future version.
|
|
21
|
-
from entangled.markdown_reader import read_markdown_string
|
|
22
|
-
|
|
23
18
|
|
|
24
19
|
type ContentFilter = Callable[[ReferenceMap, Content], Iterable[Content]]
|
|
25
20
|
type CodeBlockFilter = Callable[[ReferenceMap, ReferenceId], Iterable[Content]]
|
|
@@ -35,6 +30,10 @@ def codeblock_filter(f: CodeBlockFilter) -> ContentFilter:
|
|
|
35
30
|
return _foo
|
|
36
31
|
|
|
37
32
|
|
|
33
|
+
def document_to_text(refs: ReferenceMap, content: Iterable[Content]) -> str:
|
|
34
|
+
return "".join(map(lambda c: content_to_text(refs, c)[0], content))
|
|
35
|
+
|
|
36
|
+
|
|
38
37
|
def iter_bind[T, U](lst: Iterable[T], f: Callable[[T], Iterable[U]]) -> Iterable[U]:
|
|
39
38
|
return chain(*map(f, lst))
|
|
40
39
|
|
|
@@ -46,12 +45,14 @@ def compose_filter(a: ContentFilter, b: ContentFilter) -> ContentFilter:
|
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
def compose_filters(*args: ContentFilter) -> ContentFilter:
|
|
49
|
-
|
|
48
|
+
identity: ContentFilter = lambda _, c: [c]
|
|
49
|
+
return reduce(compose_filter, args, identity)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
def read_single_markdown(ctx: Context, text: str) -> tuple[ReferenceMap, list[Content]]:
|
|
53
|
+
refs = ReferenceMap()
|
|
54
|
+
content, _ = read_markdown(ctx, refs, text)
|
|
55
|
+
return refs, content
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
@codeblock_filter
|
|
@@ -60,7 +61,7 @@ def add_title(reference_map: ReferenceMap, r: ReferenceId) -> list[Content]:
|
|
|
60
61
|
Changes the `open_line` member of a `CodeBlock` to reflect accepted
|
|
61
62
|
MkDocs syntax, adding a `title` attribute.
|
|
62
63
|
"""
|
|
63
|
-
codeblock: CodeBlock = reference_map
|
|
64
|
+
codeblock: CodeBlock = reference_map[r]
|
|
64
65
|
|
|
65
66
|
ids = [p.value for p in codeblock.properties if isinstance(p, Id)]
|
|
66
67
|
classes = [p.value for p in codeblock.properties if isinstance(p, Class)]
|
|
@@ -93,7 +94,7 @@ def add_title(reference_map: ReferenceMap, r: ReferenceId) -> list[Content]:
|
|
|
93
94
|
if title:
|
|
94
95
|
open_line += " " + str(Attribute("title", title))
|
|
95
96
|
|
|
96
|
-
open_line += "}"
|
|
97
|
+
open_line += "}\n"
|
|
97
98
|
|
|
98
99
|
codeblock.open_line = open_line
|
|
99
100
|
return [r]
|
|
@@ -104,11 +105,12 @@ def include_repl_output(reference_map: ReferenceMap, r: ReferenceId) -> list[Con
|
|
|
104
105
|
"""
|
|
105
106
|
Takes any codeblock that has the `repl` class and append its pre-computed output.
|
|
106
107
|
"""
|
|
107
|
-
codeblock: CodeBlock = reference_map
|
|
108
|
+
codeblock: CodeBlock = reference_map[r]
|
|
108
109
|
if Class("repl") not in codeblock.properties:
|
|
109
110
|
return [r]
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
ref = next(iter(reference_map.select_by_name(r.name)))
|
|
113
|
+
first: CodeBlock = reference_map[ref]
|
|
112
114
|
session_filename = get_attribute(first.properties, "session")
|
|
113
115
|
assert session_filename is not None
|
|
114
116
|
session_path: Path = Path(session_filename)
|
|
@@ -132,6 +134,7 @@ def include_repl_output(reference_map: ReferenceMap, r: ReferenceId) -> list[Con
|
|
|
132
134
|
|
|
133
135
|
|
|
134
136
|
def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files: Files) -> str:
|
|
135
|
-
|
|
137
|
+
context = Context() | read_config(FileCache())
|
|
138
|
+
reference_map, content = read_single_markdown(context, markdown)
|
|
136
139
|
filtered_content = iter_bind(content, partial(compose_filters(add_title, include_repl_output), reference_map))
|
|
137
140
|
return document_to_text(reference_map, filtered_content)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mkdocs-entangled-plugin"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
description = "Plugin for MkDocs helping with rendering Entangled (entangled.github.io) projects."
|
|
5
5
|
authors = [{ name = "Johan Hidding", email = "j.hidding@esciencecenter.nl" }]
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.13,<4"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
license = "Apache-2.0"
|
|
9
9
|
dependencies = [
|
|
10
10
|
"mkdocs>=1.4.2,<2",
|
|
11
|
-
"entangled-cli>=2.
|
|
11
|
+
"entangled-cli>=2.5,<3",
|
|
12
12
|
"mawk>=0.1.7,<0.2",
|
|
13
13
|
]
|
|
14
14
|
|
|
@@ -42,3 +42,6 @@ testpaths = [
|
|
|
42
42
|
|
|
43
43
|
[tool.mypy]
|
|
44
44
|
packages = ["mkdocs_entangled"]
|
|
45
|
+
|
|
46
|
+
[tool.uv.sources]
|
|
47
|
+
entangled-cli = { git = "https://github.com/entangled/entangled.py" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mkdocs_entangled_plugin-0.5.0 → mkdocs_entangled_plugin-0.7.0}/mkdocs_entangled/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|