nbsync 0.1.3__tar.gz → 0.2.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.
- {nbsync-0.1.3 → nbsync-0.2.0}/.github/workflows/docs.yaml +1 -1
- {nbsync-0.1.3 → nbsync-0.2.0}/PKG-INFO +29 -19
- {nbsync-0.1.3 → nbsync-0.2.0}/README.md +25 -14
- nbsync-0.2.0/docs/index.md +1 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/mkdocs.yaml +3 -8
- {nbsync-0.1.3 → nbsync-0.2.0}/pyproject.toml +5 -21
- {nbsync-0.1.3 → nbsync-0.2.0}/src/nbsync/cell.py +1 -2
- nbsync-0.2.0/src/nbsync/logger.py +32 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/src/nbsync/sync.py +23 -10
- nbsync-0.2.0/tests/test_logger.py +64 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/tests/test_sync.py +19 -5
- nbsync-0.1.3/docs/getting-started/configuration.md +0 -35
- nbsync-0.1.3/docs/getting-started/first-steps.md +0 -186
- nbsync-0.1.3/docs/getting-started/installation.md +0 -35
- nbsync-0.1.3/docs/index.md +0 -138
- nbsync-0.1.3/notebooks/analysis.ipynb +0 -69
- nbsync-0.1.3/scripts/plot.py +0 -15
- nbsync-0.1.3/scripts/plotting.py +0 -19
- nbsync-0.1.3/src/nbsync/logger.py +0 -5
- nbsync-0.1.3/src/nbsync/plugin.py +0 -96
- nbsync-0.1.3/tests/__init__.py +0 -0
- nbsync-0.1.3/tests/test_plugin.py +0 -108
- {nbsync-0.1.3 → nbsync-0.2.0}/.devcontainer/devcontainer.json +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.devcontainer/postCreate.sh +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.devcontainer/starship.toml +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.gitattributes +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.github/workflows/ci.yaml +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.github/workflows/publish.yaml +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/.gitignore +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/LICENSE +0 -0
- {nbsync-0.1.3/scripts → nbsync-0.2.0/src/nbsync}/__init__.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/src/nbsync/markdown.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/src/nbsync/notebook.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/src/nbsync/py.typed +0 -0
- {nbsync-0.1.3/src/nbsync → nbsync-0.2.0/tests}/__init__.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/tests/conftest.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/tests/test_cell.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/tests/test_markdown.py +0 -0
- {nbsync-0.1.3 → nbsync-0.2.0}/tests/test_notebook.py +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbsync
|
3
|
-
Version: 0.
|
4
|
-
Summary:
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution
|
5
5
|
Project-URL: Documentation, https://daizutabi.github.io/nbsync/
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/nbsync
|
7
7
|
Project-URL: Issues, https://github.com/daizutabi/nbsync/issues
|
@@ -28,7 +28,7 @@ License: MIT License
|
|
28
28
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
29
|
SOFTWARE.
|
30
30
|
License-File: LICENSE
|
31
|
-
Keywords: documentation,dynamic-execution,jupyter,markdown,
|
31
|
+
Keywords: documentation,dynamic-execution,jupyter,markdown,notebook,python,real-time-sync,visualization
|
32
32
|
Classifier: Development Status :: 4 - Beta
|
33
33
|
Classifier: Programming Language :: Python
|
34
34
|
Classifier: Programming Language :: Python :: 3.10
|
@@ -39,8 +39,7 @@ Classifier: Topic :: Documentation
|
|
39
39
|
Classifier: Topic :: Software Development :: Documentation
|
40
40
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
41
41
|
Requires-Python: >=3.10
|
42
|
-
Requires-Dist:
|
43
|
-
Requires-Dist: nbstore>=0.4.7
|
42
|
+
Requires-Dist: nbstore>=0.4.11
|
44
43
|
Description-Content-Type: text/markdown
|
45
44
|
|
46
45
|
# nbsync
|
@@ -50,11 +49,9 @@ Description-Content-Type: text/markdown
|
|
50
49
|
[![Build Status][GHAction-image]][GHAction-link]
|
51
50
|
[![Coverage Status][codecov-image]][codecov-link]
|
52
51
|
|
53
|
-
<strong>Connect Jupyter notebooks
|
52
|
+
<strong>Connect Jupyter notebooks and Markdown documents</strong>
|
54
53
|
|
55
|
-
nbsync is a
|
56
|
-
visualizations in your documentation, solving the disconnect between
|
57
|
-
code development and documentation.
|
54
|
+
nbsync is a core library that seamlessly bridges Jupyter notebooks and Markdown documents, enabling dynamic content synchronization and execution.
|
58
55
|
|
59
56
|
## Why Use nbsync?
|
60
57
|
|
@@ -68,7 +65,7 @@ Data scientists, researchers, and technical writers face a common dilemma:
|
|
68
65
|
|
69
66
|
### Our Solution
|
70
67
|
|
71
|
-
|
68
|
+
nbsync creates a live bridge between your notebooks and markdown documents by:
|
72
69
|
|
73
70
|
- **Keeping environments separate** - work in the tool best suited for each task
|
74
71
|
- **Maintaining connections** - reference specific figures from notebooks
|
@@ -86,7 +83,7 @@ This plugin creates a live bridge between your notebooks and documentation by:
|
|
86
83
|
|
87
84
|
- **Automatic Updates**:
|
88
85
|
When you modify your notebooks, your documentation updates
|
89
|
-
automatically
|
86
|
+
automatically.
|
90
87
|
|
91
88
|
- **Clean Source Documents**:
|
92
89
|
Your markdown remains readable and focused on content, without
|
@@ -104,14 +101,27 @@ This plugin creates a live bridge between your notebooks and documentation by:
|
|
104
101
|
pip install nbsync
|
105
102
|
```
|
106
103
|
|
107
|
-
### 2.
|
104
|
+
### 2. Basic Usage
|
108
105
|
|
109
|
-
|
106
|
+
```python
|
107
|
+
from nbsync.sync import Synchronizer
|
108
|
+
from nbstore import Store
|
109
|
+
|
110
|
+
# Initialize with a notebook store
|
111
|
+
store = Store("path/to/notebooks")
|
112
|
+
sync = Synchronizer(store)
|
113
|
+
|
114
|
+
# Process markdown with notebook references
|
115
|
+
markdown_text = """
|
116
|
+
# My Document
|
117
|
+
|
118
|
+
{#my-figure}
|
119
|
+
"""
|
110
120
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
121
|
+
# Convert markdown with notebook references to final output
|
122
|
+
for element in sync.convert(markdown_text):
|
123
|
+
# Process each element (string or Cell objects)
|
124
|
+
print(element)
|
115
125
|
```
|
116
126
|
|
117
127
|
### 3. Mark Figures in Your Notebook
|
@@ -140,14 +150,14 @@ Creating documentation and developing visualizations involve different
|
|
140
150
|
workflows and timeframes. When building visualizations in Jupyter notebooks,
|
141
151
|
you need rapid cycles of execution, verification, and modification.
|
142
152
|
|
143
|
-
|
153
|
+
nbsync is designed specifically to address these separation of
|
144
154
|
concerns, allowing you to:
|
145
155
|
|
146
156
|
- **Focus on code** in notebooks without documentation distractions
|
147
157
|
- **Focus on narrative** in markdown without code interruptions
|
148
158
|
- **Maintain powerful connections** between both environments
|
149
159
|
|
150
|
-
Each environment is optimized for its purpose, while
|
160
|
+
Each environment is optimized for its purpose, while nbsync
|
151
161
|
handles the integration automatically.
|
152
162
|
|
153
163
|
## Contributing
|
@@ -5,11 +5,9 @@
|
|
5
5
|
[![Build Status][GHAction-image]][GHAction-link]
|
6
6
|
[![Coverage Status][codecov-image]][codecov-link]
|
7
7
|
|
8
|
-
<strong>Connect Jupyter notebooks
|
8
|
+
<strong>Connect Jupyter notebooks and Markdown documents</strong>
|
9
9
|
|
10
|
-
nbsync is a
|
11
|
-
visualizations in your documentation, solving the disconnect between
|
12
|
-
code development and documentation.
|
10
|
+
nbsync is a core library that seamlessly bridges Jupyter notebooks and Markdown documents, enabling dynamic content synchronization and execution.
|
13
11
|
|
14
12
|
## Why Use nbsync?
|
15
13
|
|
@@ -23,7 +21,7 @@ Data scientists, researchers, and technical writers face a common dilemma:
|
|
23
21
|
|
24
22
|
### Our Solution
|
25
23
|
|
26
|
-
|
24
|
+
nbsync creates a live bridge between your notebooks and markdown documents by:
|
27
25
|
|
28
26
|
- **Keeping environments separate** - work in the tool best suited for each task
|
29
27
|
- **Maintaining connections** - reference specific figures from notebooks
|
@@ -41,7 +39,7 @@ This plugin creates a live bridge between your notebooks and documentation by:
|
|
41
39
|
|
42
40
|
- **Automatic Updates**:
|
43
41
|
When you modify your notebooks, your documentation updates
|
44
|
-
automatically
|
42
|
+
automatically.
|
45
43
|
|
46
44
|
- **Clean Source Documents**:
|
47
45
|
Your markdown remains readable and focused on content, without
|
@@ -59,14 +57,27 @@ This plugin creates a live bridge between your notebooks and documentation by:
|
|
59
57
|
pip install nbsync
|
60
58
|
```
|
61
59
|
|
62
|
-
### 2.
|
60
|
+
### 2. Basic Usage
|
63
61
|
|
64
|
-
|
62
|
+
```python
|
63
|
+
from nbsync.sync import Synchronizer
|
64
|
+
from nbstore import Store
|
65
|
+
|
66
|
+
# Initialize with a notebook store
|
67
|
+
store = Store("path/to/notebooks")
|
68
|
+
sync = Synchronizer(store)
|
69
|
+
|
70
|
+
# Process markdown with notebook references
|
71
|
+
markdown_text = """
|
72
|
+
# My Document
|
73
|
+
|
74
|
+
{#my-figure}
|
75
|
+
"""
|
65
76
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
77
|
+
# Convert markdown with notebook references to final output
|
78
|
+
for element in sync.convert(markdown_text):
|
79
|
+
# Process each element (string or Cell objects)
|
80
|
+
print(element)
|
70
81
|
```
|
71
82
|
|
72
83
|
### 3. Mark Figures in Your Notebook
|
@@ -95,14 +106,14 @@ Creating documentation and developing visualizations involve different
|
|
95
106
|
workflows and timeframes. When building visualizations in Jupyter notebooks,
|
96
107
|
you need rapid cycles of execution, verification, and modification.
|
97
108
|
|
98
|
-
|
109
|
+
nbsync is designed specifically to address these separation of
|
99
110
|
concerns, allowing you to:
|
100
111
|
|
101
112
|
- **Focus on code** in notebooks without documentation distractions
|
102
113
|
- **Focus on narrative** in markdown without code interruptions
|
103
114
|
- **Maintain powerful connections** between both environments
|
104
115
|
|
105
|
-
Each environment is optimized for its purpose, while
|
116
|
+
Each environment is optimized for its purpose, while nbsync
|
106
117
|
handles the integration automatically.
|
107
118
|
|
108
119
|
## Contributing
|
@@ -0,0 +1 @@
|
|
1
|
+
# nbsync
|
@@ -41,10 +41,8 @@ theme:
|
|
41
41
|
- search.suggest
|
42
42
|
plugins:
|
43
43
|
- search
|
44
|
-
-
|
45
|
-
|
46
|
-
- ../notebooks
|
47
|
-
- ../scripts
|
44
|
+
- mkapi:
|
45
|
+
debug: true
|
48
46
|
markdown_extensions:
|
49
47
|
- admonition
|
50
48
|
- pymdownx.emoji:
|
@@ -60,7 +58,4 @@ markdown_extensions:
|
|
60
58
|
alternate_style: true
|
61
59
|
nav:
|
62
60
|
- Home: index.md
|
63
|
-
-
|
64
|
-
- getting-started/installation.md
|
65
|
-
- getting-started/configuration.md
|
66
|
-
- getting-started/first-steps.md
|
61
|
+
- API: $api/nbsync.***
|
@@ -4,15 +4,14 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "nbsync"
|
7
|
-
version = "0.
|
8
|
-
description = "
|
7
|
+
version = "0.2.0"
|
8
|
+
description = "A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution"
|
9
9
|
readme = "README.md"
|
10
10
|
license = { file = "LICENSE" }
|
11
11
|
authors = [{ name = "daizutabi", email = "daizutabi@gmail.com" }]
|
12
12
|
keywords = [
|
13
13
|
"jupyter",
|
14
14
|
"notebook",
|
15
|
-
"mkdocs",
|
16
15
|
"documentation",
|
17
16
|
"markdown",
|
18
17
|
"python",
|
@@ -32,31 +31,23 @@ classifiers = [
|
|
32
31
|
"Topic :: Text Processing :: Markup :: Markdown",
|
33
32
|
]
|
34
33
|
requires-python = ">=3.10"
|
35
|
-
dependencies = ["
|
34
|
+
dependencies = ["nbstore>=0.4.11"]
|
36
35
|
|
37
36
|
[project.urls]
|
38
37
|
Documentation = "https://daizutabi.github.io/nbsync/"
|
39
38
|
Source = "https://github.com/daizutabi/nbsync"
|
40
39
|
Issues = "https://github.com/daizutabi/nbsync/issues"
|
41
40
|
|
42
|
-
[project.entry-points."mkdocs.plugins"]
|
43
|
-
nbsync = "nbsync.plugin:Plugin"
|
44
|
-
|
45
41
|
[dependency-groups]
|
46
42
|
dev = [
|
47
43
|
"ipykernel>=6.29.5",
|
48
44
|
"matplotlib>=3.10.1",
|
49
|
-
"mkdocs-material>=9.6.11",
|
50
45
|
"nbconvert>=7.16.6",
|
51
|
-
"pandas>=2.2",
|
52
|
-
"polars>=1.26",
|
53
|
-
"pytest-clarity>=1.0.1",
|
54
46
|
"pytest-cov>=6.1.0",
|
55
47
|
"pytest-randomly>=3.16.0",
|
56
|
-
"pytest-xdist>=3.6.1",
|
57
48
|
"ruff>=0.11.4",
|
58
|
-
"seaborn>=0.13.2",
|
59
49
|
]
|
50
|
+
docs = ["mkapi", "mkdocs-material"]
|
60
51
|
|
61
52
|
[tool.pytest.ini_options]
|
62
53
|
testpaths = ["src", "tests"]
|
@@ -81,11 +72,4 @@ unfixable = ["F401"]
|
|
81
72
|
ignore = ["ANN401", "ARG001", "ARG002", "C901", "D", "PLR0911", "S105"]
|
82
73
|
|
83
74
|
[tool.ruff.lint.per-file-ignores]
|
84
|
-
"**/tests/*" = ["ANN", "ARG", "D", "FBT", "PLR", "RUF", "S", "
|
85
|
-
"**/{notebooks,scripts}/*" = ["ANN", "ERA001", "NPY", "T201"]
|
86
|
-
|
87
|
-
[tool.pyright]
|
88
|
-
include = ["src", "tests"]
|
89
|
-
strictDictionaryInference = true
|
90
|
-
strictListInference = true
|
91
|
-
strictSetInference = true
|
75
|
+
"**/tests/*" = ["ANN", "ARG", "D", "FBT", "PGH003", "PLR", "RUF", "S", "SLF"]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import logging
|
4
|
+
from logging import Logger
|
5
|
+
from typing import Any
|
6
|
+
|
7
|
+
_logger = logging.getLogger("nbsync")
|
8
|
+
|
9
|
+
|
10
|
+
def configure(logger: Logger | None = None) -> Logger:
|
11
|
+
global _logger # noqa: PLW0603
|
12
|
+
|
13
|
+
if logger:
|
14
|
+
_logger = logger
|
15
|
+
|
16
|
+
return _logger
|
17
|
+
|
18
|
+
|
19
|
+
def debug(msg: str, *args: Any, **kwargs: Any) -> None:
|
20
|
+
_logger.debug(msg, *args, **kwargs)
|
21
|
+
|
22
|
+
|
23
|
+
def info(msg: str, *args: Any, **kwargs: Any) -> None:
|
24
|
+
_logger.info(msg, *args, **kwargs)
|
25
|
+
|
26
|
+
|
27
|
+
def warning(msg: str, *args: Any, **kwargs: Any) -> None:
|
28
|
+
_logger.warning(msg, *args, **kwargs)
|
29
|
+
|
30
|
+
|
31
|
+
def error(msg: str, *args: Any, **kwargs: Any) -> None:
|
32
|
+
_logger.error(msg, *args, **kwargs)
|
@@ -10,12 +10,11 @@ from nbstore.markdown import CodeBlock, Image
|
|
10
10
|
from nbstore.notebook import get_language, get_mime_content, get_source
|
11
11
|
|
12
12
|
import nbsync.markdown
|
13
|
+
from nbsync import logger
|
13
14
|
from nbsync.cell import Cell
|
14
15
|
from nbsync.markdown import is_truelike
|
15
16
|
from nbsync.notebook import Notebook
|
16
17
|
|
17
|
-
from .logger import logger
|
18
|
-
|
19
18
|
if TYPE_CHECKING:
|
20
19
|
from collections.abc import Iterator
|
21
20
|
|
@@ -35,7 +34,7 @@ class Synchronizer:
|
|
35
34
|
yield elem
|
36
35
|
|
37
36
|
if isinstance(elem, Image | CodeBlock):
|
38
|
-
update_notebooks(
|
37
|
+
update_notebooks(elem, notebooks, self.store)
|
39
38
|
|
40
39
|
for url, notebook in notebooks.items():
|
41
40
|
if url not in self.notebooks or not self.notebooks[url].equals(notebook):
|
@@ -58,17 +57,13 @@ class Synchronizer:
|
|
58
57
|
if isinstance(elem, str):
|
59
58
|
yield elem
|
60
59
|
|
61
|
-
elif
|
62
|
-
|
63
|
-
nb = self.notebooks[elem.url].nb
|
64
|
-
yield convert_image(elem, nb)
|
65
|
-
elif code_block := convert_code_block(elem):
|
66
|
-
yield code_block
|
60
|
+
elif cell := convert(elem, self.notebooks):
|
61
|
+
yield cell
|
67
62
|
|
68
63
|
|
69
64
|
def update_notebooks(
|
70
|
-
notebooks: dict[str, Notebook],
|
71
65
|
elem: Image | CodeBlock,
|
66
|
+
notebooks: dict[str, Notebook],
|
72
67
|
store: Store,
|
73
68
|
) -> None:
|
74
69
|
url = elem.url
|
@@ -93,6 +88,24 @@ def update_notebooks(
|
|
93
88
|
notebook.add_cell(elem.identifier, source)
|
94
89
|
|
95
90
|
|
91
|
+
def convert(
|
92
|
+
elem: Image | CodeBlock,
|
93
|
+
notebooks: dict[str, Notebook],
|
94
|
+
) -> str | Cell:
|
95
|
+
if elem.identifier not in [".", "_"]:
|
96
|
+
if isinstance(elem, Image):
|
97
|
+
if elem.url not in notebooks:
|
98
|
+
logger.warning(f"Notebook not found: {elem.url}")
|
99
|
+
return ""
|
100
|
+
|
101
|
+
nb = notebooks[elem.url].nb
|
102
|
+
return convert_image(elem, nb)
|
103
|
+
|
104
|
+
return convert_code_block(elem)
|
105
|
+
|
106
|
+
return ""
|
107
|
+
|
108
|
+
|
96
109
|
def convert_image(image: Image, nb: NotebookNode) -> Cell:
|
97
110
|
try:
|
98
111
|
image.source = get_source(nb, image.identifier)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import logging
|
2
|
+
from logging import Logger
|
3
|
+
|
4
|
+
import pytest
|
5
|
+
|
6
|
+
from nbsync import logger
|
7
|
+
|
8
|
+
|
9
|
+
@pytest.fixture
|
10
|
+
def reset_logger():
|
11
|
+
original_logger = logger._logger
|
12
|
+
|
13
|
+
yield
|
14
|
+
|
15
|
+
logger._logger = original_logger
|
16
|
+
|
17
|
+
|
18
|
+
def test_default_logger():
|
19
|
+
assert isinstance(logger._logger, Logger)
|
20
|
+
assert logger._logger.name == "nbsync"
|
21
|
+
|
22
|
+
|
23
|
+
def test_configure(reset_logger):
|
24
|
+
custom_logger = logging.getLogger("custom_logger")
|
25
|
+
|
26
|
+
result = logger.configure(custom_logger)
|
27
|
+
|
28
|
+
assert result is custom_logger
|
29
|
+
assert logger._logger is custom_logger
|
30
|
+
assert logger._logger.name == "custom_logger"
|
31
|
+
|
32
|
+
|
33
|
+
def test_configure_no_args(reset_logger):
|
34
|
+
custom_logger = logging.getLogger("custom_logger")
|
35
|
+
logger._logger = custom_logger
|
36
|
+
|
37
|
+
result = logger.configure()
|
38
|
+
|
39
|
+
assert result is custom_logger
|
40
|
+
assert logger._logger is custom_logger
|
41
|
+
|
42
|
+
|
43
|
+
def test_logging_methods(reset_logger, caplog):
|
44
|
+
caplog.set_level(logging.DEBUG, logger="nbsync")
|
45
|
+
|
46
|
+
debug_msg = "Debug message"
|
47
|
+
info_msg = "Info message"
|
48
|
+
warning_msg = "Warning message"
|
49
|
+
error_msg = "Error message"
|
50
|
+
|
51
|
+
logger.debug(debug_msg)
|
52
|
+
logger.info(info_msg)
|
53
|
+
logger.warning(warning_msg)
|
54
|
+
logger.error(error_msg)
|
55
|
+
|
56
|
+
assert debug_msg in caplog.text
|
57
|
+
assert info_msg in caplog.text
|
58
|
+
assert warning_msg in caplog.text
|
59
|
+
assert error_msg in caplog.text
|
60
|
+
|
61
|
+
assert (logger._logger.name, logging.DEBUG, debug_msg) in caplog.record_tuples
|
62
|
+
assert (logger._logger.name, logging.INFO, info_msg) in caplog.record_tuples
|
63
|
+
assert (logger._logger.name, logging.WARNING, warning_msg) in caplog.record_tuples
|
64
|
+
assert (logger._logger.name, logging.ERROR, error_msg) in caplog.record_tuples
|
@@ -57,7 +57,7 @@ def test_update_notebooks(store: Store):
|
|
57
57
|
from nbsync.sync import Notebook, update_notebooks
|
58
58
|
|
59
59
|
notebooks: dict[str, Notebook] = {}
|
60
|
-
update_notebooks(
|
60
|
+
update_notebooks(Image("abc", "id", [], {}, "", "a.ipynb"), notebooks, store)
|
61
61
|
assert len(notebooks) == 1
|
62
62
|
nb = notebooks["a.ipynb"].nb
|
63
63
|
assert nbstore.notebook.get_source(nb, "id") == "print(1+1)"
|
@@ -68,7 +68,7 @@ def test_update_notebooks_exec(store: Store):
|
|
68
68
|
|
69
69
|
notebooks: dict[str, Notebook] = {}
|
70
70
|
image = Image("abc", "id", [], {"exec": "1"}, "", "a.ipynb")
|
71
|
-
update_notebooks(
|
71
|
+
update_notebooks(image, notebooks, store)
|
72
72
|
assert len(notebooks) == 1
|
73
73
|
assert notebooks["a.ipynb"].execution_needed
|
74
74
|
|
@@ -78,7 +78,7 @@ def test_update_notebooks_add_cell(store: Store):
|
|
78
78
|
|
79
79
|
notebooks: dict[str, Notebook] = {}
|
80
80
|
code_block = CodeBlock("abc", "id2", [], {}, "123", "a.ipynb")
|
81
|
-
update_notebooks(
|
81
|
+
update_notebooks(code_block, notebooks, store)
|
82
82
|
assert len(notebooks) == 1
|
83
83
|
notebook = notebooks["a.ipynb"]
|
84
84
|
assert notebook.execution_needed
|
@@ -91,7 +91,7 @@ def test_update_notebooks_self(store: Store):
|
|
91
91
|
|
92
92
|
notebooks: dict[str, Notebook] = {}
|
93
93
|
code_block = CodeBlock("abc", "id2", [], {}, "123", ".md")
|
94
|
-
update_notebooks(
|
94
|
+
update_notebooks(code_block, notebooks, store)
|
95
95
|
assert len(notebooks) == 1
|
96
96
|
notebook = notebooks[".md"]
|
97
97
|
assert len(notebook.nb.cells) == 1
|
@@ -102,7 +102,7 @@ def test_update_notebooks_error(store: Store):
|
|
102
102
|
|
103
103
|
notebooks: dict[str, Notebook] = {}
|
104
104
|
code_block = CodeBlock("abc", "id2", [], {}, "123", "invalid.md")
|
105
|
-
update_notebooks(
|
105
|
+
update_notebooks(code_block, notebooks, store)
|
106
106
|
assert len(notebooks) == 0
|
107
107
|
|
108
108
|
|
@@ -160,3 +160,17 @@ def test_sync_code_block(sync: Synchronizer):
|
|
160
160
|
x = next(sync.convert("```a b.md#c source=1\nc\n```"))
|
161
161
|
assert isinstance(x, str)
|
162
162
|
assert x == "```a \nc\n```"
|
163
|
+
|
164
|
+
|
165
|
+
def test_sync_notebook_not_found():
|
166
|
+
from nbsync.sync import convert
|
167
|
+
|
168
|
+
image = Image("abc", "id", [], {}, "", "a.ipynb")
|
169
|
+
assert convert(image, {}) == ""
|
170
|
+
|
171
|
+
|
172
|
+
def test_convert_no_id():
|
173
|
+
from nbsync.sync import convert
|
174
|
+
|
175
|
+
image = Image("abc", ".", [], {}, "", "a.ipynb")
|
176
|
+
assert convert(image, {}) == ""
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Configuration
|
2
|
-
|
3
|
-
Configuring nbsync for your MkDocs site is simple but powerful, allowing you to
|
4
|
-
customize how notebooks and Python files are integrated with your documentation.
|
5
|
-
|
6
|
-
## Basic Configuration
|
7
|
-
|
8
|
-
To use nbsync with MkDocs, add it to your `mkdocs.yml` file:
|
9
|
-
|
10
|
-
```yaml
|
11
|
-
plugins:
|
12
|
-
- search
|
13
|
-
- nbsync
|
14
|
-
```
|
15
|
-
|
16
|
-
This minimal configuration uses all the default settings.
|
17
|
-
|
18
|
-
## Source Directory Configuration
|
19
|
-
|
20
|
-
Specify where nbsync should look for notebooks and Python files:
|
21
|
-
|
22
|
-
```yaml
|
23
|
-
plugins:
|
24
|
-
- search
|
25
|
-
- nbsync:
|
26
|
-
src_dir:
|
27
|
-
- ../notebooks # Path to notebooks directory
|
28
|
-
- ../scripts # Path to Python scripts
|
29
|
-
```
|
30
|
-
|
31
|
-
The `src_dir` option can be:
|
32
|
-
|
33
|
-
- A single path as a string
|
34
|
-
- A list of paths
|
35
|
-
- Relative to your docs directory
|