nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

nbdev with non-flat layout

Open ericct opened this issue 5 years ago • 3 comments

Hello,

First, thanks for this great work!

Not sure it's a bug or something I'm doing wrong.

I'd like to use nbdev but with a different layout, mainly for inclusion with existing projects, but I'm having an issue. In order to reproduce this, I've just made a simple template here. The template is in master branch and a dummy instantiation is in test/instantiated. Basically:

  • notebooks are under notebooks folder
  • generated code will go into src
  • generated docs will go into docs (all these from the project root) notebooks/settings.ini is changed to reflect this:
doc_path = ../docs
...
lib_path = ../src/%(lib_name)s

nbdev_build_lib seems to work OK, but nbdev_build_docs is misled by the layout:

converting: /home/eric/nbdev_alt_template/nbdev/index.ipynb
'/home/eric/nbdev_alt_template/nbdev/index.ipynb' does not start with '/home/eric/nbdev_alt_template/nbdev/../src'
converting: /home/eric/nbdev_alt_template/nbdev/00_core.ipynb
'/home/eric/nbdev_alt_template/nbdev/00_core.ipynb' does not start with '/home/eric/nbdev_alt_template/nbdev/../src'

So, is the behavior intended?

Thanks!

ericct avatar Mar 02 '21 17:03 ericct

Instead of trying to use relative paths ../* in settings.ini which appear to be breaking, perhaps use a symlink instead.

For example, we are using the symlink ghtop in this repo to accomplish the same goal you are trying to achieve. (In that particular example we have the docs and the library in separate repos)

Hope that helps, thanks. cc: @jph00

hamelsmu avatar Mar 08 '21 06:03 hamelsmu

Hello,

Sure, symlink would indeed hide this issue to nbdev. But it seems that nbdev supports relative path "downwards", so maybe it should support also ../* or any valid path expression. If you do agree, this should be considered as a bug and keep it open then.

I will try to get a fix for that. My understanding is that nbdev is checking that the relative path can be attained. It does so using string prefix, but we may do the same traversing the parent chain until we find the other path (or not => not attainable).

ericct avatar Mar 08 '21 17:03 ericct

Also, would propose a (better?) name for the issue "upward relative paths non supported in settings.ini".

ericct avatar Mar 08 '21 17:03 ericct