Repository navigation
Expand file tree
/
Copy pathtutorial.html
More file actions
912 lines (762 loc) · 48 KB
/
Copy pathtutorial.html
File metadata and controls
912 lines (762 loc) · 48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
---
title: nbdev tutorial
image: images/nbdev_source.gif
keywords: fastai
sidebar: home_sidebar
summary: "A step by step guide"
description: "A step by step guide"
nb_path: "nbs/tutorial.ipynb"
---
<!--
#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/tutorial.ipynb
# command to build the docs after a change: nbdev_build_docs
-->
<div class="container" id="notebook-container">
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>nbdev is a system for <em>exploratory programming</em>. See the <a href="https://www.fast.ai/2019/12/02/nbdev/">nbdev launch post</a> for information about what that means. In practice, programming in this way can feel very different to the kind of programming many of you will be familiar with, since we've mainly be taught coding techniques that are (at least implicitly) tied to the underlying tools we have access to. I've found that programming in a "notebook first" way can make me 2-3x more productive than I was before (when we used vscode, Visual Studio, vim, PyCharm, and similar tools).</p>
<p>In this tutorial, I'll try to get you up and running with the basics of the nbdev system as quickly and easily as possible. You can also watch this video in which I take you through the tutorial, step by step (to view full screen, click the little square in the bottom right of the video; to view in a separate Youtube window, click the Youtube logo):</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/Hrs7iEYmRmg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Set-up-Your-Jupyter-Server">Set up Your Jupyter Server<a class="anchor-link" href="#Set-up-Your-Jupyter-Server"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Jupyter-Environment">Jupyter Environment<a class="anchor-link" href="#Jupyter-Environment"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To complete this tutorial, you'll need a Jupyter Notebook Server configured on your machine. If you have not installed Jupyter before, you may find the <a href="https://www.anaconda.com/products/individual">Anaconda Individual Edition</a> the simplest to install.</p>
<p>If you already have experience with Jupyter, please note that everything in this tutorial must be run using the same kernel.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Install-nbdev">Install <code>nbdev</code><a class="anchor-link" href="#Install-nbdev"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>No matter how you installed Jupyter, you'll need to manually install <code>nbdev</code>. You can install nbdev with <code>pip</code> or <code>conda</code> from a terminal window:</p>
<div class="highlight"><pre><span></span>pip install nbdev
</pre></div>
<p>or</p>
<div class="highlight"><pre><span></span>conda install -c fastai nbdev
</pre></div>
<p>Jupyter notebook has a terminal window available, so we'll use that:</p>
<ol>
<li>Start <code>jupyter notebook</code></li>
<li>From the "New" dropdown on the right side, choose <code>Terminal</code>.</li>
<li>Enter "<code>python -m pip install nbdev</code>" (or use conda as specified above)</li>
</ol>
<p>When the command completes, you're ready to go.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Set-up-Repo">Set up Repo<a class="anchor-link" href="#Set-up-Repo"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Template">Template<a class="anchor-link" href="#Template"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To create your new project repo, click here: <a href="https://github.com/fastai/nbdev_template/generate">nbdev template</a> (you need to be logged in to GitHub for this link to work). Fill in the requested info and click <em>Create repository from template</em>.</p>
<p><strong>NB:</strong> The name of your project will become the name of the Python package generated by nbdev. For that reason, it is a good idea to pick a short, all-lowercase name with <em>no dashes</em> between words (underscores are allowed). Now, open your terminal, and clone the repo you just created.</p>
<p>Alternatively, you can use a cli command <a href="/cli.html#nbdev_new"><code>nbdev_new</code></a> to create a new nbdev project from an existing GitHub repo that you have cloned locally. <em>To create a new GitHub repo locally, we recommend the <a href="https://cli.github.com/">gh cli</a> tool, which allows you to create a new repo with the command <code>gh repo create</code>.</em></p>
<p>_There is also a GitLab template hosted <a href="https://gitlab.com/thomas.capelle/nbdev_template/">here</a> (you need to be logged in to GitLab for this link to work)._</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="GitHub-pages">GitHub pages<a class="anchor-link" href="#GitHub-pages"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The nbdev system uses <a href="https://jekyllrb.com/">jekyll</a> for documentation. Because <a href="https://help.github.com/en/github/working-with-github-pages/setting-up-a-github-pages-site-with-jekyll">GitHub Pages supports Jekyll</a>, you can host your site for free on <a href="https://pages.github.com/">Github Pages</a> without any additional setup, so this is the approach we recommend (but it's not required; any jekyll hosting will work fine).</p>
<p>To enable Github Pages in your project repo, click <em>Settings</em> in Github, then scroll down to <em>Github Pages</em>, and set "Source" to <em>Master branch /docs folder</em>. Once you've saved, if you scroll back down to that section, Github will have a link to your new website. Copy that URL, and then go back to your main repo page, click "edit" next to the description and paste the URL into the "website" section. While you're there, go ahead and put in your project description too. <em>NOTE: Don't expect your Pages to build & deploy properly yet; only after we edit <code>settings.ini</code> (below) and make some other changes will your GitHub Pages site be deployed.</em></p>
<h4 id="Previewing-Documents-Locally">Previewing Documents Locally<a class="anchor-link" href="#Previewing-Documents-Locally"> </a></h4><p>It is often desirable to preview the documentation locally before having it built and rendered by GitHub Pages. This requires you to run Jekyll locally, which requires installing Ruby and Jekyll. Instructions on how to install Jekyll are provided <a href="https://jekyllrb.com/">on Jekyll's site</a>. You can run the command <code>make docs_serve</code> from the root of your repo to serve the documentation locally after calling <a href="/export2html.html#nbdev_build_docs"><code>nbdev_build_docs</code></a> to generate the docs.</p>
<p>In order to allow you to run Jekyll locally <a href="https://github.com/fastai/nbdev_template">nbdev_template</a> contains manifest files, called Gem files, that specify all Ruby dependencies for Jekyll & nbdev. <strong>If you do not plan to preview documentation locally</strong>, you can choose to delete <code>Gemfile</code> and <code>Gemfile.lock</code> from your nbdev repository.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Edit-settings.ini">Edit settings.ini<a class="anchor-link" href="#Edit-settings.ini"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Next, edit the <code>settings.ini</code> file in your cloned repo. This file contains all the necessary information for when you'll be ready to package your library. The basic structure (that can be personalized provided you change the relevant information in <code>settings.ini</code>) is that the root of the repo will contain your notebooks, the <code>docs</code> folder will contain your auto-generated docs, and a folder with a name you select will contain your auto-generated modules.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You'll see these commented out lines in <code>settings.ini</code>. Uncomment them, and set each value as needed.</p>
<pre><code># lib_name = your_project_name
# repo_name = name of github repo
# user = your_github_username
# description = A description of your project
# keywords = some keywords
# author = Your Name
# author_email = email@example.com
# copyright = Your Name or Company Name
# branch = The default branch of your GitHub repo (usually either master or main)</code></pre>
<p>We'll see some other settings we can change later.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Install-git-hooks-to-avoid-and-handle-conflicts">Install git hooks to avoid and handle conflicts<a class="anchor-link" href="#Install-git-hooks-to-avoid-and-handle-conflicts"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Jupyter Notebooks can cause challenges with git conflicts, but life becomes much easier when you use <code>nbdev</code>. As a first step, run <a href="/cli.html#nbdev_install_git_hooks"><code>nbdev_install_git_hooks</code></a> in the terminal from your project folder. This will set up git hooks which will remove metadata from your notebooks when you commit, greatly reducing the chance you have a conflict.</p>
<p>But if you do get a conflict later, simply run <code>nbdev_fix_merge filename.ipynb</code>. This will replace any conflicts in cell outputs with your version, and if there are conflicts in input cells, then both cells will be included in the merged file, along with standard conflict markers (e.g. <code>=====</code>). Then you can open the notebook in Jupyter and choose which version to keep.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Edit-00_core.ipynb">Edit 00_core.ipynb<a class="anchor-link" href="#Edit-00_core.ipynb"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Now, run <code>jupyter notebook</code>, and click <code>00_core.ipynb</code> (you don't <em>have</em> to start your notebook names with a number like we do here; but we find it helpful to show the order you've created your project in). You'll see something that looks a bit like this:</p>
<div class="highlight"><pre><span></span><span class="c1">#default_exp core</span>
</pre></div>
<p><strong>module name here</strong></p>
<blockquote><p>API details.</p>
</blockquote>
<p>Let's explain what these special cells mean.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Module-name-and-summary">Module name and summary<a class="anchor-link" href="#Module-name-and-summary"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The markdown cell uses special syntax to define the title and summary of your module. Feel free to replace "module name here" with a title and "API details." with a summary for your module.</p>
<p>This cell can optionally be used to define jekyll metadata, see <a href="/export2html.html#get_metadata"><code>get_metadata</code></a> for more details.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Add-a-function">Add a function<a class="anchor-link" href="#Add-a-function"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Let's add a function to this notebook, e.g.:</p>
<div class="highlight"><pre><span></span><span class="c1">#export</span>
<span class="k">def</span> <span class="nf">say_hello</span><span class="p">(</span><span class="n">to</span><span class="p">):</span>
<span class="s2">"Say hello to somebody"</span>
<span class="k">return</span> <span class="sa">f</span><span class="s1">'Hello </span><span class="si">{</span><span class="n">to</span><span class="si">}</span><span class="s1">!'</span>
</pre></div>
<p>Notice how it includes <code>#export</code> at the top - this means it will be included in your module, and documentation. The documentation will look like this:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="say_hello" class="doc_header"><code>say_hello</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/tutorial.py#L6" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>say_hello</code>(<strong><code>to</code></strong>)</p>
</blockquote>
<p>Say hello to somebody</p>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Add-examples-and-tests">Add examples and tests<a class="anchor-link" href="#Add-examples-and-tests"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>It's a good idea to give an example of your function in action. Just include regular code cells, and they'll appear (with output) in the docs, e.g.:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">say_hello</span><span class="p">(</span><span class="s2">"Sylvain"</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_text output_subarea output_execute_result">
<pre>'Hello Sylvain!'</pre>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Examples can output plots, images, etc, and they'll all appear in your docs, e.g.:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">display</span><span class="p">,</span><span class="n">SVG</span>
</pre></div>
</div>
</div>
</div>
</div>
{% endraw %}
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">display</span><span class="p">(</span><span class="n">SVG</span><span class="p">(</span><span class="s1">'<svg height="100"><circle cx="50" cy="50" r="40"/></svg>'</span><span class="p">))</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_svg output_subarea ">
<svg height="100"><circle cx="50" cy="50" r="40"/></svg>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You can also include tests:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">assert</span> <span class="n">say_hello</span><span class="p">(</span><span class="s2">"Jeremy"</span><span class="p">)</span><span class="o">==</span><span class="s2">"Hello Jeremy!"</span>
</pre></div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You should also add markdown headings as you create your notebook; one benefit of this is that a table of contents will be created in the documentation automatically.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Build-lib">Build lib<a class="anchor-link" href="#Build-lib"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Now you can create your python module. To do so, just run <a href="/export2html.html#nbdev_build_lib"><code>nbdev_build_lib</code></a> from the terminal when anywhere in your project folder.</p>
<pre><code>$ nbdev_build_lib
Converted 00_core.ipynb.
Converted index.ipynb.</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Note-if-using-a-subdirectory-to-contain-.ipynb-files-instead-of-the-project-root">Note if using a subdirectory to contain .ipynb files instead of the project root<a class="anchor-link" href="#Note-if-using-a-subdirectory-to-contain-.ipynb-files-instead-of-the-project-root"> </a></h4><p>If you have set the parameter nbs_path to be anything other than the project root, you will not be able to import your generated modules without an extra step:</p>
<ul>
<li>either install these modules locally, as their relative import will take you beyond the top-level package, which can be done by running <code>pip install -e .</code> in the project root, to install the modules to your environment in editable mode.</li>
<li>or make a simlink in your notebook folder to the library folder, which can be done by running <code>ln -s lib_path lib_name</code> (adjust <code>lib_path</code> and <code>lib_name</code> to your use case).</li>
</ul>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Edit-index.ipynb">Edit index.ipynb<a class="anchor-link" href="#Edit-index.ipynb"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Now you're ready to create your documentation home page and README.md file; these are both generated automatically from <em>index.ipynb</em>. So click on that to open it now.</p>
<p>You'll see that there's already a line there to import your library - change it to use the name you selected in <code>settings.ini</code>. Then, add information about how to use your module, including some examples. Remember, these examples should be actual notebook code cells with real outputs.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Build-docs">Build docs<a class="anchor-link" href="#Build-docs"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Now you can create your documentation. To do so, just run <a href="/export2html.html#nbdev_build_docs"><code>nbdev_build_docs</code></a> from the terminal when anywhere in your project folder.</p>
<pre><code>$ nbdev_build_docs
converting: /home/jhoward/git/nbdev/nbs/00_core.ipynb
converting: /home/jhoward/git/nbdev/nbs/index.ipynb</code></pre>
<p>This will export HTML versions of your notebooks to the <code>docs</code> directory, and will create hyperlinks for any words in backticks (as long as they exist in your module). It will also create a menu for all notebooks you have created, and a table of contents for each.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Commit-to-Github">Commit to Github<a class="anchor-link" href="#Commit-to-Github"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You can now check-in the generated files with <code>git add</code>, <code>git commit</code> and <code>git push</code>. (You can use <code>git status</code> to check which files have been generated.) The following command should be sufficient:</p>
<pre><code>git add -A; git commit -m'check in files'; git push</code></pre>
<p>Wait a minute or two for Github to process your commit, and then head over to the Github website to look at your results.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Continuous-Integration-(CI)">Continuous Integration (CI)<a class="anchor-link" href="#Continuous-Integration-(CI)"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Back in your project's Github main page, click where it says <em>1 commit</em> (or <em>2 commits</em> or whatever). Hopefully, you'll see a green checkmark next to your latest commit. That means that your documentation site built correctly, and your module's tests all passed! This is checked for you using <em>continuous integration (CI)</em> with <a href="https://github.com/features/actions">GitHub actions</a>. This does the following:</p>
<ul>
<li>Checks the notebooks are readable (with <a href="/test.html#nbdev_read_nbs"><code>nbdev_read_nbs</code></a>)</li>
<li>check the notebooks have been cleaned of needless metadata to avoid merge conflicts (with <a href="/clean.html#nbdev_clean_nbs"><code>nbdev_clean_nbs</code></a>)</li>
<li>check there is no diff between the notebooks and the exported library (with <a href="/sync.html#nbdev_diff_nbs"><code>nbdev_diff_nbs</code></a>)</li>
<li>run the tests in your notebooks (with <a href="/test.html#nbdev_test_nbs"><code>nbdev_test_nbs</code></a>)</li>
</ul>
<p>The template contains a basic CI that uses the four points above, edit the file <code>.github/workflows/main.yml</code> to your liking and comment out the parts you don't want.</p>
<p>If you have a red cross, that means something failed. Click on the cross, then click <em>Details</em>, and you'll be able to see what failed.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="View-docs-and-readme">View docs and readme<a class="anchor-link" href="#View-docs-and-readme"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Once everything is passing, have a look at your readme in Github. You'll see that your <code>index.ipynb</code> file has been converted to a readme automatically.</p>
<p>Next, go to your documentation site (e.g. by clicking on the link next to the description that you created earlier). You should see that your index notebook has also been used here.</p>
<p>Congratulations, the basics are now all in place! Let's continue and use some more advanced functionality.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Add-a-class">Add a class<a class="anchor-link" href="#Add-a-class"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Create a class in <code>00_core.ipynb</code> as follows:</p>
<div class="highlight"><pre><span></span><span class="c1">#export</span>
<span class="k">class</span> <span class="nc">HelloSayer</span><span class="p">:</span>
<span class="s2">"Say hello to `to` using `say_hello`"</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span> <span class="o">=</span> <span class="n">to</span>
<span class="k">def</span> <span class="nf">say</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="s2">"Do the saying"</span>
<span class="k">return</span> <span class="n">say_hello</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="p">)</span>
</pre></div>
<p>This will automatically appear in the docs like this:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h2 id="HelloSayer" class="doc_header"><code>class</code> <code>HelloSayer</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/tutorial.py#L11" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>HelloSayer</code>(<strong><code>to</code></strong>)</p>
</blockquote>
<p>Say hello to <code>to</code> using <a href="/tutorial.html#say_hello"><code>say_hello</code></a></p>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Document-with-show_doc">Document with show_doc<a class="anchor-link" href="#Document-with-show_doc"> </a></h3>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>However, methods aren't automatically documented. To add method docs, use <a href="/showdoc.html#show_doc"><code>show_doc</code></a>:</p>
<div class="highlight"><pre><span></span><span class="n">show_doc</span><span class="p">(</span><span class="n">HelloSayer</span><span class="o">.</span><span class="n">say</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="HelloSayer.say" class="doc_header"><code>HelloSayer.say</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/tutorial.py#L15" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>HelloSayer.say</code>()</p>
</blockquote>
<p>Do the saying</p>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>And add some examples and/or tests:</p>
</div>
</div>
</div>
{% raw %}
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">o</span> <span class="o">=</span> <span class="n">HelloSayer</span><span class="p">(</span><span class="s2">"Alexis"</span><span class="p">)</span>
<span class="n">o</span><span class="o">.</span><span class="n">say</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_text output_subarea output_execute_result">
<pre>'Hello Alexis!'</pre>
</div>
</div>
</div>
</div>
</div>
{% endraw %}
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Add-links-with-backticks">Add links with backticks<a class="anchor-link" href="#Add-links-with-backticks"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Notice above there is a link from our new class documentation to our function. That's because we used backticks in the docstring:</p>
<div class="highlight"><pre><span></span><span class="s2">"Say hello to `to` using `say_hello`"</span>
</pre></div>
<p>These are automatically converted to hyperlinks wherever possible. For instance, here are hyperlinks to <a href="/tutorial.html#HelloSayer"><code>HelloSayer</code></a> and <a href="/tutorial.html#say_hello"><code>say_hello</code></a> created using backticks.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Set-up-autoreload">Set up autoreload<a class="anchor-link" href="#Set-up-autoreload"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Since you'll be often updating your modules from one notebook, and using them in another, it's helpful if your notebook automatically reads in the new modules as soon as the python file changes. To make this happen, just add these lines to the top of your notebook:</p>
<pre><code>%load_ext autoreload
%autoreload 2</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Add-in-notebook-export-cell">Add in-notebook export cell<a class="anchor-link" href="#Add-in-notebook-export-cell"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>It's helpful to be able to export all your modules directly from a notebook, rather than going to the terminal to do it. All nbdev commands are available directly from a notebook in Python. Add this line to any cell and run it to export your modules (I normally make this the last cell of my notebooks).</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">nbdev.export</span> <span class="kn">import</span> <span class="n">notebook2script</span><span class="p">;</span> <span class="n">notebook2script</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Run-tests-in-parallel">Run tests in parallel<a class="anchor-link" href="#Run-tests-in-parallel"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Before you push to github or make a release, you might want to run all your tests. nbdev can run all your notebooks in parallel to check for errors. Just run <a href="/test.html#nbdev_test_nbs"><code>nbdev_test_nbs</code></a> in a terminal.</p>
<pre><code>(base) jhoward@usf3:~/git/nbdev$ nbdev_test_nbs
testing: /home/jhoward/git/nbdev/nbs/00_core.ipynb
testing: /home/jhoward/git/nbdev/nbs/index.ipynb
All tests are passing!</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="View-docs-locally">View docs locally<a class="anchor-link" href="#View-docs-locally"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>If you want to look at your docs locally before you push to Github, you can do so by running a jekyll server. First, install Jekyll by <a href="https://jekyllrb.com/docs/installation/ubuntu/">following these steps</a>. Then, install the modules needed for serving nbdev docs by <code>cd</code>ing to the <code>docs</code> directory, and typing <code>bundle install</code>. Finally, cd back to your repo root and type <code>make docs_serve</code>. This will launch a server on port 4000 (by default) which you can connect to with your browser to view your docs.</p>
<p>If Github pages fails to build your docs, running locally with Jekyll is the easiest way to find out what the problem is.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Set-up-prerequisites">Set up prerequisites<a class="anchor-link" href="#Set-up-prerequisites"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>If your module requires other modules as dependencies, you can add those prerequisites to your <code>settings.ini</code> in the <code>requirements</code> section. The requirements should be separated by a space and if the module requires at least or at most a specific version of the requirement this may be specified here, too.</p>
<p>For example if your module requires the <code>fastcore</code> module of at least version 1.0.5, the <code>torchvision</code> module of at most version 0.7 and any version of <code>matplotlib</code>, then the prerequisites would look like this:</p>
<div class="highlight"><pre><span></span><span class="n">requirements</span> <span class="o">=</span> <span class="n">fastcore</span><span class="o">>=</span><span class="mf">1.0</span><span class="o">.</span><span class="mi">5</span> <span class="n">torchvision</span><span class="o"><</span><span class="mf">0.7</span> <span class="n">matplotlib</span>
</pre></div>
<p>In addition to <code>requirements</code> you can specify dependencies with other keywords that have different scopes. Below is a list of all possible dependency keywords:</p>
<ul>
<li><code>requirements</code>: Passed to both pip and conda setup</li>
<li><code>pip_requirements</code>: Passed to pip setup only</li>
<li><code>conda_requirements</code>: Passed to conda setup only</li>
<li><code>dev_requirements</code>: Passed to pip setup as a development requirement</li>
</ul>
<p>For more information about the format of dependencies, see the pyipi and conda docs on creating specifications in <a href="https://packaging.python.org/tutorials/packaging-projects/#creating-setup-py">setup.py</a> and <a href="https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html">meta.yaml</a>, respectively.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Set-up-console-scripts">Set up console scripts<a class="anchor-link" href="#Set-up-console-scripts"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Behind the scenes, nbdev uses that standard package <code>setuptools</code> for handling installation of modules. One very useful feature of <code>setuptools</code> is that it can automatically create <a href="https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point">cross-platform console scripts</a>. nbdev surfaces this functionality; to use it, use the same format as <code>setuptools</code>, with whitespace between each script definition (if you have more than one).</p>
<pre><code>console_scripts = nbdev_build_lib=nbdev.cli:nbdev_build_lib</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Test-with-editable-install">Test with editable install<a class="anchor-link" href="#Test-with-editable-install"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To test and use your modules in other projects, and use your console scripts (if you have any), the easiest approach is to use an <a href="http://codumentary.blogspot.com/2014/11/python-tip-of-year-pip-install-editable.html">editable install</a>. To do this, <code>cd</code> to the root of your repo in the terminal, and type:</p>
<pre><code>pip install -e .</code></pre>
<p>(Note that the trailing period is important.) Your module changes will be automatically picked up without reinstalling. If you add any additional console scripts, you will need to run this command again.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Upload-to-pypi">Upload to pypi<a class="anchor-link" href="#Upload-to-pypi"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>If you want people to be able to install your project by just typing <code>pip install your-project</code> then you need to upload it to <a href="https://pypi.org/">pypi</a>. The good news is, we've already created a fully pypi compliant installer for your project! So all you need to do is register at pypi (click "Register" on pypi) if you haven't previously done so, and then create a file called <code>~/.pypirc</code> with your login details. It should have these contents:</p>
<pre><code>[pypi]
username = your_pypi_username
password = your_pypi_password</code></pre>
<p>Another thing you will need is <code>twine</code>, so you should run once</p>
<pre><code>pip install twine</code></pre>
<p>To upload your project to pypi, just type <code>make pypi</code> in your project root directory. Once it's complete, a link to your project on pypi will be printed.</p>
<p><strong>NB</strong>: if you are not using the <code>make release</code> command to upload to both conda and pypi (described below), you must increment the version number in <code>settings.ini</code> each time you want to push a new release to pypi.</p>
<h2 id="Upload-to-pypi-and-conda-(recommended)">Upload to pypi and conda (recommended)<a class="anchor-link" href="#Upload-to-pypi-and-conda-(recommended)"> </a></h2><p>The command <code>make release</code> from the root of your nbdev repo will bump the version of your module and upload your project to both conda and pypi. We recommend this approach as it is the easiest way to publish packages.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Install-collapsible-headings-and-toc2">Install collapsible headings and toc2<a class="anchor-link" href="#Install-collapsible-headings-and-toc2"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>There are two jupyter notebook extensions that I highly recommend when working with projects like this. They are:</p>
<ul>
<li><a href="https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/collapsible_headings/readme.html">Collapsible headings</a>: This lets you fold and unfold each section in your notebook, based on its markdown headings. You can also hit <kbd>left</kbd> to go to the start of a section, and <kbd>right</kbd> to go to the end</li>
<li><a href="https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/toc2/README.html">TOC2</a>: This adds a table of contents to your notebooks, which you can navigate either with the <code>Navigate</code> menu item it adds to your notebooks, or the TOC sidebar it adds. These can be modified and/or hidden using its settings.</li>
</ul>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Math-equation-support">Math equation support<a class="anchor-link" href="#Math-equation-support"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>nbdev supports equations (we use the excellent <a href="https://katex.org/">KaTeX library</a>). Enable it with <code>use_math: true</code> in your <code>_config.yml</code> (it's enabled by default). You can include math in your notebook's documentation using the following methods.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Using <code>$$</code>, e.g.:</p>
<pre><code>{% raw %}
$$\sum_{i=1}^{k+1}i$$
{% endraw %}</code></pre>
<p>Which is rendered as:</p>
<blockquote>$$\sum_{i=1}^{k+1}i$$
</blockquote>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Using <code>$</code>, e.g.:</p>
<pre><code>This version is displayed inline: $\sum_{i=1}^{k+1}i$ . You can include text before and after.</code></pre>
<p>Which is rendered as:</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<blockquote><p>This version is displayed inline:$\sum_{i=1}^{k+1}i$ . You can include text before and after.</p>
</blockquote>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Custom-search-engine">Custom search engine<a class="anchor-link" href="#Custom-search-engine"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>For adding search to your docs site, nbdev supports <a href="https://cse.google.com/cse/all">Google Custom Search</a>, including auto-completion as you type your search query. You can try it out by using the search box at the top of this page.</p>
<p>Although we can't fully automate the creation of the search engine (since you need to login to Google to do it) we have made it very easy. Here are the steps you need to follow: <a href="https://nbdev.fast.ai/search">Setting up search</a>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Google-Colab-Badges">Google Colab Badges<a class="anchor-link" href="#Google-Colab-Badges"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Because both the documentation and code for nbdev is written in notebooks, you can optionally view and run nbdev documentation in <a href="https://colab.research.google.com/">Google Colab</a>. You can enable Google Colab badges that link to the appropriate notebook(s) in your GitHub repository.</p>
<p>You can toggle this feature on or off in your <code>/_config.yml</code> file:</p>
<div class="highlight"><pre><span></span><span class="c1"># This specifies what badges are turned on by default for notebook docs.</span>
<span class="nt">default_badges</span><span class="p">:</span>
<span class="nt">colab</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">true</span>
</pre></div>
<p>Furthermore, if you want to hide a badge on an individual document but still show badges elsewhere, you can set the front matter <code>hide_colab_badge: true</code>. For example, if you wanted to hide the Colab badge from showing up on the notebook <code>nbs/06_cli.ipynb</code>, your front matter (in the form of a markdown cell at the top of the notebook) will look like this:</p>
<pre><code># Command line functions
> Console commands added by the nbdev library
- hide_colab_badge:true</code></pre>
<p>Note how in the above example, the title <code>Command line functions</code> is formatted as a markdown heading and the summary <code>Console commands added by the nbdev library</code> is formatted as a markdown block quote. The additional option <code>hide_colab_badge</code> is a list item. It is important that this list item is separated from the summary by 2 newlines as shown above, in the same notebook markdown cell.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Look-at-nbdev-"source"-for-more-ideas">Look at nbdev "source" for more ideas<a class="anchor-link" href="#Look-at-nbdev-"source"-for-more-ideas"> </a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Don't forget that nbdev itself is written in nbdev! It's a good place to look to see how fast.ai uses it in practice, and get a few tips. You'll find the nbdev notebooks here in the <a href="https://github.com/fastai/nbdev/tree/master/nbs">nbs folder</a> on Github.</p>
</div>
</div>
</div>
</div>