nbautoexport icon indicating copy to clipboard operation
nbautoexport copied to clipboard

Document examples of use with GNU make

Open jayqi opened this issue 4 years ago • 2 comments

From @cccntu, originally mentioned here

I also tried the export command, but found they always exports every files. Maybe we can check the modified time and only export the necessary files? (like in Make) So user can add this command in Makefile without generating all the files each time. And add a flag to force regenerating everything.

jayqi avatar Jan 11 '21 18:01 jayqi

@cccntu One thing to note that might be helpful (though it doesn't address the feature request itself): if the path you specify is to one notebook file (instead of a directory), it will only export that notebook. So in cases where you know a priori which notebook you want to export, this can save you some unneeded computation.

EDIT: Although now that I think about this, potentially you can just use make directly, with recipes that use the export command that points to a single file. Let us know if this works!

jayqi avatar Jan 11 '21 18:01 jayqi

@jayqi Thanks for the suggestion, I did not know about that.

I was gonna say it would be too much work to add every file to Makefile, then I remembered that you can use wildcard in Makefile. Though it took me some time to figure it out, I got it working! Here are the lines I added in my Makefile.

nb:$(patsubst notebooks/%.ipynb, notebooks/script/%.py, $(wildcard notebooks/*.ipynb))
notebooks/script/%.py : notebooks/%.ipynb
        nbautoexport export $?

run make nb

cccntu avatar Jan 12 '21 02:01 cccntu