Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify multiple directories in nbs_path or exclude certain subdirectories #1395

Open
mattgra opened this issue Feb 1, 2024 · 3 comments
Open

Comments

@mattgra
Copy link

mattgra commented Feb 1, 2024

I would like to build nbdev docs (nb: docs only, no lib code) based on multiple subfolders - the pattern is as follows:

repo_root
└ nbs_dir
	├ sub-directory1
	│	├ core/
	│	└ tutorials/nbs/...  # here are the tutorials!
	├ sub-directory2
	│	├ core/
	│	└ tutorials/nbs/...  # here are the tutorials!
	└ sub-directory3
		├ core/
		└ tutorials/nbs/...  # here are the tutorials!

Thus, I'd like to specify my nbs_path in settings.ini either as follows:

Option 1

# settings.ini
nbs_path = nbs_dir/sub-directory1/tutorials, nbs_dir/sub-directory2/tutorials, nbs_dir/sub-directory3/tutorials

Option 2

# settings.ini
nbs_path = nbs_dir
exclude_pattern = nbs_dir/*/core/

Additional context:

sub-dir1/2/3 are submodules from external libraries which have their own lib code and nbdev tutorials.
This repo would only serve as synced, centralised point to access all tutorials in a single build.

@deven367
Copy link
Contributor

deven367 commented Feb 2, 2024

Hey @mattgra, if I understand your requirement correctly, this is already possible in nbdev.

To create tutorials, (do NOT add the #|default_exp flag to your nb). You can check the nbdev repo for this.
image

Then to update the sidebar, you can manually edit the _quarto.yml file to get your desired sidebar configuration.

@mattgra
Copy link
Author

mattgra commented Feb 2, 2024

Not sure i fully understand this solution.
In the repo you are showing the settings.ini still points to the nbs folder only. (https://github.com/fastai/nbdev/blob/master/settings.ini)
nbdev then recursively goes through all the folders inside nbs and generates the docs (i.e., also for the explanations, tutorials, and API folders. (see here: https://nbdev.fast.ai/api)
image

@deven367
Copy link
Contributor

deven367 commented Feb 2, 2024

Yes, that's correct. nbdev recursively goes through the notebooks in the nbs folder. The part where the notebooks differ in the api folder vs the tutorials folder is over here.

When the #|default_exp flag is missing in a notebook, no python file is created for it, and it is rendered by nbdev as docs.

API notebook
image

Tutorials nb
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants