使用 Mathematica Workbench 2.0 在教程和符号页面的干净会话中加载包
我正在使用 Workbench 为包开发文档。 到目前为止,我已经
Quit[]
Needs["mypackage`"]
在每个教程的开头使用过。这是因为我想要一个干净的全局环境并同时加载包。
我运行了一些构建,一切都按预期工作,但我想知道:是否有更好的方法来拥有一个干净的全局上下文,并且每次使用 MMA 为我的包启动教程时“自动”加载包上下文?
换句话说:从一个教程到下一个教程,或者从教程回到常规 MMA 笔记本,教程示例中定义的所有符号是否有可能被“遗忘”?在标准 MMA 教程页面中,似乎就是这样发生的。
我想这可以在本地/笔记本上下文中完成。
但这在实践中如何运作呢?
感谢您的帮助
I am developing documentation for a package with Workbench.
So far I have used
Quit[]
Needs["mypackage`"]
at the beginning of each Tutorial. This is because I want a clean global environment and package loading at the same time.
I ran some builds and everything worked as expected, but I wonder: is there a better way to have a clean global context and the package context load "automatically" each time a launch a tutorial for my package with MMA?
In other words: going from one tutorial to the next, or from a tutorial back to a regular MMA notebook, is it possible that all symbols defined in the tutorial examples be "forgotten"? In the standard MMA tutorial pages, this is what seems to happen.
I suppose this could be done this a local/notebook context.
But how would this work in practice?
Thank you for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于每个教程,选择菜单项评估>笔记本的默认上下文>此笔记本独有的。这将使每个笔记本都有一个新的、独特的背景。因此,您不需要
Quit[]
(这似乎是一个相当激烈的方法。)可能有几种方法可以确保Needs
单元格运行,但将其作为初始化单元可能是最简单的。For each tutorial, choose the menu item Evaluation > Notebook's Default Context > Unique to this Notebook. This will make each notebook have a new, unique, context. So then you don't need the
Quit[]
(which seems like a pretty drastic method.) There are probably a few ways you could make sure theNeeds
cell is run, but making it an initialization cell is probably the easiest.