nbsync 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
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.
- nbsync/markdown.py +43 -18
- nbsync/sync.py +2 -2
- {nbsync-0.1.1.dist-info → nbsync-0.1.3.dist-info}/METADATA +1 -9
- {nbsync-0.1.1.dist-info → nbsync-0.1.3.dist-info}/RECORD +7 -7
- {nbsync-0.1.1.dist-info → nbsync-0.1.3.dist-info}/WHEEL +0 -0
- {nbsync-0.1.1.dist-info → nbsync-0.1.3.dist-info}/entry_points.txt +0 -0
- {nbsync-0.1.1.dist-info → nbsync-0.1.3.dist-info}/licenses/LICENSE +0 -0
nbsync/markdown.py
CHANGED
@@ -12,6 +12,49 @@ if TYPE_CHECKING:
|
|
12
12
|
Element: TypeAlias = str | CodeBlock | Image
|
13
13
|
|
14
14
|
|
15
|
+
def convert_code_block(code_block: CodeBlock) -> Iterator[Element]:
|
16
|
+
for elem in _convert_code_block_tabbed(code_block):
|
17
|
+
if isinstance(elem, CodeBlock):
|
18
|
+
yield _convert_code_block_exec(elem)
|
19
|
+
else:
|
20
|
+
yield elem
|
21
|
+
|
22
|
+
|
23
|
+
def _convert_code_block_tabbed(code_block: CodeBlock) -> Iterator[Element]:
|
24
|
+
source = code_block.attributes.get("source", None)
|
25
|
+
if source != "tabbed-nbsync":
|
26
|
+
yield code_block
|
27
|
+
return
|
28
|
+
|
29
|
+
markdown = code_block.text.replace('source="tabbed-nbsync"', "")
|
30
|
+
markdown = textwrap.indent(markdown, " ")
|
31
|
+
yield f'===! "Markdown"\n\n{markdown}\n\n'
|
32
|
+
|
33
|
+
text = textwrap.indent(code_block.source, " ")
|
34
|
+
text = f'=== "Rendered"\n\n{text}'
|
35
|
+
yield from nbstore.markdown.parse(text)
|
36
|
+
|
37
|
+
|
38
|
+
def _convert_code_block_exec(code_block: CodeBlock) -> CodeBlock | Image:
|
39
|
+
exec_ = code_block.attributes.get("exec", None)
|
40
|
+
if exec_ != "1" or not code_block.classes:
|
41
|
+
return code_block
|
42
|
+
|
43
|
+
if code_block.classes[0] != "python":
|
44
|
+
return code_block
|
45
|
+
|
46
|
+
del code_block.attributes["exec"]
|
47
|
+
return Image(
|
48
|
+
code_block.indent,
|
49
|
+
"",
|
50
|
+
code_block.classes[1:],
|
51
|
+
code_block.attributes,
|
52
|
+
code_block.source,
|
53
|
+
url=".md",
|
54
|
+
indent=code_block.indent,
|
55
|
+
)
|
56
|
+
|
57
|
+
|
15
58
|
def convert_image(image: Image, index: int | None = None) -> Iterator[Element]:
|
16
59
|
if image.source:
|
17
60
|
if not image.identifier and index is None:
|
@@ -29,24 +72,6 @@ def convert_image(image: Image, index: int | None = None) -> Iterator[Element]:
|
|
29
72
|
yield image.text
|
30
73
|
|
31
74
|
|
32
|
-
def convert_code_block(code_block: CodeBlock) -> Iterator[Element]:
|
33
|
-
source = code_block.attributes.get("source", None)
|
34
|
-
if source == "tabbed-nbsync":
|
35
|
-
yield from _convert_code_block_tabbed(code_block)
|
36
|
-
else:
|
37
|
-
yield code_block
|
38
|
-
|
39
|
-
|
40
|
-
def _convert_code_block_tabbed(code_block: CodeBlock) -> Iterator[Element]:
|
41
|
-
markdown = code_block.text.replace('source="tabbed-nbsync"', "")
|
42
|
-
markdown = textwrap.indent(markdown, " ")
|
43
|
-
yield f'===! "Markdown"\n\n{markdown}\n\n'
|
44
|
-
|
45
|
-
text = textwrap.indent(code_block.source, " ")
|
46
|
-
text = f'=== "Rendered"\n\n{text}'
|
47
|
-
yield from nbstore.markdown.parse(text)
|
48
|
-
|
49
|
-
|
50
75
|
SUPPORTED_EXTENSIONS = (".ipynb", ".md", ".py")
|
51
76
|
|
52
77
|
|
nbsync/sync.py
CHANGED
@@ -62,8 +62,8 @@ class Synchronizer:
|
|
62
62
|
if isinstance(elem, Image):
|
63
63
|
nb = self.notebooks[elem.url].nb
|
64
64
|
yield convert_image(elem, nb)
|
65
|
-
|
66
|
-
yield
|
65
|
+
elif code_block := convert_code_block(elem):
|
66
|
+
yield code_block
|
67
67
|
|
68
68
|
|
69
69
|
def update_notebooks(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbsync
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.3
|
4
4
|
Summary: MkDocs plugin treating Jupyter notebooks, Python scripts and Markdown files as first-class citizens for documentation with dynamic execution and real-time synchronization
|
5
5
|
Project-URL: Documentation, https://daizutabi.github.io/nbsync/
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/nbsync
|
@@ -134,14 +134,6 @@ Use standard Markdown image syntax with the figure identifier:
|
|
134
134
|
{#my-figure}
|
135
135
|
```
|
136
136
|
|
137
|
-
## Advanced Usage
|
138
|
-
|
139
|
-
For more detailed information on how to use nbsync, see:
|
140
|
-
|
141
|
-
- [Notebook Configuration](usage/notebook.md) - Setting up notebook directories
|
142
|
-
- [Class Options](usage/class.md) - Control how notebook content is displayed
|
143
|
-
<!-- - [Workflow Tips](usage/workflow.md) - Best practices for documentation -->
|
144
|
-
|
145
137
|
## The Power of Separation
|
146
138
|
|
147
139
|
Creating documentation and developing visualizations involve different
|
@@ -1,13 +1,13 @@
|
|
1
1
|
nbsync/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
nbsync/cell.py,sha256=HNgMDwA1KrMxyoxAL2wUrg3zdA1glveoXY5YbO_uFeM,3788
|
3
3
|
nbsync/logger.py,sha256=tQK8Z8HdWQNhVohQYLwZtJhdaj2w0UTyhHQak3mPqNc,119
|
4
|
-
nbsync/markdown.py,sha256=
|
4
|
+
nbsync/markdown.py,sha256=xcPhQKWpFDyVQ_xtZCpFrnR0QED_hYs4PAyaT7dF3t4,3830
|
5
5
|
nbsync/notebook.py,sha256=Voh-e8RQsoYmWKnaHzAn4bm6Ud5v-aHwmng2Uc0rUts,1009
|
6
6
|
nbsync/plugin.py,sha256=YywBAD7fcrPg3-_9T_kSuvD8RBzsc_ovlIviGlKR9po,2835
|
7
7
|
nbsync/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
nbsync/sync.py,sha256=
|
9
|
-
nbsync-0.1.
|
10
|
-
nbsync-0.1.
|
11
|
-
nbsync-0.1.
|
12
|
-
nbsync-0.1.
|
13
|
-
nbsync-0.1.
|
8
|
+
nbsync/sync.py,sha256=_VIcb6m-_-hKxHFulfpijzvvMsGOymv7jOj2H9VqbhQ,3600
|
9
|
+
nbsync-0.1.3.dist-info/METADATA,sha256=7KS2vSTRBIpukQ_3ZjaBoEwLiP58PYHUkluVrpp8Ro0,6287
|
10
|
+
nbsync-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
nbsync-0.1.3.dist-info/entry_points.txt,sha256=bSqmJTDmrUoSm4yDjk8YDWxI71SShx16judadGdiKbA,47
|
12
|
+
nbsync-0.1.3.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
|
13
|
+
nbsync-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|