nbdev 2.3.34__tar.gz → 3.0.6__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.
- {nbdev-2.3.34 → nbdev-3.0.6}/CONTRIBUTING.md +11 -1
- {nbdev-2.3.34/nbdev.egg-info → nbdev-3.0.6}/PKG-INFO +45 -29
- {nbdev-2.3.34 → nbdev-3.0.6}/README.md +28 -11
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/__init__.py +1 -1
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/_modidx.py +37 -46
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/clean.py +25 -23
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/cli.py +41 -34
- nbdev-3.0.6/nbdev/config.py +368 -0
- nbdev-3.0.6/nbdev/diff.py +92 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/doclinks.py +51 -44
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/export.py +13 -14
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/frontmatter.py +4 -4
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/maker.py +27 -27
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/merge.py +10 -10
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/migrate.py +114 -20
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/process.py +16 -16
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/processors.py +26 -26
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/qmd.py +9 -9
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/quarto.py +66 -31
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/release.py +69 -68
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/serve.py +8 -7
- nbdev-3.0.6/nbdev/showdoc.py +67 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/sync.py +14 -11
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/test.py +7 -7
- {nbdev-2.3.34 → nbdev-3.0.6/nbdev.egg-info}/PKG-INFO +45 -29
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev.egg-info/SOURCES.txt +1 -3
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev.egg-info/entry_points.txt +2 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev.egg-info/requires.txt +9 -4
- nbdev-3.0.6/pyproject.toml +82 -0
- nbdev-2.3.34/nbdev/config.py +0 -279
- nbdev-2.3.34/nbdev/showdoc.py +0 -255
- nbdev-2.3.34/nbdev.egg-info/not-zip-safe +0 -1
- nbdev-2.3.34/pyproject.toml +0 -3
- nbdev-2.3.34/settings.ini +0 -74
- nbdev-2.3.34/setup.py +0 -64
- {nbdev-2.3.34 → nbdev-3.0.6}/LICENSE +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/MANIFEST.in +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/extract_attachments.py +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/imports.py +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev/serve_drv.py +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-2.3.34 → nbdev-3.0.6}/setup.cfg +0 -0
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## How to get started
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install nbdev in editable mode with development dependencies:
|
|
6
|
+
```sh
|
|
7
|
+
pip install -e '.[dev]'
|
|
6
8
|
```
|
|
9
|
+
|
|
10
|
+
Before anything else, please install the git hooks that run automatic scripts during each commit and merge to strip the notebooks of superfluous metadata (and avoid merge conflicts). After cloning the repository, run the following command inside it:
|
|
11
|
+
```sh
|
|
7
12
|
nbdev_install_hooks
|
|
8
13
|
```
|
|
9
14
|
|
|
15
|
+
Run the test suite to ensure everything is working:
|
|
16
|
+
```sh
|
|
17
|
+
nbdev_test
|
|
18
|
+
```
|
|
19
|
+
|
|
10
20
|
## Did you find a bug?
|
|
11
21
|
|
|
12
22
|
* Ensure the bug was not already reported by searching on GitHub under Issues.
|
|
@@ -1,35 +1,32 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.6
|
|
4
4
|
Summary: Create delightful software with Jupyter Notebooks
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
License: Apache Software License 2.0
|
|
5
|
+
Author-email: "Jeremy Howard and the fast.ai community" <j@fast.ai>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/AnswerDotAI/nbdev
|
|
9
8
|
Project-URL: Documentation, https://nbdev.fast.ai/
|
|
10
|
-
Keywords: nbdev
|
|
9
|
+
Keywords: nbdev,fastai,jupyter,notebook,export
|
|
11
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
12
11
|
Classifier: Intended Audience :: Developers
|
|
13
12
|
Classifier: Natural Language :: English
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
15
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
21
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.9
|
|
22
17
|
Description-Content-Type: text/markdown
|
|
23
18
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist: execnb>=0.1.4
|
|
19
|
+
Requires-Dist: fastcore>=1.12.3
|
|
20
|
+
Requires-Dist: execnb>=0.1.12
|
|
27
21
|
Requires-Dist: astunparse
|
|
28
22
|
Requires-Dist: ghapi>=1.0.3
|
|
29
23
|
Requires-Dist: watchdog
|
|
30
24
|
Requires-Dist: asttokens
|
|
31
25
|
Requires-Dist: setuptools
|
|
32
|
-
Requires-Dist:
|
|
26
|
+
Requires-Dist: build
|
|
27
|
+
Requires-Dist: fastgit
|
|
28
|
+
Requires-Dist: pyyaml
|
|
29
|
+
Requires-Dist: tomli; python_version < "3.11"
|
|
33
30
|
Provides-Extra: dev
|
|
34
31
|
Requires-Dist: ipywidgets; extra == "dev"
|
|
35
32
|
Requires-Dist: nbdev-numpy; extra == "dev"
|
|
@@ -42,6 +39,8 @@ Requires-Dist: nbclassic; extra == "dev"
|
|
|
42
39
|
Requires-Dist: pysymbol_llm; extra == "dev"
|
|
43
40
|
Requires-Dist: llms-txt; extra == "dev"
|
|
44
41
|
Requires-Dist: sphinx; extra == "dev"
|
|
42
|
+
Requires-Dist: plum-dispatch; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
45
44
|
|
|
46
45
|
# Getting Started
|
|
47
46
|
|
|
@@ -50,6 +49,22 @@ Requires-Dist: sphinx; extra == "dev"
|
|
|
50
49
|
|
|
51
50
|

|
|
52
51
|
|
|
52
|
+
## 🛑**Jan 2026 Major Version Update – Breaking Change**🛑
|
|
53
|
+
|
|
54
|
+
**nbdev3 is here!** As many of you have been requesting, configuration
|
|
55
|
+
has moved from `settings.ini` to `pyproject.toml`, following modern
|
|
56
|
+
Python packaging standards ([PEP
|
|
57
|
+
621](https://peps.python.org/pep-0621/)). Your project metadata now
|
|
58
|
+
lives in the standard `[project]` section, while nbdev-specific settings
|
|
59
|
+
go in `[tool.nbdev]`.
|
|
60
|
+
|
|
61
|
+
**Migrating from nbdev2:** Run
|
|
62
|
+
[`nbdev_migrate_config`](https://nbdev.fast.ai/api/migrate.html#nbdev_migrate_config)
|
|
63
|
+
in your project root to automatically convert your `settings.ini` to
|
|
64
|
+
`pyproject.toml` and update your GitHub Actions workflows to use
|
|
65
|
+
nbdev3-compatible versions. Your existing notebooks and code don’t need
|
|
66
|
+
any changes.
|
|
67
|
+
|
|
53
68
|
`nbdev` is a notebook-driven development platform. Simply write
|
|
54
69
|
notebooks with lightweight markup and get high-quality documentation,
|
|
55
70
|
tests, continuous integration, and packaging for free!
|
|
@@ -69,7 +84,10 @@ practices because tests and documentation are first class.
|
|
|
69
84
|
package releases. Python best practices are automatically followed,
|
|
70
85
|
for example, only exported objects are included in `__all__`
|
|
71
86
|
- **Two-way sync between notebooks and plaintext source code** allowing
|
|
72
|
-
you to use your IDE for code navigation or quick edits
|
|
87
|
+
you to use your IDE for code navigation or quick edits. Sync is
|
|
88
|
+
robust: each exported cell is tagged with its unique notebook cell ID,
|
|
89
|
+
so [`nbdev_update`](https://nbdev.fast.ai/api/sync.html#nbdev_update)
|
|
90
|
+
always updates the correct cell
|
|
73
91
|
- **Tests** written as ordinary notebook cells are run in parallel with
|
|
74
92
|
a single command
|
|
75
93
|
- **Continuous integration** out-of-the-box with [GitHub
|
|
@@ -92,12 +110,6 @@ You can install nbdev with pip:
|
|
|
92
110
|
pip install nbdev
|
|
93
111
|
```
|
|
94
112
|
|
|
95
|
-
… or with conda (or mamba):
|
|
96
|
-
|
|
97
|
-
``` sh
|
|
98
|
-
conda install -c fastai nbdev
|
|
99
|
-
```
|
|
100
|
-
|
|
101
113
|
Note that `nbdev` must be installed into the same Python environment
|
|
102
114
|
that you use for both Jupyter and your project.
|
|
103
115
|
|
|
@@ -124,11 +136,13 @@ available commands:
|
|
|
124
136
|
!nbdev_help
|
|
125
137
|
```
|
|
126
138
|
|
|
127
|
-
|
|
139
|
+
nb_export Export a single nbdev notebook to a python script.
|
|
140
|
+
nbdev_bump_version Increment version in __init__.py by one
|
|
128
141
|
nbdev_changelog Create a CHANGELOG.md file from closed and labeled GitHub issues
|
|
129
142
|
nbdev_clean Clean all notebooks in `fname` to avoid merge conflicts
|
|
130
143
|
nbdev_conda Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it
|
|
131
|
-
|
|
144
|
+
nbdev_contributing Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present). Skips if the file doesn't exist.
|
|
145
|
+
nbdev_create_config Create a pyproject.toml config file.
|
|
132
146
|
nbdev_docs Create Quarto docs and README.md
|
|
133
147
|
nbdev_export Export notebooks in `path` to Python modules
|
|
134
148
|
nbdev_filter A notebook filter for Quarto
|
|
@@ -139,6 +153,7 @@ available commands:
|
|
|
139
153
|
nbdev_install_quarto Install latest Quarto on macOS or Linux, prints instructions for Windows
|
|
140
154
|
nbdev_merge Git merge driver for notebooks
|
|
141
155
|
nbdev_migrate Convert all markdown and notebook files in `path` from v1 to v2
|
|
156
|
+
nbdev_migrate_config Migrate settings.ini to pyproject.toml
|
|
142
157
|
nbdev_new Create an nbdev project.
|
|
143
158
|
nbdev_prepare Export, test, and clean notebooks, and render README if needed
|
|
144
159
|
nbdev_preview Preview docs locally
|
|
@@ -148,12 +163,13 @@ available commands:
|
|
|
148
163
|
nbdev_release_both Release both conda and PyPI packages
|
|
149
164
|
nbdev_release_gh Calls `nbdev_changelog`, lets you edit the result, then pushes to git and calls `nbdev_release_git`
|
|
150
165
|
nbdev_release_git Tag and create a release in GitHub for the current version
|
|
151
|
-
nbdev_requirements Writes a `requirements.txt` file to `directory` based on
|
|
166
|
+
nbdev_requirements Writes a `requirements.txt` file to `directory` based on pyproject.toml.
|
|
152
167
|
nbdev_sidebar Create sidebar.yml
|
|
153
168
|
nbdev_test Test in parallel notebooks matching `path`, passing along `flags`
|
|
154
|
-
nbdev_trust Trust notebooks matching `fname
|
|
169
|
+
nbdev_trust Trust notebooks matching `fname`.
|
|
155
170
|
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
156
171
|
nbdev_update_license Allows you to update the license of your project.
|
|
172
|
+
watch_export Use `nb_export` on ipynb files in `nbs` directory on changes using nbdev config if available
|
|
157
173
|
|
|
158
174
|
## FAQ
|
|
159
175
|
|
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|

|
|
7
7
|
|
|
8
|
+
## 🛑**Jan 2026 Major Version Update – Breaking Change**🛑
|
|
9
|
+
|
|
10
|
+
**nbdev3 is here!** As many of you have been requesting, configuration
|
|
11
|
+
has moved from `settings.ini` to `pyproject.toml`, following modern
|
|
12
|
+
Python packaging standards ([PEP
|
|
13
|
+
621](https://peps.python.org/pep-0621/)). Your project metadata now
|
|
14
|
+
lives in the standard `[project]` section, while nbdev-specific settings
|
|
15
|
+
go in `[tool.nbdev]`.
|
|
16
|
+
|
|
17
|
+
**Migrating from nbdev2:** Run
|
|
18
|
+
[`nbdev_migrate_config`](https://nbdev.fast.ai/api/migrate.html#nbdev_migrate_config)
|
|
19
|
+
in your project root to automatically convert your `settings.ini` to
|
|
20
|
+
`pyproject.toml` and update your GitHub Actions workflows to use
|
|
21
|
+
nbdev3-compatible versions. Your existing notebooks and code don’t need
|
|
22
|
+
any changes.
|
|
23
|
+
|
|
8
24
|
`nbdev` is a notebook-driven development platform. Simply write
|
|
9
25
|
notebooks with lightweight markup and get high-quality documentation,
|
|
10
26
|
tests, continuous integration, and packaging for free!
|
|
@@ -24,7 +40,10 @@ practices because tests and documentation are first class.
|
|
|
24
40
|
package releases. Python best practices are automatically followed,
|
|
25
41
|
for example, only exported objects are included in `__all__`
|
|
26
42
|
- **Two-way sync between notebooks and plaintext source code** allowing
|
|
27
|
-
you to use your IDE for code navigation or quick edits
|
|
43
|
+
you to use your IDE for code navigation or quick edits. Sync is
|
|
44
|
+
robust: each exported cell is tagged with its unique notebook cell ID,
|
|
45
|
+
so [`nbdev_update`](https://nbdev.fast.ai/api/sync.html#nbdev_update)
|
|
46
|
+
always updates the correct cell
|
|
28
47
|
- **Tests** written as ordinary notebook cells are run in parallel with
|
|
29
48
|
a single command
|
|
30
49
|
- **Continuous integration** out-of-the-box with [GitHub
|
|
@@ -47,12 +66,6 @@ You can install nbdev with pip:
|
|
|
47
66
|
pip install nbdev
|
|
48
67
|
```
|
|
49
68
|
|
|
50
|
-
… or with conda (or mamba):
|
|
51
|
-
|
|
52
|
-
``` sh
|
|
53
|
-
conda install -c fastai nbdev
|
|
54
|
-
```
|
|
55
|
-
|
|
56
69
|
Note that `nbdev` must be installed into the same Python environment
|
|
57
70
|
that you use for both Jupyter and your project.
|
|
58
71
|
|
|
@@ -79,11 +92,13 @@ available commands:
|
|
|
79
92
|
!nbdev_help
|
|
80
93
|
```
|
|
81
94
|
|
|
82
|
-
|
|
95
|
+
nb_export Export a single nbdev notebook to a python script.
|
|
96
|
+
nbdev_bump_version Increment version in __init__.py by one
|
|
83
97
|
nbdev_changelog Create a CHANGELOG.md file from closed and labeled GitHub issues
|
|
84
98
|
nbdev_clean Clean all notebooks in `fname` to avoid merge conflicts
|
|
85
99
|
nbdev_conda Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it
|
|
86
|
-
|
|
100
|
+
nbdev_contributing Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present). Skips if the file doesn't exist.
|
|
101
|
+
nbdev_create_config Create a pyproject.toml config file.
|
|
87
102
|
nbdev_docs Create Quarto docs and README.md
|
|
88
103
|
nbdev_export Export notebooks in `path` to Python modules
|
|
89
104
|
nbdev_filter A notebook filter for Quarto
|
|
@@ -94,6 +109,7 @@ available commands:
|
|
|
94
109
|
nbdev_install_quarto Install latest Quarto on macOS or Linux, prints instructions for Windows
|
|
95
110
|
nbdev_merge Git merge driver for notebooks
|
|
96
111
|
nbdev_migrate Convert all markdown and notebook files in `path` from v1 to v2
|
|
112
|
+
nbdev_migrate_config Migrate settings.ini to pyproject.toml
|
|
97
113
|
nbdev_new Create an nbdev project.
|
|
98
114
|
nbdev_prepare Export, test, and clean notebooks, and render README if needed
|
|
99
115
|
nbdev_preview Preview docs locally
|
|
@@ -103,12 +119,13 @@ available commands:
|
|
|
103
119
|
nbdev_release_both Release both conda and PyPI packages
|
|
104
120
|
nbdev_release_gh Calls `nbdev_changelog`, lets you edit the result, then pushes to git and calls `nbdev_release_git`
|
|
105
121
|
nbdev_release_git Tag and create a release in GitHub for the current version
|
|
106
|
-
nbdev_requirements Writes a `requirements.txt` file to `directory` based on
|
|
122
|
+
nbdev_requirements Writes a `requirements.txt` file to `directory` based on pyproject.toml.
|
|
107
123
|
nbdev_sidebar Create sidebar.yml
|
|
108
124
|
nbdev_test Test in parallel notebooks matching `path`, passing along `flags`
|
|
109
|
-
nbdev_trust Trust notebooks matching `fname
|
|
125
|
+
nbdev_trust Trust notebooks matching `fname`.
|
|
110
126
|
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
111
127
|
nbdev_update_license Allows you to update the license of your project.
|
|
128
|
+
watch_export Use `nb_export` on ipynb files in `nbs` directory on changes using nbdev config if available
|
|
112
129
|
|
|
113
130
|
## FAQ
|
|
114
131
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Autogenerated by nbdev
|
|
2
2
|
|
|
3
|
-
d = { 'settings': { 'branch': '
|
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
|
4
4
|
'doc_baseurl': '/',
|
|
5
5
|
'doc_host': 'https://nbdev.fast.ai',
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/nbdev',
|
|
@@ -28,26 +28,42 @@ d = { 'settings': { 'branch': 'master',
|
|
|
28
28
|
'nbdev.cli.nbdev_new': ('api/cli.html#nbdev_new', 'nbdev/cli.py'),
|
|
29
29
|
'nbdev.cli.nbdev_update_license': ('api/cli.html#nbdev_update_license', 'nbdev/cli.py'),
|
|
30
30
|
'nbdev.cli.watch_export': ('api/cli.html#watch_export', 'nbdev/cli.py')},
|
|
31
|
-
'nbdev.config': { 'nbdev.config.
|
|
31
|
+
'nbdev.config': { 'nbdev.config.ConfigToml': ('api/config.html#configtoml', 'nbdev/config.py'),
|
|
32
|
+
'nbdev.config.ConfigToml.__getattr__': ('api/config.html#configtoml.__getattr__', 'nbdev/config.py'),
|
|
33
|
+
'nbdev.config.ConfigToml.__getitem__': ('api/config.html#configtoml.__getitem__', 'nbdev/config.py'),
|
|
34
|
+
'nbdev.config.ConfigToml.__init__': ('api/config.html#configtoml.__init__', 'nbdev/config.py'),
|
|
35
|
+
'nbdev.config.ConfigToml.d': ('api/config.html#configtoml.d', 'nbdev/config.py'),
|
|
36
|
+
'nbdev.config.ConfigToml.get': ('api/config.html#configtoml.get', 'nbdev/config.py'),
|
|
37
|
+
'nbdev.config.ConfigToml.path': ('api/config.html#configtoml.path', 'nbdev/config.py'),
|
|
38
|
+
'nbdev.config.ConfigToml.version': ('api/config.html#configtoml.version', 'nbdev/config.py'),
|
|
32
39
|
'nbdev.config._basic_export_nb': ('api/config.html#_basic_export_nb', 'nbdev/config.py'),
|
|
33
|
-
'nbdev.config._cfg2txt': ('api/config.html#_cfg2txt', 'nbdev/config.py'),
|
|
34
40
|
'nbdev.config._fetch_from_git': ('api/config.html#_fetch_from_git', 'nbdev/config.py'),
|
|
41
|
+
'nbdev.config._find_nbdev_pyproject': ('api/config.html#_find_nbdev_pyproject', 'nbdev/config.py'),
|
|
35
42
|
'nbdev.config._get_info': ('api/config.html#_get_info', 'nbdev/config.py'),
|
|
36
43
|
'nbdev.config._git_repo': ('api/config.html#_git_repo', 'nbdev/config.py'),
|
|
44
|
+
'nbdev.config._has_nbdev': ('api/config.html#_has_nbdev', 'nbdev/config.py'),
|
|
37
45
|
'nbdev.config._has_py': ('api/config.html#_has_py', 'nbdev/config.py'),
|
|
38
|
-
'nbdev.config.
|
|
39
|
-
'nbdev.config.
|
|
40
|
-
'nbdev.config._type': ('api/config.html#_type', 'nbdev/config.py'),
|
|
41
|
-
'nbdev.config._xdg_config_paths': ('api/config.html#_xdg_config_paths', 'nbdev/config.py'),
|
|
46
|
+
'nbdev.config._load_toml': ('api/config.html#_load_toml', 'nbdev/config.py'),
|
|
47
|
+
'nbdev.config._user_config': ('api/config.html#_user_config', 'nbdev/config.py'),
|
|
42
48
|
'nbdev.config.add_init': ('api/config.html#add_init', 'nbdev/config.py'),
|
|
43
|
-
'nbdev.config.
|
|
49
|
+
'nbdev.config.bump_version': ('api/config.html#bump_version', 'nbdev/config.py'),
|
|
44
50
|
'nbdev.config.create_output': ('api/config.html#create_output', 'nbdev/config.py'),
|
|
45
51
|
'nbdev.config.get_config': ('api/config.html#get_config', 'nbdev/config.py'),
|
|
46
52
|
'nbdev.config.is_nbdev': ('api/config.html#is_nbdev', 'nbdev/config.py'),
|
|
47
53
|
'nbdev.config.nbdev_create_config': ('api/config.html#nbdev_create_config', 'nbdev/config.py'),
|
|
54
|
+
'nbdev.config.read_version': ('api/config.html#read_version', 'nbdev/config.py'),
|
|
55
|
+
'nbdev.config.set_version': ('api/config.html#set_version', 'nbdev/config.py'),
|
|
48
56
|
'nbdev.config.show_src': ('api/config.html#show_src', 'nbdev/config.py'),
|
|
57
|
+
'nbdev.config.update_proj': ('api/config.html#update_proj', 'nbdev/config.py'),
|
|
49
58
|
'nbdev.config.update_version': ('api/config.html#update_version', 'nbdev/config.py'),
|
|
50
59
|
'nbdev.config.write_cells': ('api/config.html#write_cells', 'nbdev/config.py')},
|
|
60
|
+
'nbdev.diff': { 'nbdev.diff._cell_changes': ('api/diff.html#_cell_changes', 'nbdev/diff.py'),
|
|
61
|
+
'nbdev.diff._nb_srcdict': ('api/diff.html#_nb_srcdict', 'nbdev/diff.py'),
|
|
62
|
+
'nbdev.diff.cell_diffs': ('api/diff.html#cell_diffs', 'nbdev/diff.py'),
|
|
63
|
+
'nbdev.diff.changed_cells': ('api/diff.html#changed_cells', 'nbdev/diff.py'),
|
|
64
|
+
'nbdev.diff.nbs_pair': ('api/diff.html#nbs_pair', 'nbdev/diff.py'),
|
|
65
|
+
'nbdev.diff.read_nb_from_git': ('api/diff.html#read_nb_from_git', 'nbdev/diff.py'),
|
|
66
|
+
'nbdev.diff.source_diff': ('api/diff.html#source_diff', 'nbdev/diff.py')},
|
|
51
67
|
'nbdev.doclinks': { 'nbdev.doclinks.NbdevLookup': ('api/doclinks.html#nbdevlookup', 'nbdev/doclinks.py'),
|
|
52
68
|
'nbdev.doclinks.NbdevLookup.__getitem__': ( 'api/doclinks.html#nbdevlookup.__getitem__',
|
|
53
69
|
'nbdev/doclinks.py'),
|
|
@@ -137,15 +153,20 @@ d = { 'settings': { 'branch': 'master',
|
|
|
137
153
|
'nbdev.merge.unpatch': ('api/merge.html#unpatch', 'nbdev/merge.py')},
|
|
138
154
|
'nbdev.migrate': { 'nbdev.migrate.MigrateProc': ('api/migrate.html#migrateproc', 'nbdev/migrate.py'),
|
|
139
155
|
'nbdev.migrate.MigrateProc.begin': ('api/migrate.html#migrateproc.begin', 'nbdev/migrate.py'),
|
|
156
|
+
'nbdev.migrate._build_classifiers': ('api/migrate.html#_build_classifiers', 'nbdev/migrate.py'),
|
|
140
157
|
'nbdev.migrate._cat_slug': ('api/migrate.html#_cat_slug', 'nbdev/migrate.py'),
|
|
141
158
|
'nbdev.migrate._co': ('api/migrate.html#_co', 'nbdev/migrate.py'),
|
|
142
159
|
'nbdev.migrate._convert_callout': ('api/migrate.html#_convert_callout', 'nbdev/migrate.py'),
|
|
143
160
|
'nbdev.migrate._convert_video': ('api/migrate.html#_convert_video', 'nbdev/migrate.py'),
|
|
144
161
|
'nbdev.migrate._file_slug': ('api/migrate.html#_file_slug', 'nbdev/migrate.py'),
|
|
162
|
+
'nbdev.migrate._fmt_script': ('api/migrate.html#_fmt_script', 'nbdev/migrate.py'),
|
|
145
163
|
'nbdev.migrate._fp_convert': ('api/migrate.html#_fp_convert', 'nbdev/migrate.py'),
|
|
146
164
|
'nbdev.migrate._fp_fm': ('api/migrate.html#_fp_fm', 'nbdev/migrate.py'),
|
|
147
165
|
'nbdev.migrate._fp_image': ('api/migrate.html#_fp_image', 'nbdev/migrate.py'),
|
|
148
166
|
'nbdev.migrate._is_jekyll_post': ('api/migrate.html#_is_jekyll_post', 'nbdev/migrate.py'),
|
|
167
|
+
'nbdev.migrate._migrate_workflows': ('api/migrate.html#_migrate_workflows', 'nbdev/migrate.py'),
|
|
168
|
+
'nbdev.migrate._nbdev_migrate_config': ('api/migrate.html#_nbdev_migrate_config', 'nbdev/migrate.py'),
|
|
169
|
+
'nbdev.migrate._py_val': ('api/migrate.html#_py_val', 'nbdev/migrate.py'),
|
|
149
170
|
'nbdev.migrate._re_v1': ('api/migrate.html#_re_v1', 'nbdev/migrate.py'),
|
|
150
171
|
'nbdev.migrate._repl_directives': ('api/migrate.html#_repl_directives', 'nbdev/migrate.py'),
|
|
151
172
|
'nbdev.migrate._repl_v1dir': ('api/migrate.html#_repl_v1dir', 'nbdev/migrate.py'),
|
|
@@ -153,11 +174,13 @@ d = { 'settings': { 'branch': 'master',
|
|
|
153
174
|
'nbdev.migrate._replace_fm': ('api/migrate.html#_replace_fm', 'nbdev/migrate.py'),
|
|
154
175
|
'nbdev.migrate._rm_quote': ('api/migrate.html#_rm_quote', 'nbdev/migrate.py'),
|
|
155
176
|
'nbdev.migrate._subv1': ('api/migrate.html#_subv1', 'nbdev/migrate.py'),
|
|
177
|
+
'nbdev.migrate._toml_val': ('api/migrate.html#_toml_val', 'nbdev/migrate.py'),
|
|
156
178
|
'nbdev.migrate._v': ('api/migrate.html#_v', 'nbdev/migrate.py'),
|
|
157
179
|
'nbdev.migrate.fp_md_fm': ('api/migrate.html#fp_md_fm', 'nbdev/migrate.py'),
|
|
158
180
|
'nbdev.migrate.migrate_md': ('api/migrate.html#migrate_md', 'nbdev/migrate.py'),
|
|
159
181
|
'nbdev.migrate.migrate_nb': ('api/migrate.html#migrate_nb', 'nbdev/migrate.py'),
|
|
160
|
-
'nbdev.migrate.nbdev_migrate': ('api/migrate.html#nbdev_migrate', 'nbdev/migrate.py')
|
|
182
|
+
'nbdev.migrate.nbdev_migrate': ('api/migrate.html#nbdev_migrate', 'nbdev/migrate.py'),
|
|
183
|
+
'nbdev.migrate.nbdev_migrate_config': ('api/migrate.html#nbdev_migrate_config', 'nbdev/migrate.py')},
|
|
161
184
|
'nbdev.process': { 'nbdev.process.NBProcessor': ('api/process.html#nbprocessor', 'nbdev/process.py'),
|
|
162
185
|
'nbdev.process.NBProcessor.__init__': ('api/process.html#nbprocessor.__init__', 'nbdev/process.py'),
|
|
163
186
|
'nbdev.process.NBProcessor._proc': ('api/process.html#nbprocessor._proc', 'nbdev/process.py'),
|
|
@@ -257,20 +280,22 @@ d = { 'settings': { 'branch': 'master',
|
|
|
257
280
|
'nbdev.quarto._SidebarYmlRemoved.__init__': ( 'api/quarto.html#_sidebarymlremoved.__init__',
|
|
258
281
|
'nbdev/quarto.py'),
|
|
259
282
|
'nbdev.quarto._copytree': ('api/quarto.html#_copytree', 'nbdev/quarto.py'),
|
|
283
|
+
'nbdev.quarto._doc_mtime_not_older': ('api/quarto.html#_doc_mtime_not_older', 'nbdev/quarto.py'),
|
|
260
284
|
'nbdev.quarto._ensure_quarto': ('api/quarto.html#_ensure_quarto', 'nbdev/quarto.py'),
|
|
261
285
|
'nbdev.quarto._install_linux': ('api/quarto.html#_install_linux', 'nbdev/quarto.py'),
|
|
262
286
|
'nbdev.quarto._install_mac': ('api/quarto.html#_install_mac', 'nbdev/quarto.py'),
|
|
263
287
|
'nbdev.quarto._nbglob_docs': ('api/quarto.html#_nbglob_docs', 'nbdev/quarto.py'),
|
|
264
288
|
'nbdev.quarto._pre': ('api/quarto.html#_pre', 'nbdev/quarto.py'),
|
|
265
289
|
'nbdev.quarto._pre_docs': ('api/quarto.html#_pre_docs', 'nbdev/quarto.py'),
|
|
266
|
-
'nbdev.quarto._readme_mtime_not_older': ('api/quarto.html#_readme_mtime_not_older', 'nbdev/quarto.py'),
|
|
267
290
|
'nbdev.quarto._recursive_parser': ('api/quarto.html#_recursive_parser', 'nbdev/quarto.py'),
|
|
291
|
+
'nbdev.quarto._save_cached_contributing': ('api/quarto.html#_save_cached_contributing', 'nbdev/quarto.py'),
|
|
268
292
|
'nbdev.quarto._save_cached_readme': ('api/quarto.html#_save_cached_readme', 'nbdev/quarto.py'),
|
|
269
293
|
'nbdev.quarto._sort': ('api/quarto.html#_sort', 'nbdev/quarto.py'),
|
|
270
294
|
'nbdev.quarto._sprun': ('api/quarto.html#_sprun', 'nbdev/quarto.py'),
|
|
271
295
|
'nbdev.quarto.fs_watchdog': ('api/quarto.html#fs_watchdog', 'nbdev/quarto.py'),
|
|
272
296
|
'nbdev.quarto.install': ('api/quarto.html#install', 'nbdev/quarto.py'),
|
|
273
297
|
'nbdev.quarto.install_quarto': ('api/quarto.html#install_quarto', 'nbdev/quarto.py'),
|
|
298
|
+
'nbdev.quarto.nbdev_contributing': ('api/quarto.html#nbdev_contributing', 'nbdev/quarto.py'),
|
|
274
299
|
'nbdev.quarto.nbdev_docs': ('api/quarto.html#nbdev_docs', 'nbdev/quarto.py'),
|
|
275
300
|
'nbdev.quarto.nbdev_preview': ('api/quarto.html#nbdev_preview', 'nbdev/quarto.py'),
|
|
276
301
|
'nbdev.quarto.nbdev_proc_nbs': ('api/quarto.html#nbdev_proc_nbs', 'nbdev/quarto.py'),
|
|
@@ -293,12 +318,12 @@ d = { 'settings': { 'branch': 'master',
|
|
|
293
318
|
'nbdev.release._run': ('api/release.html#_run', 'nbdev/release.py'),
|
|
294
319
|
'nbdev.release._write_yaml': ('api/release.html#_write_yaml', 'nbdev/release.py'),
|
|
295
320
|
'nbdev.release.anaconda_upload': ('api/release.html#anaconda_upload', 'nbdev/release.py'),
|
|
296
|
-
'nbdev.release.bump_version': ('api/release.html#bump_version', 'nbdev/release.py'),
|
|
297
321
|
'nbdev.release.changelog': ('api/release.html#changelog', 'nbdev/release.py'),
|
|
298
322
|
'nbdev.release.chk_conda_rel': ('api/release.html#chk_conda_rel', 'nbdev/release.py'),
|
|
299
323
|
'nbdev.release.conda_output_path': ('api/release.html#conda_output_path', 'nbdev/release.py'),
|
|
300
324
|
'nbdev.release.latest_pypi': ('api/release.html#latest_pypi', 'nbdev/release.py'),
|
|
301
325
|
'nbdev.release.nbdev_bump_version': ('api/release.html#nbdev_bump_version', 'nbdev/release.py'),
|
|
326
|
+
'nbdev.release.push_release': ('api/release.html#push_release', 'nbdev/release.py'),
|
|
302
327
|
'nbdev.release.pypi_details': ('api/release.html#pypi_details', 'nbdev/release.py'),
|
|
303
328
|
'nbdev.release.pypi_json': ('api/release.html#pypi_json', 'nbdev/release.py'),
|
|
304
329
|
'nbdev.release.release_both': ('api/release.html#release_both', 'nbdev/release.py'),
|
|
@@ -312,44 +337,10 @@ d = { 'settings': { 'branch': 'master',
|
|
|
312
337
|
'nbdev.serve._proc_file': ('api/serve.html#_proc_file', 'nbdev/serve.py'),
|
|
313
338
|
'nbdev.serve.proc_nbs': ('api/serve.html#proc_nbs', 'nbdev/serve.py')},
|
|
314
339
|
'nbdev.serve_drv': {},
|
|
315
|
-
'nbdev.showdoc': { 'nbdev.showdoc.
|
|
316
|
-
'nbdev.showdoc.BasicHtmlRenderer._repr_html_': ( 'api/showdoc.html#basichtmlrenderer._repr_html_',
|
|
317
|
-
'nbdev/showdoc.py'),
|
|
318
|
-
'nbdev.showdoc.BasicHtmlRenderer.doc': ('api/showdoc.html#basichtmlrenderer.doc', 'nbdev/showdoc.py'),
|
|
319
|
-
'nbdev.showdoc.BasicMarkdownRenderer': ('api/showdoc.html#basicmarkdownrenderer', 'nbdev/showdoc.py'),
|
|
340
|
+
'nbdev.showdoc': { 'nbdev.showdoc.BasicMarkdownRenderer': ('api/showdoc.html#basicmarkdownrenderer', 'nbdev/showdoc.py'),
|
|
320
341
|
'nbdev.showdoc.BasicMarkdownRenderer._repr_markdown_': ( 'api/showdoc.html#basicmarkdownrenderer._repr_markdown_',
|
|
321
342
|
'nbdev/showdoc.py'),
|
|
322
|
-
'nbdev.showdoc.DocmentTbl': ('api/showdoc.html#docmenttbl', 'nbdev/showdoc.py'),
|
|
323
|
-
'nbdev.showdoc.DocmentTbl.__eq__': ('api/showdoc.html#docmenttbl.__eq__', 'nbdev/showdoc.py'),
|
|
324
|
-
'nbdev.showdoc.DocmentTbl.__init__': ('api/showdoc.html#docmenttbl.__init__', 'nbdev/showdoc.py'),
|
|
325
|
-
'nbdev.showdoc.DocmentTbl._columns': ('api/showdoc.html#docmenttbl._columns', 'nbdev/showdoc.py'),
|
|
326
|
-
'nbdev.showdoc.DocmentTbl._hdr_list': ('api/showdoc.html#docmenttbl._hdr_list', 'nbdev/showdoc.py'),
|
|
327
|
-
'nbdev.showdoc.DocmentTbl._repr_markdown_': ( 'api/showdoc.html#docmenttbl._repr_markdown_',
|
|
328
|
-
'nbdev/showdoc.py'),
|
|
329
|
-
'nbdev.showdoc.DocmentTbl._row': ('api/showdoc.html#docmenttbl._row', 'nbdev/showdoc.py'),
|
|
330
|
-
'nbdev.showdoc.DocmentTbl._row_list': ('api/showdoc.html#docmenttbl._row_list', 'nbdev/showdoc.py'),
|
|
331
|
-
'nbdev.showdoc.DocmentTbl.has_docment': ('api/showdoc.html#docmenttbl.has_docment', 'nbdev/showdoc.py'),
|
|
332
|
-
'nbdev.showdoc.DocmentTbl.has_return': ('api/showdoc.html#docmenttbl.has_return', 'nbdev/showdoc.py'),
|
|
333
|
-
'nbdev.showdoc.DocmentTbl.hdr_str': ('api/showdoc.html#docmenttbl.hdr_str', 'nbdev/showdoc.py'),
|
|
334
|
-
'nbdev.showdoc.DocmentTbl.params_str': ('api/showdoc.html#docmenttbl.params_str', 'nbdev/showdoc.py'),
|
|
335
|
-
'nbdev.showdoc.DocmentTbl.return_str': ('api/showdoc.html#docmenttbl.return_str', 'nbdev/showdoc.py'),
|
|
336
|
-
'nbdev.showdoc.ShowDocRenderer': ('api/showdoc.html#showdocrenderer', 'nbdev/showdoc.py'),
|
|
337
|
-
'nbdev.showdoc.ShowDocRenderer.__init__': ('api/showdoc.html#showdocrenderer.__init__', 'nbdev/showdoc.py'),
|
|
338
|
-
'nbdev.showdoc._bold': ('api/showdoc.html#_bold', 'nbdev/showdoc.py'),
|
|
339
|
-
'nbdev.showdoc._create_html_table': ('api/showdoc.html#_create_html_table', 'nbdev/showdoc.py'),
|
|
340
|
-
'nbdev.showdoc._docstring': ('api/showdoc.html#_docstring', 'nbdev/showdoc.py'),
|
|
341
|
-
'nbdev.showdoc._escape_markdown': ('api/showdoc.html#_escape_markdown', 'nbdev/showdoc.py'),
|
|
342
343
|
'nbdev.showdoc._ext_link': ('api/showdoc.html#_ext_link', 'nbdev/showdoc.py'),
|
|
343
|
-
'nbdev.showdoc._f_name': ('api/showdoc.html#_f_name', 'nbdev/showdoc.py'),
|
|
344
|
-
'nbdev.showdoc._fmt_anno': ('api/showdoc.html#_fmt_anno', 'nbdev/showdoc.py'),
|
|
345
|
-
'nbdev.showdoc._fmt_sig': ('api/showdoc.html#_fmt_sig', 'nbdev/showdoc.py'),
|
|
346
|
-
'nbdev.showdoc._fullname': ('api/showdoc.html#_fullname', 'nbdev/showdoc.py'),
|
|
347
|
-
'nbdev.showdoc._html_link': ('api/showdoc.html#_html_link', 'nbdev/showdoc.py'),
|
|
348
|
-
'nbdev.showdoc._list2row': ('api/showdoc.html#_list2row', 'nbdev/showdoc.py'),
|
|
349
|
-
'nbdev.showdoc._maybe_nm': ('api/showdoc.html#_maybe_nm', 'nbdev/showdoc.py'),
|
|
350
|
-
'nbdev.showdoc._non_empty_keys': ('api/showdoc.html#_non_empty_keys', 'nbdev/showdoc.py'),
|
|
351
|
-
'nbdev.showdoc._show_param': ('api/showdoc.html#_show_param', 'nbdev/showdoc.py'),
|
|
352
|
-
'nbdev.showdoc._wrap_sig': ('api/showdoc.html#_wrap_sig', 'nbdev/showdoc.py'),
|
|
353
344
|
'nbdev.showdoc.colab_link': ('api/showdoc.html#colab_link', 'nbdev/showdoc.py'),
|
|
354
345
|
'nbdev.showdoc.doc': ('api/showdoc.html#doc', 'nbdev/showdoc.py'),
|
|
355
346
|
'nbdev.showdoc.show_doc': ('api/showdoc.html#show_doc', 'nbdev/showdoc.py'),
|
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/11_clean.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% auto 0
|
|
5
|
+
# %% auto #0
|
|
6
6
|
__all__ = ['nbdev_trust', 'clean_nb', 'process_write', 'nbdev_clean', 'clean_jupyter', 'nbdev_install_hooks']
|
|
7
7
|
|
|
8
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
8
|
+
# %% ../nbs/api/11_clean.ipynb #07637414
|
|
9
9
|
import ast,warnings,stat
|
|
10
10
|
from astunparse import unparse
|
|
11
11
|
from textwrap import indent
|
|
12
12
|
|
|
13
13
|
from execnb.nbio import *
|
|
14
14
|
from fastcore.script import *
|
|
15
|
-
from fastcore.
|
|
16
|
-
from fastcore.
|
|
15
|
+
from fastcore.utils import *
|
|
16
|
+
from fastcore.xtras import *
|
|
17
17
|
|
|
18
18
|
from .imports import *
|
|
19
19
|
from .config import *
|
|
20
20
|
from .sync import *
|
|
21
21
|
from .process import first_code_ln
|
|
22
22
|
|
|
23
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
23
|
+
# %% ../nbs/api/11_clean.ipynb #4259f92c
|
|
24
24
|
@call_parse
|
|
25
25
|
def nbdev_trust(
|
|
26
26
|
fname:str=None, # A notebook name or glob to trust
|
|
27
27
|
force_all:bool=False # Also trust notebooks that haven't changed
|
|
28
28
|
):
|
|
29
|
-
"Trust notebooks matching `fname
|
|
29
|
+
"Trust notebooks matching `fname`."
|
|
30
30
|
try: from nbformat.sign import NotebookNotary
|
|
31
31
|
except:
|
|
32
32
|
import warnings
|
|
@@ -47,7 +47,7 @@ def nbdev_trust(
|
|
|
47
47
|
if not NotebookNotary().check_signature(nb): NotebookNotary().sign(nb)
|
|
48
48
|
check_fname.touch(exist_ok=True)
|
|
49
49
|
|
|
50
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
50
|
+
# %% ../nbs/api/11_clean.ipynb #a2ba2b4c
|
|
51
51
|
_repr_id_re = re.compile('(<.*?)( at 0x[0-9a-fA-F]+)(>)')
|
|
52
52
|
|
|
53
53
|
_sub = partial(_repr_id_re.sub, r'\1\3')
|
|
@@ -57,7 +57,7 @@ def _skip_or_sub(x): return _sub(x) if "at 0x" in x else x
|
|
|
57
57
|
def _clean_cell_output_id(lines):
|
|
58
58
|
return _skip_or_sub(lines) if isinstance(lines,str) else [_skip_or_sub(o) for o in lines]
|
|
59
59
|
|
|
60
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
60
|
+
# %% ../nbs/api/11_clean.ipynb #b4cde615
|
|
61
61
|
def _clean_cell_output(cell, clean_ids):
|
|
62
62
|
"Remove `cell` output execution count and optionally ids from text reprs"
|
|
63
63
|
outputs = cell.get('outputs', [])
|
|
@@ -69,9 +69,9 @@ def _clean_cell_output(cell, clean_ids):
|
|
|
69
69
|
if k.startswith('text') and clean_ids: data[k] = _clean_cell_output_id(data[k])
|
|
70
70
|
if k.startswith('image') and "svg" not in k: data[k] = data[k].rstrip()
|
|
71
71
|
if 'text' in o and clean_ids: o['text'] = _clean_cell_output_id(o['text'])
|
|
72
|
-
|
|
72
|
+
# o.get('metadata', {}).pop('tags', None)
|
|
73
73
|
|
|
74
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
74
|
+
# %% ../nbs/api/11_clean.ipynb #2ba79c93
|
|
75
75
|
def _clean_cell(cell, clear_all, allowed_metadata_keys, clean_ids):
|
|
76
76
|
"Clean `cell` by removing superfluous metadata or everything except the input if `clear_all`"
|
|
77
77
|
if 'execution_count' in cell: cell['execution_count'] = None
|
|
@@ -81,8 +81,9 @@ def _clean_cell(cell, clear_all, allowed_metadata_keys, clean_ids):
|
|
|
81
81
|
if cell['source'] == ['']: cell['source'] = []
|
|
82
82
|
cell['metadata'] = {} if clear_all else {
|
|
83
83
|
k:v for k,v in cell['metadata'].items() if k in allowed_metadata_keys}
|
|
84
|
+
if 'id' not in cell: cell['id'] = rtoken_hex(4)
|
|
84
85
|
|
|
85
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
86
|
+
# %% ../nbs/api/11_clean.ipynb #e8101222
|
|
86
87
|
def clean_nb(
|
|
87
88
|
nb, # The notebook to clean
|
|
88
89
|
clear_all=False, # Remove all cell metadata and cell outputs?
|
|
@@ -99,13 +100,15 @@ def clean_nb(
|
|
|
99
100
|
if nb.get('metadata', {}).get('kernelspec', {}).get('name', None):
|
|
100
101
|
nb['metadata']['kernelspec']['display_name'] = nb["metadata"]["kernelspec"]["name"]
|
|
101
102
|
nb['metadata'] = {k:v for k,v in nb['metadata'].items() if k in metadata_keys}
|
|
103
|
+
# Cell IDs were added in nbformat 4.5
|
|
104
|
+
if nb.get('nbformat') == 4 and nb.get('nbformat_minor', 0) < 5: nb['nbformat_minor'] = 5
|
|
102
105
|
|
|
103
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
106
|
+
# %% ../nbs/api/11_clean.ipynb #604d83e6
|
|
104
107
|
def _reconfigure(*strms):
|
|
105
108
|
for s in strms:
|
|
106
109
|
if hasattr(s,'reconfigure'): s.reconfigure(encoding='utf-8')
|
|
107
110
|
|
|
108
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
111
|
+
# %% ../nbs/api/11_clean.ipynb #d251837f
|
|
109
112
|
def process_write(warn_msg, proc_nb, f_in, f_out=None, disp=False):
|
|
110
113
|
if not f_out: f_out = f_in
|
|
111
114
|
if isinstance(f_in, (str,Path)): f_in = Path(f_in).open(encoding="utf-8")
|
|
@@ -118,16 +121,16 @@ def process_write(warn_msg, proc_nb, f_in, f_out=None, disp=False):
|
|
|
118
121
|
warn(f'{warn_msg}')
|
|
119
122
|
warn(e)
|
|
120
123
|
|
|
121
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
124
|
+
# %% ../nbs/api/11_clean.ipynb #714357ce
|
|
122
125
|
def _nbdev_clean(nb, path=None, clear_all=None):
|
|
123
126
|
cfg = get_config(path=path)
|
|
124
127
|
clear_all = clear_all or cfg.clear_all
|
|
125
|
-
allowed_metadata_keys = cfg.get("allowed_metadata_keys")
|
|
126
|
-
allowed_cell_metadata_keys = cfg.get("allowed_cell_metadata_keys")
|
|
128
|
+
allowed_metadata_keys = cfg.get("allowed_metadata_keys") or []
|
|
129
|
+
allowed_cell_metadata_keys = cfg.get("allowed_cell_metadata_keys") or []
|
|
127
130
|
clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)
|
|
128
131
|
if path: nbdev_trust.__wrapped__(path)
|
|
129
132
|
|
|
130
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
133
|
+
# %% ../nbs/api/11_clean.ipynb #6af3b9d4
|
|
131
134
|
@call_parse
|
|
132
135
|
def nbdev_clean(
|
|
133
136
|
fname:str=None, # A notebook name or glob to clean
|
|
@@ -143,15 +146,14 @@ def nbdev_clean(
|
|
|
143
146
|
if fname is None: fname = get_config().nbs_path
|
|
144
147
|
for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp)
|
|
145
148
|
|
|
146
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
149
|
+
# %% ../nbs/api/11_clean.ipynb #f84289fc
|
|
147
150
|
def clean_jupyter(path, model, **kwargs):
|
|
148
151
|
"Clean Jupyter `model` pre save to `path`"
|
|
149
152
|
if not (model['type']=='notebook' and model['content']['nbformat']==4): return
|
|
150
|
-
get_config.cache_clear() # Allow config changes without restarting Jupyter
|
|
151
153
|
jupyter_hooks = get_config(path=path).jupyter_hooks
|
|
152
154
|
if jupyter_hooks: _nbdev_clean(model['content'], path=path)
|
|
153
155
|
|
|
154
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
156
|
+
# %% ../nbs/api/11_clean.ipynb #b7c19563
|
|
155
157
|
_pre_save_hook_src = '''
|
|
156
158
|
def nbdev_clean_jupyter(**kwargs):
|
|
157
159
|
try: from nbdev.clean import clean_jupyter
|
|
@@ -161,7 +163,7 @@ def nbdev_clean_jupyter(**kwargs):
|
|
|
161
163
|
c.ContentsManager.pre_save_hook = nbdev_clean_jupyter'''.strip()
|
|
162
164
|
_pre_save_hook_re = re.compile(r'c\.(File)?ContentsManager\.pre_save_hook')
|
|
163
165
|
|
|
164
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
166
|
+
# %% ../nbs/api/11_clean.ipynb #fcb8df4b
|
|
165
167
|
def _add_jupyter_hooks(src, path):
|
|
166
168
|
if _pre_save_hook_src in src: return
|
|
167
169
|
mod = ast.parse(src)
|
|
@@ -179,12 +181,12 @@ def _add_jupyter_hooks(src, path):
|
|
|
179
181
|
if src: src+='\n\n'
|
|
180
182
|
return src+_pre_save_hook_src
|
|
181
183
|
|
|
182
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
184
|
+
# %% ../nbs/api/11_clean.ipynb #cc677e44
|
|
183
185
|
def _git_root():
|
|
184
186
|
try: return Path(run('git rev-parse --show-toplevel'))
|
|
185
187
|
except OSError: return None
|
|
186
188
|
|
|
187
|
-
# %% ../nbs/api/11_clean.ipynb
|
|
189
|
+
# %% ../nbs/api/11_clean.ipynb #e6083614
|
|
188
190
|
@call_parse
|
|
189
191
|
def nbdev_install_hooks():
|
|
190
192
|
"Install Jupyter and git hooks to automatically clean, trust, and fix merge conflicts in notebooks"
|