|
1 | 1 | from typing import Optional
|
2 | 2 | from dataclasses import dataclass
|
3 |
| -from pathlib import Path |
4 | 3 | import re
|
5 |
| -import tempfile |
6 |
| -import subprocess |
7 |
| -import sys |
8 | 4 |
|
9 | 5 | from mkdocs.config.defaults import MkDocsConfig
|
10 | 6 | from mkdocs.structure.pages import Page
|
11 | 7 | from mkdocs.structure.files import Files
|
12 | 8 |
|
13 |
| -from .config import EntangledConfig |
14 |
| -from .properties import read_properties, Id, Attribute, Class |
| 9 | +from .properties import read_properties, Id, Attribute |
15 | 10 | from . import mawk
|
16 | 11 |
|
17 | 12 |
|
18 | 13 | @dataclass
|
19 | 14 | class EntangledFilter(mawk.RuleSet):
|
20 | 15 | add_title: bool = True
|
21 |
| - build_artifacts: bool = True |
22 |
| - |
23 |
| - _collect_make_script: bool = False |
24 | 16 | _ignore: bool = False
|
25 | 17 |
|
26 | 18 | @mawk.on_match(r"~~~markdown")
|
@@ -58,31 +50,11 @@ def open_code_block(self, m: re.Match) -> Optional[list[str]]:
|
58 | 50 | if title is not None:
|
59 | 51 | props.append(Attribute("title", title))
|
60 | 52 |
|
61 |
| - if self.build_artifacts and Class("build-artifact") in props: |
62 |
| - self._collect_make_script = True |
63 |
| - self._make_script: list[str] = [] |
64 |
| - self._make_props = props |
65 |
| - self._indent = indent |
66 |
| - |
67 | 53 | prop_str = " ".join(str(p) for p in props)
|
68 | 54 | return [f"{indent}``` {{{prop_str}}}"]
|
69 | 55 |
|
70 | 56 | @mawk.on_match(r"\s*```\s*$")
|
71 | 57 | def close_code_block(self, m: re.Match) -> Optional[list[str]]:
|
72 |
| - if not self._ignore and self._collect_make_script: |
73 |
| - self._collect_make_script = False |
74 |
| - script = "\n".join(self._make_script) |
75 |
| - with tempfile.TemporaryDirectory() as _tmpdir: |
76 |
| - tmpdir = Path(_tmpdir) |
77 |
| - with open(tmpdir / "Makefile", "w") as makefile: |
78 |
| - makefile.write(script) |
79 |
| - subprocess.run(["make", "-f", str(tmpdir / "Makefile")]) |
80 |
| - return None |
81 |
| - |
82 |
| - @mawk.always |
83 |
| - def add_line_to_script(self, line: str) -> Optional[list[str]]: |
84 |
| - if not self._ignore and self._collect_make_script: |
85 |
| - self._make_script.append(line.removeprefix(self._indent)) |
86 | 58 | return None
|
87 | 59 |
|
88 | 60 |
|
|
0 commit comments