Skip to main content

front end - How to make a parallel auto-generated .m package from Initialization cells?


according to the documentation at ref/InitializationCell,



When you first save a notebook that contains initialization cells, you have the option to make a parallel auto-generated .m package that contains only the contents of the initialization cells. The package is by default automatically updated whenever the initialization cells in the notebook are changed and saved again.



This would be a REALLY NICE feature, because it would give me a beautiful way to document a package in a notebook (instead of just textual code)!


To test it out, I took the documentation a bit literally and created a new notebook with a single initialization cell (with the little vertical-hook cell-bracket initialization-cell giveaway highlighted in yellow and circled in red in the screenshot, here:



enter image description here


The cell after the initialization cell is supposed to be just a reference to the initialization cell, and, when I evaluate the notebook, voila, there is the expected value.


However, when I now save the notebook, I don't get the advertised "option to make a parallel auto-generated .m package." Ok, so I make one manually (Save As.../Save As Type.../Mathematica Package .m), no problem, as follows:


enter image description here


But, of course, this one is not "automatically updated whenever the initialization cells in the notebook are changed and saved again." Here's the updated notebook:


enter image description here


but the .m file is not automatically updated. I would use this feature daily if I could get it to work. As always, I'll be very grateful for advice, guidance, clues.



Answer



This may be set from the Option Inspector (Format->Option Inspector) from this option:


enter image description here



Automatic automatically creates a package.


(to be clear, you need to select Global Preferences for this to apply to all your notebooks).


Comments