[Solved] [nbdev] Issue with build_docs

Hi! I’m trying to build the documentation for my library and I have two issues:

  1. How do I build the documentation when I don’t want to run a particular notebook, just do it as-is
  • Reason: It requires google colab to even run, hence want to avoid that particular notebook
  1. When I do build_docs with this notebook, it will fail
------------------
show_doc(Learner.get_preds, default_cls_level=2)
------------------

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-6cef04df2e5a> in <module>
----> 1 show_doc(Learner.get_preds, default_cls_level=2)

NameError: name 'Learner' is not defined
NameError: name 'Learner' is not defined

converting: /media/mldata/fastai2/zach/fastinference/nbs/01_tabular_shap_interp.ipynb

Any ideas?

If you’re working with the latest, please git pull from master and try 2 again - I’m guessing you have the same problem as Questions on nbdev. If this doesn’t help, can you share the full nb so I can take a proper look.

For point 1

  • nbdev will ignore any file that starts with an underscore - is it an option to rename the file, build docs, then put the name back? not great I know )o:
  • You can do simple exclusions with glob. i.e. this will include all .ipynb files unless they start with 2 nbdev_build_docs --fname=[!2]*.ipynb
(nbdev-fork) ✔ ~/github/pete88b/decision_tree [master ↑·1|✚ 1…1⚑ 17] 
16:40 $ ls
000_target_module.ipynb             _99_interactive_demo.ipynb
001_exports_to_target_module.ipynb  CONTRIBUTING.md
002_target_module.ipynb             decision_tree
00_core.ipynb                       docs
10_data.ipynb                       index.ipynb
20_models.ipynb                     LICENSE
30_test_flag.ipynb                  Makefile
40_test_export.ipynb                MANIFEST.in
50_test_doc.ipynb                   nbdev_template
60_all_test.ipynb                   README.md
70_multi_all_test_flag.ipynb        settings.ini
70_multi_all_test_flag.txt          setup.py
71_tensor_patch.ipynb               test
(nbdev-fork) ✔ ~/github/pete88b/decision_tree [master ↑·1|✚ 1…1⚑ 17] 
16:40 $ touch *.ipynb
(nbdev-fork) ✔ ~/github/pete88b/decision_tree [master ↑·1|✚ 1…1⚑ 17] 
16:41 $ nbdev_build_docs --fname=[!2]*.ipynb
converting: 10_data.ipynb
converting: index.ipynb
converting: 002_target_module.ipynb
converting: 50_test_doc.ipynb
converting: 40_test_export.ipynb
converting: 00_core.ipynb
converting: 000_target_module.ipynb
converting: 70_multi_all_test_flag.ipynb
converting: 30_test_flag.ipynb
converting: 71_tensor_patch.ipynb
converting: _99_interactive_demo.ipynb
converting: 001_exports_to_target_module.ipynb
converting: 60_all_test.ipynb
converting /home/peter/github/pete88b/decision_tree/index.ipynb to README.md

1 Like

This seems like a valid option :slight_smile:

I’ll try that too! Thanks!

So I believe the main issue is they were @patch’s, I solved it by putting a #hide at the top of the problematic cells (in my case, this was perfectly okay)