Clean-up older files after renaming notebook

Hi all,

Is there any way to clean up the generated docs and lib py code for renamed notebooks?

For example, renaming the template 00_core.ipynb to something else will leave a core.html and core.py in the output folders.

Am I missing something obvious?
Is there a way to clean it up more automatically?

Thanks

1 Like

I have been cleaning it up manually and had the same question. I suppose one could write a script that uses nbdev_diff_nbs to spot the modules that do not come from an export.

If you’re working on Windows, do keep in mind that nbdev_diff_nbs doesn’t work so you would need to write your own Powershell or CmdLet script from scratch.

1 Like

I’m on macOS and Linux :wink:.

It would be really nice to have this as part of the build, maybe it could ask before deleting, but suggesting would be great.

EDIT: @jeremy is this a feature coming in the next version?

1 Like

It should work to delete the contents of the docs/ and the library folders. nbdev will regenerate them from scratch, just like the first time.

1 Like

It’s not really possible to do safely. We have no way to know which files you auto-generated with some older file and no longer want to keep, vs which ones are files you’ve created manually and do want to keep.

As long as you haven’t manually added any docs or modules to them, of course!

1 Like

Thanks! I created a command to do both a clean (delete) + build. I don’t usually place manually created files in those folders as @Jeremy mentioned

Yes, I see what you mean.

The first thing that occurred that could work was to look at the comment in the first line, where it mentions it’s generated.
It would likely make the implementation slower and more convoluted, but could be an interesting separate command for clean up?

EDIT: I understand how this may not be a good practice :wink: sharing just for brainstorming/discussing.
EDIT2: To clarify, I am not suggesting deleting without prompt, just an extra check/reminder that could help keep the library clean

2 Likes

Thats actually not a half bad idea i think…

1 Like