Skip to content

Commit 4e142c0

Browse files
committed
spacing
1 parent e15f30d commit 4e142c0

File tree

9 files changed

+49
-49
lines changed

9 files changed

+49
-49
lines changed

nbdev/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def nb_export(nbname:str, # Filename of notebook
8585
all_cells = exp.in_all[mod]
8686
nm = ifnone(name, getattr(exp, 'default_exp', None) if mod=='#' else mod)
8787
if not nm:
88-
warn(f"Notebook '{nbname}' uses `#|export` without `#|default_exp` cell.\n"
88+
warn(f"Notebook '{nbname}' uses `#| export` without `#| default_exp` cell.\n"
8989
"Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\n"
9090
"See https://nbdev.fast.ai/getting_started.html for more information.")
9191
return

nbdev/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _quarto_re(lang=None): return re.compile(_dir_pre(lang) + r'\s*[\w|-]+\s*:')
3535
# %% ../nbs/api/03_process.ipynb
3636
def _directive(s, lang='python'):
3737
s = re.sub('^'+_dir_pre(lang), f"{langs[lang]}|", s)
38-
if s.strip().endswith(':'): s = s.replace(':', '') # You can append colon at the end to be Quarto compliant. Ex: #|hide:
38+
if s.strip().endswith(':'): s = s.replace(':', '') # You can append colon at the end to be Quarto compliant. Ex: #| hide:
3939
if ':' in s: s = s.replace(':', ': ')
4040
s = (s.strip()[2:]).strip().split()
4141
if not s: return None

nbs/api/02_maker.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
}
635635
],
636636
"source": [
637-
"cells = make_code_cells(\"from __future__ import print_function\", \"#| export\\ndef a(): ...\", \"#|export\\nclass A:\")\n",
637+
"cells = make_code_cells(\"from __future__ import print_function\", \"#| export\\ndef a(): ...\", \"#| export\\nclass A:\")\n",
638638
"am.make(cells)\n",
639639
"show_src(Path('tmp/test/testing_noall.py').read_text(encoding='utf-8'))"
640640
]

nbs/api/03_process.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@
133133
"outputs": [],
134134
"source": [
135135
"#| hide\n",
136-
"assert _quarto_re().match('#|code-fold: show')\n",
137-
"assert _quarto_re().match('#|hide: true')\n",
138-
"assert not _quarto_re().match('#|code fold: show') #not a valid quarto directive"
136+
"assert _quarto_re().match('#| code-fold: show')\n",
137+
"assert _quarto_re().match('#| hide: true')\n",
138+
"assert not _quarto_re().match('#| code fold: show') #not a valid quarto directive"
139139
]
140140
},
141141
{
@@ -148,7 +148,7 @@
148148
"#| export\n",
149149
"def _directive(s, lang='python'):\n",
150150
" s = re.sub('^'+_dir_pre(lang), f\"{langs[lang]}|\", s)\n",
151-
" if s.strip().endswith(':'): s = s.replace(':', '') # You can append colon at the end to be Quarto compliant. Ex: #|hide:\n",
151+
" if s.strip().endswith(':'): s = s.replace(':', '') # You can append colon at the end to be Quarto compliant. Ex: #| hide:\n",
152152
" if ':' in s: s = s.replace(':', ': ')\n",
153153
" s = (s.strip()[2:]).strip().split()\n",
154154
" if not s: return None\n",
@@ -178,9 +178,9 @@
178178
"outputs": [],
179179
"source": [
180180
"#| hide\n",
181-
"test_eq(_norm_quarto('#|foo:bar'), '#|foo: bar')\n",
182-
"test_eq(_norm_quarto('#|foo: bar'), '#|foo: bar')\n",
183-
"test_eq(_norm_quarto('#|not_quarto'), '#|not_quarto')"
181+
"test_eq(_norm_quarto('#| foo:bar'), '# |foo: bar')\n",
182+
"test_eq(_norm_quarto('# |foo: bar'), '#| foo: bar')\n",
183+
"test_eq(_norm_quarto('#| not_quarto'), '#| not_quarto')"
184184
]
185185
},
186186
{
@@ -208,7 +208,7 @@
208208
"source": [
209209
"_tst = \"\"\" \n",
210210
"#| default_exp\n",
211-
" #|export\n",
211+
" #| export\n",
212212
"#| hide_input\n",
213213
"foo\n",
214214
"\"\"\"\n",
@@ -227,7 +227,7 @@
227227
"# test for cell magics\n",
228228
"_tst = \"\"\"%%timeit\n",
229229
"#| hide\n",
230-
" #|export\n",
230+
" #| export\n",
231231
"foo\n",
232232
"\"\"\"\n",
233233
"test_eq(first_code_ln(_tst.splitlines(True)), 3)\n",
@@ -236,7 +236,7 @@
236236
"_tst = \"\"\"\n",
237237
"#| hide\n",
238238
"%line_magic\n",
239-
" #|export\n",
239+
" #| export\n",
240240
"foo\n",
241241
"\"\"\"\n",
242242
"test_eq(first_code_ln(_tst.splitlines(True)),2)"
@@ -298,7 +298,7 @@
298298
"1+2\n",
299299
"#bar\"\"\")\n",
300300
"\n",
301-
"# this one has #|hide: with a colon at the end, wich is quarto compliant\n",
301+
"# this one has #| hide: with a colon at the end, wich is quarto compliant\n",
302302
"exp2 = AttrDict(source = \"\"\"#| export module\n",
303303
"#| eval:false\n",
304304
"#| hide:\n",
@@ -311,7 +311,7 @@
311311
"\n",
312312
"test_eq(extract_directives(exp), _answer)\n",
313313
"test_eq(extract_directives(exp2), _answer)\n",
314-
"test_eq(exp.source, '#|eval: false\\n# |woo: baz\\n1+2\\n#bar')"
314+
"test_eq(exp.source, '#| eval: false\\n# |woo: baz\\n1+2\\n#bar')"
315315
]
316316
},
317317
{

nbs/api/04_export.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
"source": [
197197
"_cell = read_nb('../../tests/export_procs.ipynb')['cells'][2]\n",
198198
"scrub_magics(_cell)\n",
199-
"test_eq(_cell.source, '''#|export bar\n",
199+
"test_eq(_cell.source, '''#| export bar\n",
200200
"\"hello nbdev\"''')"
201201
]
202202
},
@@ -256,7 +256,7 @@
256256
" all_cells = exp.in_all[mod]\n",
257257
" nm = ifnone(name, getattr(exp, 'default_exp', None) if mod=='#' else mod)\n",
258258
" if not nm:\n",
259-
" warn(f\"Notebook '{nbname}' uses `#|export` without `#|default_exp` cell.\\n\"\n",
259+
" warn(f\"Notebook '{nbname}' uses `#| export` without `#| default_exp` cell.\\n\"\n",
260260
" \"Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\\n\"\n",
261261
" \"See https://nbdev.fast.ai/getting_started.html for more information.\")\n",
262262
" return\n",

nbs/blog/posts/2022-11-07-spaces/index.qmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ First, lets import the libraries we need, which in this case are `gradio` and `f
6565

6666

6767
```python
68-
#|export
68+
#| export
6969
import gradio as gr
7070
from fastcore.net import urljson, HTTPError
7171
```
7272

73-
Next, write the functions your gradio app will use. Because of [nbdev](https://nbdev.fast.ai/blog/posts/2022-07-28-nbdev2/), you can prototype and package your code all in one place. **The special comment `#|export` marks which cells will be sent to a python script** (more on this later). Note that there are only three cells in this notebook with the `#|export` directive.
73+
Next, write the functions your gradio app will use. Because of [nbdev](https://nbdev.fast.ai/blog/posts/2022-07-28-nbdev2/), you can prototype and package your code all in one place. **The special comment `#| export` marks which cells will be sent to a python script** (more on this later). Note that there are only three cells in this notebook with the `#| export` directive.
7474

7575

7676
```python
77-
#|export
77+
#| export
7878
def size(repo:str):
7979
"Returns the size in GB of a HuggingFace Dataset."
8080
url = f'https://huggingface.co/api/datasets/{repo}'
@@ -103,7 +103,7 @@ You can construct a simple UI with the `gradio.interface` and then call the `lau
103103

104104

105105
```python
106-
#|export
106+
#| export
107107
iface = gr.Interface(fn=size, inputs=gr.Text(value="tglcourse/CelebA-faces-cropped-128"), outputs="text")
108108
iface.launch(height=450, width=500)
109109
```
@@ -138,7 +138,7 @@ iface.close()
138138

139139
## 4. Convert This Notebook Into A Gradio App
140140

141-
In order to host this code on Hugging Face Spaces, you will export parts of this notebook to a script named `app.py`. As a reminder, this is what the special `#|export` comment that you have seen in cells above do! You can export code from this notebook like so:
141+
In order to host this code on Hugging Face Spaces, you will export parts of this notebook to a script named `app.py`. As a reminder, this is what the special `#| export` comment that you have seen in cells above do! You can export code from this notebook like so:
142142

143143

144144
```python

nbs/explanations/directives.ipynb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"cell_type": "markdown",
5757
"metadata": {},
5858
"source": [
59-
"### 📓 `#|hide` \n",
59+
"### 📓 `#| hide` \n",
6060
"\n",
6161
"Hide cell input and output. "
6262
]
@@ -76,14 +76,14 @@
7676
"print('you will not see this')\n",
7777
"```\n",
7878
"\n",
79-
"Note that using `#|hide` is equivalent to using the Quarto directive `#|include: false`:\n",
79+
"Note that using `#| hide` is equivalent to using the Quarto directive `#| include: false`:\n",
8080
"\n",
8181
"```python\n",
8282
"#| include: false\n",
8383
"print('you will not see this')\n",
8484
"```\n",
8585
"\n",
86-
"See the quarto docs for more information about `#|include`.\n",
86+
"See the quarto docs for more information about `#| include`.\n",
8787
"\n",
8888
":::"
8989
]
@@ -92,7 +92,7 @@
9292
"cell_type": "markdown",
9393
"metadata": {},
9494
"source": [
95-
"### 🔵 `#|echo: <true|false>`\n",
95+
"### 🔵 `#| echo: <true|false>`\n",
9696
"\n",
9797
"Toggle the visibility of code-cell inputs.\n",
9898
"\n",
@@ -120,7 +120,7 @@
120120
"cell_type": "markdown",
121121
"metadata": {},
122122
"source": [
123-
"### 🔵 `#|output: <true|false|asis>`\n",
123+
"### 🔵 `#| output: <true|false|asis>`\n",
124124
"\n",
125125
"Setting this to `false` hides the output of a cell. Setting this to `asis` renders the output as raw markdown.\n",
126126
"\n",
@@ -135,7 +135,7 @@
135135
"1 + 1\n",
136136
"```\n",
137137
" \n",
138-
"The following cell with `#|output: asis` will produce the output `hello fastai` rendered as markdown instead of a string: \n",
138+
"The following cell with `#| output: asis` will produce the output `hello fastai` rendered as markdown instead of a string: \n",
139139
" \n",
140140
"```python \n",
141141
"#| output: asis\n",
@@ -148,7 +148,7 @@
148148
"cell_type": "markdown",
149149
"metadata": {},
150150
"source": [
151-
"### 📓 `#|hide_line`\n",
151+
"### 📓 `#| hide_line`\n",
152152
"\n",
153153
"Hide a specific line of code in an input cell. \n",
154154
"\n",
@@ -160,7 +160,7 @@
160160
"def _secret(): ...\n",
161161
"\n",
162162
"for i in range(3):\n",
163-
" _secret() #|hide_line\n",
163+
" _secret() #| hide_line\n",
164164
" print(i)\n",
165165
"```\n",
166166
"\n",
@@ -186,7 +186,7 @@
186186
"def _secret(): ...\n",
187187
"\n",
188188
"for i in range(3):\n",
189-
" _secret() #|hide_line\n",
189+
" _secret() #| hide_line\n",
190190
" print(i)"
191191
]
192192
},
@@ -201,7 +201,7 @@
201201
"cell_type": "markdown",
202202
"metadata": {},
203203
"source": [
204-
"### 📓 `#|filter_stream <keyword> ...`\n",
204+
"### 📓 `#| filter_stream <keyword> ...`\n",
205205
"\n",
206206
"Filter lines containing specific keywords in cell outputs. \n",
207207
"\n",
@@ -253,20 +253,20 @@
253253
"cell_type": "markdown",
254254
"metadata": {},
255255
"source": [
256-
"### 🔵 `#|code-fold: <show|true>`"
256+
"### 🔵 `#| code-fold: <show|true>`"
257257
]
258258
},
259259
{
260260
"cell_type": "markdown",
261261
"metadata": {},
262262
"source": [
263-
"The `#|code-fold` directive allows you to collapse code cells. When set to `true`, the element is collapsed by default, when set to show `show` the element is shown by default.\n",
263+
"The `#| code-fold` directive allows you to collapse code cells. When set to `true`, the element is collapsed by default, when set to show `show` the element is shown by default.\n",
264264
"\n",
265265
"::: {.callout-note collapse=\"true\"}\n",
266266
"\n",
267267
"##### Example\n",
268268
"\n",
269-
"When you set `#|code-fold: true`, the input cell is collapsed:"
269+
"When you set `#| code-fold: true`, the input cell is collapsed:"
270270
]
271271
},
272272
{
@@ -298,7 +298,7 @@
298298
"cell_type": "markdown",
299299
"metadata": {},
300300
"source": [
301-
"When you set `#|code-fold: show` the input cell is shown but still in a collapsible element:"
301+
"When you set `#| code-fold: show` the input cell is shown but still in a collapsible element:"
302302
]
303303
},
304304
{
@@ -346,14 +346,14 @@
346346
"cell_type": "markdown",
347347
"metadata": {},
348348
"source": [
349-
"### 📓 `#|default_exp <name>`"
349+
"### 📓 `#| default_exp <name>`"
350350
]
351351
},
352352
{
353353
"cell_type": "markdown",
354354
"metadata": {},
355355
"source": [
356-
"Names the module where cells with the `#|export` directive will be exported to by default.\n",
356+
"Names the module where cells with the `#| export` directive will be exported to by default.\n",
357357
"\n",
358358
"::: {.callout-note collapse=\"true\"}\n",
359359
"\n",
@@ -383,7 +383,7 @@
383383
"cell_type": "markdown",
384384
"metadata": {},
385385
"source": [
386-
"### 📓 `#|export`"
386+
"### 📓 `#| export`"
387387
]
388388
},
389389
{
@@ -404,7 +404,7 @@
404404
" return f'Hello {to}!'\n",
405405
"```\n",
406406
"\n",
407-
"The above cell will get exported to the module specified by `#|default_exp`. These exports are automatically included in [`__all__`](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package) for the module. To learn how export without inclusion in `__all__`, see the `#|exporti` directive.\n",
407+
"The above cell will get exported to the module specified by `#| default_exp`. These exports are automatically included in [`__all__`](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package) for the module. To learn how export without inclusion in `__all__`, see the `# |exporti` directive.\n",
408408
"\n",
409409
"Furthermore, the documentation for this function will automatically be rendered like this:"
410410
]
@@ -464,7 +464,7 @@
464464
],
465465
"source": [
466466
"#| echo: false\n",
467-
"# Note: we are using show_doc like this to simulate the effect of #|export without using export\n",
467+
"# Note: we are using show_doc like this to simulate the effect of #| export without using export\n",
468468
"show_doc(say_hello)"
469469
]
470470
},
@@ -486,7 +486,7 @@
486486
"cell_type": "markdown",
487487
"metadata": {},
488488
"source": [
489-
"### 📓 `#|exporti`"
489+
"### 📓 `#| exporti`"
490490
]
491491
},
492492
{
@@ -502,14 +502,14 @@
502502
"cell_type": "markdown",
503503
"metadata": {},
504504
"source": [
505-
"### 📓 `#|exports`"
505+
"### 📓 `#| exports`"
506506
]
507507
},
508508
{
509509
"cell_type": "markdown",
510510
"metadata": {},
511511
"source": [
512-
"A `s`ource export. Like `#|export` but in addition to showing docs via `showdoc.show_doc`, it also shows the source code.\n",
512+
"A `s`ource export. Like `#| export` but in addition to showing docs via `showdoc.show_doc`, it also shows the source code.\n",
513513
"\n",
514514
"\n",
515515
"::: {.callout-note collapse=\"true\"}\n",
@@ -595,7 +595,7 @@
595595
"cell_type": "markdown",
596596
"metadata": {},
597597
"source": [
598-
"### 📓 `#|exec_doc`"
598+
"### 📓 `#| exec_doc`"
599599
]
600600
},
601601
{
@@ -684,7 +684,7 @@
684684
"cell_type": "markdown",
685685
"metadata": {},
686686
"source": [
687-
"### 🔵 `#|eval: <true|false>`"
687+
"### 🔵 `#| eval: <true|false>`"
688688
]
689689
},
690690
{

nbs/tutorials/docs_only.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"\n",
2121
"While nbdev is great for authoring software, you may wish to utilize the power of nbdev for the purposes of documenting existing code, or **use various utilities of nbdev without having to write a python library**. For example, you can use the following features of nbdev without creating a python package:\n",
2222
"\n",
23-
"- Custom [nbdev directives](../explanations/directives.ipynb) such as [`#|hide_line`](../explanations/directives.ipynb#hide_line).\n",
23+
"- Custom [nbdev directives](../explanations/directives.ipynb) such as [`#| hide_line`](../explanations/directives.ipynb#hide_line).\n",
2424
"- Testing with `nbdev_test`.\n",
2525
"- Automated entity linking with [doclinks](best_practices.ipynb#reference-related-symbols-with-doclinks).\n",
2626
"- Rendering API documentation with [docments and show_doc](best_practices.ipynb#document-parameters-with-docments).\n",
@@ -48,7 +48,7 @@
4848
"\n",
4949
"- `nbdev_preview` for previewing your site\n",
5050
"- `nbdev_test` for testing your docs locally\n",
51-
"- Custom [nbdev directives](../explanations/directives.ipynb) will be available to you (but you must be careful not to use irrelevant ones like `#|export`).\n",
51+
"- Custom [nbdev directives](../explanations/directives.ipynb) will be available to you (but you must be careful not to use irrelevant ones like `#| export`).\n",
5252
"- If you created your nbdev docs site on GitHub, GitHub Actions will publish your docs for you automatically [as described here](../explanations/docs.ipynb#Deploying-Docs-With-GitHub-Actions).\n",
5353
"- You can publish your docs on other platforms as described [here](../explanations/docs.ipynb#Deploying-Your-Docs-On-Other-Platforms)."
5454
]

nbs/tutorials/migrating.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"cell_type": "markdown",
5656
"metadata": {},
5757
"source": [
58-
"nbdev has slightly changed how \"directive comments\" like `export` and `default_exp` work, in order to align with how Quarto does things. Now, instead of just adding a `#` to the start to indicate a directive (e.g `#export`), you now need to use `#|` (e.g `#|export`). You can also optionally add a space (e.g `#| export`).\n",
58+
"nbdev has slightly changed how \"directive comments\" like `export` and `default_exp` work, in order to align with how Quarto does things. Now, instead of just adding a `#` to the start to indicate a directive (e.g `#export`), you now need to use `#|` (e.g `#| export`). You can also optionally add a space (e.g `#| export`).\n",
5959
"\n",
6060
"To automatically upgrade your directives to the new format, run in the root of your repo:\n",
6161
"\n",

0 commit comments

Comments
 (0)