Generating docs when source and notebooks are in different folders

I am not able to run nbdev_build_docs in windows if notebooks and lib both are in subfolders (.\notebooks and .\src)

# Change to, e.g. "nbs", to put your notebooks in nbs dir instead of repo root
nbs_path = notebooks
doc_path = docs

# Anything shown as '%(...)s' is substituted with that setting automatically
url = /
doc_host = %(url)s 
doc_baseurl = /%(lib_name)s 
git_url = https://gitlab.com/%(user)s/%(lib_name)s/tree/%(branch)s/
lib_path = ./src/%(lib_name)s
title = %(lib_name)s

error is always the same

(base) D:\dev\nbdev>nbdev_build_docs
converting: D:\dev\nbdev\notebooks\index.ipynb
'D:\\dev\\nbdev\\notebooks\\index.ipynb' does not start with 'D:\\dev\\nbdev\\src'
Traceback (most recent call last):
  File "c:\users\z003yeph\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "c:\users\z003yeph\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "C:\Users\z003yeph\AppData\Local\Continuum\anaconda3\Scripts\nbdev_build_docs.exe\__main__.py", line 7, in <module>
  File "c:\users\z003yeph\appdata\local\continuum\anaconda3\lib\site-packages\fastscript\core.py", line 76, in _f
func(**args.__dict__)
  File "c:\users\z003yeph\appdata\local\continuum\anaconda3\lib\site-packages\nbdev\cli.py", line 219, in nbdev_build_docs
notebook2html(fname=fname, force_all=force_all, n_workers=n_workers)
  File "c:\users\z003yeph\appdata\local\continuum\anaconda3\lib\site-packages\nbdev\export2html.py", line 579, in notebook2html
raise Exception(msg + '\n'.join([f.name for p,f in zip(passed,files) if not p]))
Exception: Conversion failed on the following:
index.ipynb

tried symbolic links and junctions as described here (https://github.com/fastai/nbdev/issues/197), but still not working under windows. any ideas?

Can you share your repo?

the only way to run nbdev_build_docs is when setting back the lib_path to the project root:
lib_path = %(lib_name)s
and create a symbolic link into the src/my_lib folder

1 Like

I’m not sure if the nbdev project cares much about what the PyPA recommends, but maybe a user should be warned in the docs that the “officially” motivated (= by the PyPA) src-layout structure is not supported by nbdev?