nbdev 2.3.12__tar.gz → 2.3.14__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.12/nbdev.egg-info → nbdev-2.3.14}/PKG-INFO +48 -42
- {nbdev-2.3.12 → nbdev-2.3.14}/README.md +29 -40
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/__init__.py +1 -1
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/_modidx.py +10 -3
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/cli.py +64 -9
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/config.py +3 -1
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/doclinks.py +13 -9
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/export.py +23 -4
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/frontmatter.py +5 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/maker.py +1 -1
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/merge.py +2 -2
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/process.py +6 -5
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/quarto.py +63 -32
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/release.py +6 -5
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/serve.py +5 -5
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/showdoc.py +16 -16
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/test.py +2 -1
- {nbdev-2.3.12 → nbdev-2.3.14/nbdev.egg-info}/PKG-INFO +48 -42
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/entry_points.txt +1 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/requires.txt +2 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/settings.ini +5 -4
- {nbdev-2.3.12 → nbdev-2.3.14}/setup.py +8 -4
- {nbdev-2.3.12 → nbdev-2.3.14}/CONTRIBUTING.md +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/LICENSE +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/MANIFEST.in +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/clean.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/extract_attachments.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/imports.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/migrate.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/processors.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/qmd.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/serve_drv.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev/sync.py +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/SOURCES.txt +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/not-zip-safe +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-2.3.12 → nbdev-2.3.14}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.14
|
|
4
4
|
Summary: Create delightful software with Jupyter Notebooks
|
|
5
5
|
Home-page: https://github.com/fastai/nbdev
|
|
6
6
|
Author: Jeremy Howard and Hamel Husain
|
|
@@ -15,28 +15,35 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
19
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
20
|
Requires-Python: >=3.7
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
21
|
-
Provides-Extra: dev
|
|
22
22
|
License-File: LICENSE
|
|
23
|
+
Requires-Dist: packaging
|
|
24
|
+
Requires-Dist: ipywidgets<=8.0.4
|
|
25
|
+
Requires-Dist: fastcore>=1.5.27
|
|
26
|
+
Requires-Dist: execnb>=0.1.4
|
|
27
|
+
Requires-Dist: astunparse
|
|
28
|
+
Requires-Dist: ghapi>=1.0.3
|
|
29
|
+
Requires-Dist: watchdog
|
|
30
|
+
Requires-Dist: asttokens
|
|
31
|
+
Requires-Dist: PyYAML
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: nbdev-numpy; extra == "dev"
|
|
34
|
+
Requires-Dist: nbdev-stdlib; extra == "dev"
|
|
35
|
+
Requires-Dist: pandas; extra == "dev"
|
|
36
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
37
|
+
Requires-Dist: black; extra == "dev"
|
|
38
|
+
Requires-Dist: svg.py; extra == "dev"
|
|
39
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
23
40
|
|
|
24
|
-
Getting Started
|
|
25
|
-
================
|
|
41
|
+
# Getting Started
|
|
26
42
|
|
|
27
43
|
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
28
44
|
|
|
29
45
|

|
|
30
46
|
|
|
31
|
-
*NB: This is nbdev v2, a major upgrade of nbdev. Whilst the differences
|
|
32
|
-
to nbdev1 aren’t huge, it does require some changes. The old version
|
|
33
|
-
docs are at [nbdev1.fast.ai](https://nbdev1.fast.ai). You can use
|
|
34
|
-
version-pinning in `settings.ini` (i.e `'nbdev<2'`) to stop nbdev from
|
|
35
|
-
upgrading. To upgrade, follow the [migration
|
|
36
|
-
tutorial](https://nbdev.fast.ai/migrating.html).*
|
|
37
|
-
|
|
38
|
-
------------------------------------------------------------------------
|
|
39
|
-
|
|
40
47
|
`nbdev` is a notebook-driven development platform. Simply write
|
|
41
48
|
notebooks with lightweight markup and get high-quality documentation,
|
|
42
49
|
tests, continuous integration, and packaging for free!
|
|
@@ -115,35 +122,34 @@ available commands:
|
|
|
115
122
|
!nbdev_help
|
|
116
123
|
```
|
|
117
124
|
|
|
118
|
-
nbdev_bump_version
|
|
119
|
-
nbdev_changelog
|
|
120
|
-
nbdev_clean
|
|
121
|
-
nbdev_conda
|
|
122
|
-
nbdev_create_config
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
125
|
+
nbdev_bump_version Increment version in settings.ini by one
|
|
126
|
+
nbdev_changelog Create a CHANGELOG.md file from closed and labeled GitHub issues
|
|
127
|
+
nbdev_clean Clean all notebooks in `fname` to avoid merge conflicts
|
|
128
|
+
nbdev_conda Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it
|
|
129
|
+
nbdev_create_config Create a config file.
|
|
130
|
+
nbdev_docs Create Quarto docs and README.md
|
|
131
|
+
nbdev_export Export notebooks in `path` to Python modules
|
|
132
|
+
nbdev_filter A notebook filter for Quarto
|
|
133
|
+
nbdev_fix Create working notebook from conflicted notebook `nbname`
|
|
134
|
+
nbdev_help Show help for all console scripts
|
|
135
|
+
nbdev_install Install Quarto and the current library
|
|
136
|
+
nbdev_install_hooks Install Jupyter and git hooks to automatically clean, trust, and fix merge conflicts in notebooks
|
|
137
|
+
nbdev_install_quarto Install latest Quarto on macOS or Linux, prints instructions for Windows
|
|
138
|
+
nbdev_merge Git merge driver for notebooks
|
|
139
|
+
nbdev_migrate Convert all markdown and notebook files in `path` from v1 to v2
|
|
140
|
+
nbdev_new Create an nbdev project.
|
|
141
|
+
nbdev_prepare Export, test, and clean notebooks, and render README if needed
|
|
142
|
+
nbdev_preview Preview docs locally
|
|
143
|
+
nbdev_proc_nbs Process notebooks in `path` for docs rendering
|
|
144
|
+
nbdev_pypi Create and upload Python package to PyPI
|
|
145
|
+
nbdev_readme Create README.md from readme_nb (index.ipynb by default)
|
|
146
|
+
nbdev_release_both Release both conda and PyPI packages
|
|
147
|
+
nbdev_release_gh Calls `nbdev_changelog`, lets you edit the result, then pushes to git and calls `nbdev_release_git`
|
|
148
|
+
nbdev_release_git Tag and create a release in GitHub for the current version
|
|
149
|
+
nbdev_sidebar Create sidebar.yml
|
|
150
|
+
nbdev_test Test in parallel notebooks matching `path`, passing along `flags`
|
|
151
|
+
nbdev_trust Trust notebooks matching `fname`
|
|
152
|
+
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
147
153
|
|
|
148
154
|
## FAQ
|
|
149
155
|
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
Getting Started
|
|
2
|
-
================
|
|
1
|
+
# Getting Started
|
|
3
2
|
|
|
4
3
|
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
4
|
|
|
6
5
|

|
|
7
6
|
|
|
8
|
-
*NB: This is nbdev v2, a major upgrade of nbdev. Whilst the differences
|
|
9
|
-
to nbdev1 aren’t huge, it does require some changes. The old version
|
|
10
|
-
docs are at [nbdev1.fast.ai](https://nbdev1.fast.ai). You can use
|
|
11
|
-
version-pinning in `settings.ini` (i.e `'nbdev<2'`) to stop nbdev from
|
|
12
|
-
upgrading. To upgrade, follow the [migration
|
|
13
|
-
tutorial](https://nbdev.fast.ai/migrating.html).*
|
|
14
|
-
|
|
15
|
-
------------------------------------------------------------------------
|
|
16
|
-
|
|
17
7
|
`nbdev` is a notebook-driven development platform. Simply write
|
|
18
8
|
notebooks with lightweight markup and get high-quality documentation,
|
|
19
9
|
tests, continuous integration, and packaging for free!
|
|
@@ -92,35 +82,34 @@ available commands:
|
|
|
92
82
|
!nbdev_help
|
|
93
83
|
```
|
|
94
84
|
|
|
95
|
-
nbdev_bump_version
|
|
96
|
-
nbdev_changelog
|
|
97
|
-
nbdev_clean
|
|
98
|
-
nbdev_conda
|
|
99
|
-
nbdev_create_config
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
85
|
+
nbdev_bump_version Increment version in settings.ini by one
|
|
86
|
+
nbdev_changelog Create a CHANGELOG.md file from closed and labeled GitHub issues
|
|
87
|
+
nbdev_clean Clean all notebooks in `fname` to avoid merge conflicts
|
|
88
|
+
nbdev_conda Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it
|
|
89
|
+
nbdev_create_config Create a config file.
|
|
90
|
+
nbdev_docs Create Quarto docs and README.md
|
|
91
|
+
nbdev_export Export notebooks in `path` to Python modules
|
|
92
|
+
nbdev_filter A notebook filter for Quarto
|
|
93
|
+
nbdev_fix Create working notebook from conflicted notebook `nbname`
|
|
94
|
+
nbdev_help Show help for all console scripts
|
|
95
|
+
nbdev_install Install Quarto and the current library
|
|
96
|
+
nbdev_install_hooks Install Jupyter and git hooks to automatically clean, trust, and fix merge conflicts in notebooks
|
|
97
|
+
nbdev_install_quarto Install latest Quarto on macOS or Linux, prints instructions for Windows
|
|
98
|
+
nbdev_merge Git merge driver for notebooks
|
|
99
|
+
nbdev_migrate Convert all markdown and notebook files in `path` from v1 to v2
|
|
100
|
+
nbdev_new Create an nbdev project.
|
|
101
|
+
nbdev_prepare Export, test, and clean notebooks, and render README if needed
|
|
102
|
+
nbdev_preview Preview docs locally
|
|
103
|
+
nbdev_proc_nbs Process notebooks in `path` for docs rendering
|
|
104
|
+
nbdev_pypi Create and upload Python package to PyPI
|
|
105
|
+
nbdev_readme Create README.md from readme_nb (index.ipynb by default)
|
|
106
|
+
nbdev_release_both Release both conda and PyPI packages
|
|
107
|
+
nbdev_release_gh Calls `nbdev_changelog`, lets you edit the result, then pushes to git and calls `nbdev_release_git`
|
|
108
|
+
nbdev_release_git Tag and create a release in GitHub for the current version
|
|
109
|
+
nbdev_sidebar Create sidebar.yml
|
|
110
|
+
nbdev_test Test in parallel notebooks matching `path`, passing along `flags`
|
|
111
|
+
nbdev_trust Trust notebooks matching `fname`
|
|
112
|
+
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
|
|
124
113
|
|
|
125
114
|
## FAQ
|
|
126
115
|
|
|
@@ -24,7 +24,8 @@ d = { 'settings': { 'branch': 'master',
|
|
|
24
24
|
'nbdev.cli.chelp': ('api/cli.html#chelp', 'nbdev/cli.py'),
|
|
25
25
|
'nbdev.cli.extract_tgz': ('api/cli.html#extract_tgz', 'nbdev/cli.py'),
|
|
26
26
|
'nbdev.cli.nbdev_filter': ('api/cli.html#nbdev_filter', 'nbdev/cli.py'),
|
|
27
|
-
'nbdev.cli.nbdev_new': ('api/cli.html#nbdev_new', 'nbdev/cli.py')
|
|
27
|
+
'nbdev.cli.nbdev_new': ('api/cli.html#nbdev_new', 'nbdev/cli.py'),
|
|
28
|
+
'nbdev.cli.nbdev_update_license': ('api/cli.html#nbdev_update_license', 'nbdev/cli.py')},
|
|
28
29
|
'nbdev.config': { 'nbdev.config._apply_defaults': ('api/config.html#_apply_defaults', 'nbdev/config.py'),
|
|
29
30
|
'nbdev.config._basic_export_nb': ('api/config.html#_basic_export_nb', 'nbdev/config.py'),
|
|
30
31
|
'nbdev.config._cfg2txt': ('api/config.html#_cfg2txt', 'nbdev/config.py'),
|
|
@@ -76,7 +77,9 @@ d = { 'settings': { 'branch': 'master',
|
|
|
76
77
|
'nbdev.export.ExportModuleProc._exporti_': ('api/export.html#exportmoduleproc._exporti_', 'nbdev/export.py'),
|
|
77
78
|
'nbdev.export.ExportModuleProc.begin': ('api/export.html#exportmoduleproc.begin', 'nbdev/export.py'),
|
|
78
79
|
'nbdev.export.black_format': ('api/export.html#black_format', 'nbdev/export.py'),
|
|
79
|
-
'nbdev.export.nb_export': ('api/export.html#nb_export', 'nbdev/export.py')
|
|
80
|
+
'nbdev.export.nb_export': ('api/export.html#nb_export', 'nbdev/export.py'),
|
|
81
|
+
'nbdev.export.optional_procs': ('api/export.html#optional_procs', 'nbdev/export.py'),
|
|
82
|
+
'nbdev.export.scrub_magics': ('api/export.html#scrub_magics', 'nbdev/export.py')},
|
|
80
83
|
'nbdev.extract_attachments': {},
|
|
81
84
|
'nbdev.frontmatter': { 'nbdev.frontmatter.FrontmatterProc': ('api/frontmatter.html#frontmatterproc', 'nbdev/frontmatter.py'),
|
|
82
85
|
'nbdev.frontmatter.FrontmatterProc._update': ( 'api/frontmatter.html#frontmatterproc._update',
|
|
@@ -231,7 +234,10 @@ d = { 'settings': { 'branch': 'master',
|
|
|
231
234
|
'nbdev.qmd.meta': ('api/qmd.html#meta', 'nbdev/qmd.py'),
|
|
232
235
|
'nbdev.qmd.tbl_row': ('api/qmd.html#tbl_row', 'nbdev/qmd.py'),
|
|
233
236
|
'nbdev.qmd.tbl_sep': ('api/qmd.html#tbl_sep', 'nbdev/qmd.py')},
|
|
234
|
-
'nbdev.quarto': { 'nbdev.quarto.
|
|
237
|
+
'nbdev.quarto': { 'nbdev.quarto.IndentDumper': ('api/quarto.html#indentdumper', 'nbdev/quarto.py'),
|
|
238
|
+
'nbdev.quarto.IndentDumper.increase_indent': ( 'api/quarto.html#indentdumper.increase_indent',
|
|
239
|
+
'nbdev/quarto.py'),
|
|
240
|
+
'nbdev.quarto._SidebarYmlRemoved': ('api/quarto.html#_sidebarymlremoved', 'nbdev/quarto.py'),
|
|
235
241
|
'nbdev.quarto._SidebarYmlRemoved.__enter__': ( 'api/quarto.html#_sidebarymlremoved.__enter__',
|
|
236
242
|
'nbdev/quarto.py'),
|
|
237
243
|
'nbdev.quarto._SidebarYmlRemoved.__exit__': ( 'api/quarto.html#_sidebarymlremoved.__exit__',
|
|
@@ -246,6 +252,7 @@ d = { 'settings': { 'branch': 'master',
|
|
|
246
252
|
'nbdev.quarto._pre': ('api/quarto.html#_pre', 'nbdev/quarto.py'),
|
|
247
253
|
'nbdev.quarto._pre_docs': ('api/quarto.html#_pre_docs', 'nbdev/quarto.py'),
|
|
248
254
|
'nbdev.quarto._readme_mtime_not_older': ('api/quarto.html#_readme_mtime_not_older', 'nbdev/quarto.py'),
|
|
255
|
+
'nbdev.quarto._recursive_parser': ('api/quarto.html#_recursive_parser', 'nbdev/quarto.py'),
|
|
249
256
|
'nbdev.quarto._save_cached_readme': ('api/quarto.html#_save_cached_readme', 'nbdev/quarto.py'),
|
|
250
257
|
'nbdev.quarto._sort': ('api/quarto.html#_sort', 'nbdev/quarto.py'),
|
|
251
258
|
'nbdev.quarto._sprun': ('api/quarto.html#_sprun', 'nbdev/quarto.py'),
|
|
@@ -25,7 +25,7 @@ from contextlib import redirect_stdout
|
|
|
25
25
|
import os, tarfile, sys
|
|
26
26
|
|
|
27
27
|
# %% auto 0
|
|
28
|
-
__all__ = ['nbdev_filter', 'extract_tgz', 'nbdev_new', 'chelp']
|
|
28
|
+
__all__ = ['mapping', 'nbdev_filter', 'extract_tgz', 'nbdev_new', 'nbdev_update_license', 'chelp']
|
|
29
29
|
|
|
30
30
|
# %% ../nbs/api/13_cli.ipynb 5
|
|
31
31
|
@call_parse
|
|
@@ -67,7 +67,7 @@ def _render_nb(fn, cfg):
|
|
|
67
67
|
def _update_repo_meta(cfg):
|
|
68
68
|
"Enable gh pages and update the homepage and description in your GitHub repo."
|
|
69
69
|
token=os.getenv('GITHUB_TOKEN')
|
|
70
|
-
if token:
|
|
70
|
+
if token:
|
|
71
71
|
from ghapi.core import GhApi
|
|
72
72
|
api = GhApi(owner=cfg.user, repo=cfg.repo, token=token)
|
|
73
73
|
try: api.repos.update(homepage=f'{cfg.doc_host}{cfg.doc_baseurl}', description=cfg.description)
|
|
@@ -85,13 +85,28 @@ def nbdev_new(**kwargs):
|
|
|
85
85
|
_update_repo_meta(cfg)
|
|
86
86
|
|
|
87
87
|
path = Path()
|
|
88
|
-
with warnings.catch_warnings():
|
|
89
|
-
warnings.simplefilter('ignore', UserWarning)
|
|
90
|
-
tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release('fastai', 'nbdev-template').tag_name
|
|
91
|
-
url = f"https://github.com/fastai/nbdev-template/archive/{tag}.tar.gz"
|
|
92
|
-
extract_tgz(url)
|
|
93
|
-
tmpl_path = path/f'nbdev-template-{tag}'
|
|
94
88
|
|
|
89
|
+
_ORG_OR_USR = 'fastai'
|
|
90
|
+
_REPOSITORY = 'nbdev-template'
|
|
91
|
+
_TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}'
|
|
92
|
+
template = kwargs.get('template', _TEMPLATE)
|
|
93
|
+
try:
|
|
94
|
+
org_or_usr, repo = template.split('/')
|
|
95
|
+
except ValueError:
|
|
96
|
+
org_or_usr, repo = _ORG_OR_USR, _REPOSITORY
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
tag = kwargs.get('tag', None)
|
|
100
|
+
if tag is None:
|
|
101
|
+
with warnings.catch_warnings():
|
|
102
|
+
warnings.simplefilter('ignore', UserWarning)
|
|
103
|
+
|
|
104
|
+
tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release(org_or_usr, repo).tag_name
|
|
105
|
+
|
|
106
|
+
url = f"https://github.com/{org_or_usr}/{repo}/archive/{tag}.tar.gz"
|
|
107
|
+
extract_tgz(url)
|
|
108
|
+
tmpl_path = path/f'{repo}-{tag}'
|
|
109
|
+
|
|
95
110
|
cfg.nbs_path.mkdir(exist_ok=True)
|
|
96
111
|
nbexists = bool(first(cfg.nbs_path.glob('*.ipynb')))
|
|
97
112
|
_nbs_path_sufs = ('.ipynb','.css')
|
|
@@ -108,7 +123,47 @@ def nbdev_new(**kwargs):
|
|
|
108
123
|
nbdev_export.__wrapped__()
|
|
109
124
|
nbdev_readme.__wrapped__()
|
|
110
125
|
|
|
111
|
-
# %% ../nbs/api/13_cli.ipynb
|
|
126
|
+
# %% ../nbs/api/13_cli.ipynb 13
|
|
127
|
+
mapping = {
|
|
128
|
+
'mit': 'mit',
|
|
129
|
+
'apache2': 'apache-2.0',
|
|
130
|
+
'gpl2': 'gpl-2.0',
|
|
131
|
+
'gpl3': 'gpl-3.0',
|
|
132
|
+
'bsd3': 'bsd-3-clause'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# %% ../nbs/api/13_cli.ipynb 14
|
|
136
|
+
@call_parse
|
|
137
|
+
def nbdev_update_license(
|
|
138
|
+
to: str=None, # update license to
|
|
139
|
+
):
|
|
140
|
+
"Allows you to update the license of your project."
|
|
141
|
+
from ghapi.core import GhApi
|
|
142
|
+
warnings.filterwarnings("ignore")
|
|
143
|
+
avail_lic = GhApi().licenses.get_all_commonly_used().map(lambda x: x['key'])
|
|
144
|
+
|
|
145
|
+
cfg = get_config()
|
|
146
|
+
curr_lic = cfg['license']
|
|
147
|
+
|
|
148
|
+
mapped = mapping.get(to, None)
|
|
149
|
+
|
|
150
|
+
if mapped not in avail_lic: raise ValueError(f"{to} is not an available license")
|
|
151
|
+
body = GhApi().licenses.get(mapped)['body']
|
|
152
|
+
|
|
153
|
+
body = body.replace('[year], [fullname]', cfg['copyright'])
|
|
154
|
+
body = body.replace('[year] [fullname]', cfg['copyright'])
|
|
155
|
+
|
|
156
|
+
content = open("settings.ini", "r").read()
|
|
157
|
+
content = re.sub(r"^(license\s*=\s*).*?$", r"\1 " + to, content, flags=re.MULTILINE)
|
|
158
|
+
|
|
159
|
+
config = open("settings.ini", "w")
|
|
160
|
+
config.write(content)
|
|
161
|
+
|
|
162
|
+
lic = open('LICENSE', 'w')
|
|
163
|
+
lic.write(body)
|
|
164
|
+
print(f"License updated from {curr_lic} to {to}")
|
|
165
|
+
|
|
166
|
+
# %% ../nbs/api/13_cli.ipynb 17
|
|
112
167
|
@call_parse
|
|
113
168
|
def chelp():
|
|
114
169
|
"Show help for all console scripts"
|
|
@@ -91,7 +91,7 @@ def _get_info(owner, repo, default_branch='main', default_kw='nbdev'):
|
|
|
91
91
|
msg= [f"""Could not access repo: {owner}/{repo} to find your default branch - `{default_branch}` assumed.
|
|
92
92
|
Edit `settings.ini` if this is incorrect.
|
|
93
93
|
In the future, you can allow nbdev to see private repos by setting the environment variable GITHUB_TOKEN as described here:
|
|
94
|
-
https://nbdev.fast.ai/
|
|
94
|
+
https://nbdev.fast.ai/api/release.html#setup"""]
|
|
95
95
|
print(''.join(msg))
|
|
96
96
|
return default_branch,default_kw,''
|
|
97
97
|
|
|
@@ -152,6 +152,8 @@ _nbdev_cfg_tail = '''### Optional ###
|
|
|
152
152
|
# requirements = fastcore pandas
|
|
153
153
|
# dev_requirements =
|
|
154
154
|
# console_scripts =
|
|
155
|
+
# conda_user =
|
|
156
|
+
# package_data =
|
|
155
157
|
'''
|
|
156
158
|
|
|
157
159
|
# %% ../nbs/api/01_config.ipynb 21
|
|
@@ -46,7 +46,7 @@ def patch_name(o):
|
|
|
46
46
|
def _iter_py_cells(p):
|
|
47
47
|
"Yield cells from an exported Python file."
|
|
48
48
|
p = Path(p)
|
|
49
|
-
cells = p.read_text().split("\n# %% ")
|
|
49
|
+
cells = p.read_text(encoding='utf-8').split("\n# %% ")
|
|
50
50
|
for cell in cells[1:]:
|
|
51
51
|
top,code = cell.split('\n', 1)
|
|
52
52
|
try:
|
|
@@ -93,7 +93,7 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
|
|
|
93
93
|
idxfile = dest/'_modidx.py'
|
|
94
94
|
if skip_exists and idxfile.exists(): return
|
|
95
95
|
with contextlib.suppress(FileNotFoundError): idxfile.unlink()
|
|
96
|
-
if idxfile.exists(): res = exec_local(idxfile.read_text(), 'd')
|
|
96
|
+
if idxfile.exists(): res = exec_local(idxfile.read_text(encoding='utf-8'), 'd')
|
|
97
97
|
else: res = dict(syms={}, settings={})
|
|
98
98
|
res['settings'] = {k:v for k,v in get_config().d.items()
|
|
99
99
|
if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')}
|
|
@@ -131,19 +131,23 @@ def nbglob_cli(
|
|
|
131
131
|
@delegates(nbglob_cli)
|
|
132
132
|
def nbdev_export(
|
|
133
133
|
path:str=None, # Path or filename
|
|
134
|
+
procs:Param("tokens naming the export processors to use.", nargs="*", choices=optional_procs())="black_format",
|
|
134
135
|
**kwargs):
|
|
135
136
|
"Export notebooks in `path` to Python modules"
|
|
136
137
|
if os.environ.get('IN_TEST',0): return
|
|
138
|
+
if procs:
|
|
139
|
+
import nbdev.export
|
|
140
|
+
procs = [getattr(nbdev.export, p) for p in L(procs)]
|
|
137
141
|
files = nbglob(path=path, as_path=True, **kwargs).sorted('name')
|
|
138
|
-
for f in files: nb_export(f)
|
|
142
|
+
for f in files: nb_export(f, procs=procs)
|
|
139
143
|
add_init(get_config().lib_path)
|
|
140
144
|
_build_modidx()
|
|
141
145
|
|
|
142
|
-
# %% ../nbs/api/05_doclinks.ipynb
|
|
146
|
+
# %% ../nbs/api/05_doclinks.ipynb 25
|
|
143
147
|
import importlib,ast
|
|
144
148
|
from functools import lru_cache
|
|
145
149
|
|
|
146
|
-
# %% ../nbs/api/05_doclinks.ipynb
|
|
150
|
+
# %% ../nbs/api/05_doclinks.ipynb 26
|
|
147
151
|
def _find_mod(mod):
|
|
148
152
|
mp,_,mr = mod.partition('/')
|
|
149
153
|
spec = importlib.util.find_spec(mp)
|
|
@@ -155,7 +159,7 @@ def _find_mod(mod):
|
|
|
155
159
|
def _get_exps(mod):
|
|
156
160
|
mf = _find_mod(mod)
|
|
157
161
|
if not mf: return {}
|
|
158
|
-
txt = mf.read_text()
|
|
162
|
+
txt = mf.read_text(encoding='utf-8')
|
|
159
163
|
_def_types = ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef
|
|
160
164
|
d = {}
|
|
161
165
|
for tree in ast.parse(txt).body:
|
|
@@ -166,7 +170,7 @@ def _get_exps(mod):
|
|
|
166
170
|
|
|
167
171
|
def _lineno(sym, fname): return _get_exps(fname).get(sym, None) if fname else None
|
|
168
172
|
|
|
169
|
-
# %% ../nbs/api/05_doclinks.ipynb
|
|
173
|
+
# %% ../nbs/api/05_doclinks.ipynb 28
|
|
170
174
|
def _qual_sym(s, settings):
|
|
171
175
|
if not isinstance(s,tuple): return s
|
|
172
176
|
nb,py = s
|
|
@@ -181,10 +185,10 @@ def _qual_syms(entries):
|
|
|
181
185
|
if 'doc_host' not in settings: return entries
|
|
182
186
|
return {'syms': {mod:_qual_mod(d, settings) for mod,d in entries['syms'].items()}, 'settings':settings}
|
|
183
187
|
|
|
184
|
-
# %% ../nbs/api/05_doclinks.ipynb
|
|
188
|
+
# %% ../nbs/api/05_doclinks.ipynb 29
|
|
185
189
|
_re_backticks = re.compile(r'`([^`\s]+)`')
|
|
186
190
|
|
|
187
|
-
# %% ../nbs/api/05_doclinks.ipynb
|
|
191
|
+
# %% ../nbs/api/05_doclinks.ipynb 30
|
|
188
192
|
@lru_cache(None)
|
|
189
193
|
class NbdevLookup:
|
|
190
194
|
"Mapping from symbol names to docs and source URLs"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/04_export.ipynb.
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
|
-
__all__ = ['ExportModuleProc', 'black_format', 'nb_export']
|
|
4
|
+
__all__ = ['ExportModuleProc', 'black_format', 'scrub_magics', 'optional_procs', 'nb_export']
|
|
5
5
|
|
|
6
6
|
# %% ../nbs/api/04_export.ipynb 2
|
|
7
7
|
from .config import *
|
|
@@ -26,7 +26,7 @@ class ExportModuleProc:
|
|
|
26
26
|
self.in_all[ifnone(exp_to, '#')].append(cell)
|
|
27
27
|
_exports_=_export_
|
|
28
28
|
|
|
29
|
-
# %% ../nbs/api/04_export.ipynb
|
|
29
|
+
# %% ../nbs/api/04_export.ipynb 8
|
|
30
30
|
def black_format(cell, # Cell to format
|
|
31
31
|
force=False): # Turn black formatting on regardless of settings.ini
|
|
32
32
|
"Processor to format code with `black`"
|
|
@@ -40,8 +40,27 @@ def black_format(cell, # Cell to format
|
|
|
40
40
|
try: cell.source = _format_str(cell.source).strip()
|
|
41
41
|
except: pass
|
|
42
42
|
|
|
43
|
-
# %% ../nbs/api/04_export.ipynb
|
|
44
|
-
|
|
43
|
+
# %% ../nbs/api/04_export.ipynb 10
|
|
44
|
+
# includes the newline, because calling .strip() would affect all cells.
|
|
45
|
+
_magics_pattern = re.compile(r'^\s*(%%|%).*\n?', re.MULTILINE)
|
|
46
|
+
|
|
47
|
+
def scrub_magics(cell): # Cell to format
|
|
48
|
+
"Processor to remove cell magics from exported code"
|
|
49
|
+
try: cfg = get_config()
|
|
50
|
+
except FileNotFoundError: return
|
|
51
|
+
if cell.cell_type != 'code': return
|
|
52
|
+
try: cell.source = _magics_pattern.sub('', cell.source)
|
|
53
|
+
except: pass
|
|
54
|
+
|
|
55
|
+
# %% ../nbs/api/04_export.ipynb 13
|
|
56
|
+
import nbdev.export
|
|
57
|
+
def optional_procs():
|
|
58
|
+
"An explicit list of processors that could be used by `nb_export`"
|
|
59
|
+
return L([p for p in nbdev.export.__all__
|
|
60
|
+
if p not in ["nb_export", "ExportModuleProc", "optional_procs"]])
|
|
61
|
+
|
|
62
|
+
# %% ../nbs/api/04_export.ipynb 16
|
|
63
|
+
def nb_export(nbname, lib_path=None, procs=None, debug=False, mod_maker=ModuleMaker, name=None):
|
|
45
64
|
"Create module(s) from notebook"
|
|
46
65
|
if lib_path is None: lib_path = get_config().lib_path
|
|
47
66
|
exp = ExportModuleProc()
|
|
@@ -63,5 +63,10 @@ class FrontmatterProc(Processor):
|
|
|
63
63
|
def end(self):
|
|
64
64
|
self.nb.frontmatter_ = self.fm
|
|
65
65
|
if not self.fm: return
|
|
66
|
+
if not hasattr(self.nb, 'path_'):
|
|
67
|
+
raise AttributeError('Notebook missing `path_` attribute.\n\nPlease remove any nbdev-related notebook filters '
|
|
68
|
+
'from your _quarto.yml file (e.g. `ipynb-filter: [nbdev_filter]`), since they are no '
|
|
69
|
+
'longer supported as of nbdev v2.3. See the v2.3 launch post for more information: '
|
|
70
|
+
'https://forums.fast.ai/t/upcoming-changes-in-v2-3-edit-now-released/98905.')
|
|
66
71
|
self.fm.update({'output-file': _nbpath2html(Path(self.nb.path_)).name})
|
|
67
72
|
_insertfm(self.nb, self.fm)
|
|
@@ -47,7 +47,7 @@ def update_var(varname, func, fn=None, code=None):
|
|
|
47
47
|
"Update the definition of `varname` in file `fn`, by calling `func` with the current definition"
|
|
48
48
|
if fn:
|
|
49
49
|
fn = Path(fn)
|
|
50
|
-
code = fn.read_text()
|
|
50
|
+
code = fn.read_text(encoding='utf-8')
|
|
51
51
|
lines = code.splitlines()
|
|
52
52
|
v = read_var(code, varname)
|
|
53
53
|
res = func(v)
|
|
@@ -63,7 +63,7 @@ def nbdev_fix(nbname:str, # Notebook filename to fix
|
|
|
63
63
|
"Create working notebook from conflicted notebook `nbname`"
|
|
64
64
|
nbname = Path(nbname)
|
|
65
65
|
if not nobackup and not outname: shutil.copy(nbname, nbname.with_suffix('.ipynb.bak'))
|
|
66
|
-
nbtxt = nbname.read_text()
|
|
66
|
+
nbtxt = nbname.read_text(encoding='utf-8')
|
|
67
67
|
a,b,branch1,branch2 = unpatch(nbtxt)
|
|
68
68
|
ac,bc = dict2nb(loads(a)),dict2nb(loads(b))
|
|
69
69
|
dest = bc if theirs else ac
|
|
@@ -85,7 +85,7 @@ def _git_rebase_head():
|
|
|
85
85
|
for d in ('apply','merge'):
|
|
86
86
|
d = Path(f'.git/rebase-{d}')
|
|
87
87
|
if d.is_dir():
|
|
88
|
-
cmt = (d/'orig-head').read_text()
|
|
88
|
+
cmt = (d/'orig-head').read_text(encoding='utf-8')
|
|
89
89
|
msg = run(f'git show-branch --no-name {cmt}')
|
|
90
90
|
return f'{cmt[:7]} ({msg})'
|
|
91
91
|
|
|
@@ -33,6 +33,7 @@ def _quarto_re(lang=None): return re.compile(_dir_pre(lang) + r'\s*[\w|-]+\s*:')
|
|
|
33
33
|
# %% ../nbs/api/03_process.ipynb 11
|
|
34
34
|
def _directive(s, lang='python'):
|
|
35
35
|
s = re.sub('^'+_dir_pre(lang), f"{langs[lang]}|", s)
|
|
36
|
+
if s.strip().endswith(':'): s = s.replace(':', '') # You can append colon at the end to be Quarto compliant. Ex: #|hide:
|
|
36
37
|
if ':' in s: s = s.replace(':', ': ')
|
|
37
38
|
s = (s.strip()[2:]).strip().split()
|
|
38
39
|
if not s: return None
|
|
@@ -70,22 +71,22 @@ def extract_directives(cell, remove=True, lang='python'):
|
|
|
70
71
|
cell['source'] = ''.join([_norm_quarto(o, lang) for o in dirs if _quarto_re(lang).match(o) or _cell_mgc.match(o)] + code)
|
|
71
72
|
return dict(L(_directive(s, lang) for s in dirs).filter())
|
|
72
73
|
|
|
73
|
-
# %% ../nbs/api/03_process.ipynb
|
|
74
|
+
# %% ../nbs/api/03_process.ipynb 21
|
|
74
75
|
def opt_set(var, newval):
|
|
75
76
|
"newval if newval else var"
|
|
76
77
|
return newval if newval else var
|
|
77
78
|
|
|
78
|
-
# %% ../nbs/api/03_process.ipynb
|
|
79
|
+
# %% ../nbs/api/03_process.ipynb 22
|
|
79
80
|
def instantiate(x, **kwargs):
|
|
80
81
|
"Instantiate `x` if it's a type"
|
|
81
82
|
return x(**kwargs) if isinstance(x,type) else x
|
|
82
83
|
|
|
83
84
|
def _mk_procs(procs, nb): return L(procs).map(instantiate, nb=nb)
|
|
84
85
|
|
|
85
|
-
# %% ../nbs/api/03_process.ipynb
|
|
86
|
+
# %% ../nbs/api/03_process.ipynb 23
|
|
86
87
|
def _is_direc(f): return getattr(f, '__name__', '-')[-1]=='_'
|
|
87
88
|
|
|
88
|
-
# %% ../nbs/api/03_process.ipynb
|
|
89
|
+
# %% ../nbs/api/03_process.ipynb 24
|
|
89
90
|
class NBProcessor:
|
|
90
91
|
"Process cells and nbdev comments in a notebook"
|
|
91
92
|
def __init__(self, path=None, procs=None, nb=None, debug=False, rm_directives=True, process=False):
|
|
@@ -125,7 +126,7 @@ class NBProcessor:
|
|
|
125
126
|
"Process all cells with all processors"
|
|
126
127
|
for proc in self.procs: self._proc(proc)
|
|
127
128
|
|
|
128
|
-
# %% ../nbs/api/03_process.ipynb
|
|
129
|
+
# %% ../nbs/api/03_process.ipynb 34
|
|
129
130
|
class Processor:
|
|
130
131
|
"Base class for processors"
|
|
131
132
|
def __init__(self, nb): self.nb = nb
|