Wolfram mathematica 在Mathematica的新版本中制作版本5的旧文档的工作副本
在Mathematica的新版本中,我们有。但是版本5的遗留文档不包括在Mathematica的新版本中。此遗留文档仅占用209МB的磁盘空间,从Mathematica的新版本中访问它将非常有用 在同一台机器上安装Mathematica 5.2和Mathematica 7或8后,如何通过老式的帮助浏览器从新版本中访问旧文档 我试图从中复制文档文件夹Wolfram mathematica 在Mathematica的新版本中制作版本5的旧文档的工作副本,wolfram-mathematica,mathematica-frontend,Wolfram Mathematica,Mathematica Frontend,在Mathematica的新版本中,我们有。但是版本5的遗留文档不包括在Mathematica的新版本中。此遗留文档仅占用209МB的磁盘空间,从Mathematica的新版本中访问它将非常有用 在同一台机器上安装Mathematica 5.2和Mathematica 7或8后,如何通过老式的帮助浏览器从新版本中访问旧文档 我试图从中复制文档文件夹 C:\Program Files\Wolfram Research\Mathematica\5.2\Documentation 到 旧版帮助浏览器
C:\Program Files\Wolfram Research\Mathematica\5.2\Documentation
到
旧版帮助浏览器的内部现在显示“帮助浏览器”作为一个插件。但它不能正常工作
可以找到一些有关在Mathematica 5中调整帮助浏览器外观的有用信息。但我不知道如何将此应用于Mathematica的新版本。警告:我最近了解到,为新文档建立索引可能会在windows计算机中产生不期望的效果。请阅读Alexey的评论以了解更多细节。据我所知,在MacOSX中一切都很正常。一旦我确定问题的根源,我会给出一个更新 这里我提供了一个函数,允许任何笔记本成为Mathematica 8中文档中心的一部分。您可以让Mathematica评估以下内容:
Clear[FormatDoc, AddDocs];
FormatDoc[dir_, last_, num_, appName_, pacFile_, index_] :=
Module[{dirs, nbs, nb, str, comma = ",", title, tags},
nbs = FileNames[dir <> "/*.nb"];
dirs = FileNames[dir <> "/*"];
Do[If[last && i == Length@nbs, comma = ""];
str = FileNameDrop[nbs[[i]], {1, num}];
title = StringDrop[FileNameTake[nbs[[i]]], -3];
Print[Row[{Style["Adding: ", "MSG", Black],
Style[str, "MSG", Blue]}]];
str = StringDrop[str, -3];
WriteString[pacFile,
"\t\t\t\t\"" <> str <> "\"" <> comma <> "\n"];
nb = NotebookOpen[nbs[[i]]];
tags =
DeleteDuplicates@
Flatten@Map[#[[2]] &,
Cases[NotebookGet[
nb], (_Dummy | (CellTags -> _)), \[Infinity]]];
SetOptions[nb,
DockedCells ->
FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"],
Saveable -> False,
WindowTitle ->
"Mathematica 5.2 | " <> FileNameDrop[str] <> " | " <> title,
TaggingRules -> {"ModificationHighlight" -> False,
"Metadata" -> {"context" -> appName <> "`", "keywords" -> tags,
"index" -> True,
"label" -> "Mathematica 5.2 | " <> FileNameDrop[str],
"language" -> "en", "paclet" -> appName, "status" -> "",
"summary" -> ToString@tags, "synonyms" -> {},
"title" -> title, "windowtitle" -> title, "type" -> "Doc",
"uri" ->
StringReplace[FileNameJoin[{appName, str}], "\\" -> "/"]},
"SearchTextTranslated" -> "", "LinkTrails" -> ""}];
NotebookSave[nb];
NotebookClose[nb];
DocumentationSearch`AddDocumentationNotebook[index, nbs[[i]]];, {i,
Length@nbs}];
Do[If[DirectoryQ[dirs[[i]]], str = FileNameDrop[dirs[[i]], {1, num}];
Print[
Row[{Style["Adding from: ", "MSG", Black],
Style[str, "MSG", Gray]}]];
FormatDoc[dirs[[i]], last, num, appName, pacFile, index];], {i,
Length@dirs}]]
AddDocs[appName_] :=
Module[{appDir, appDocs, dirs, pacFile, index, indexDir, str, num},
appDir = FileNameJoin[{$UserBaseDirectory, "Applications"}];
appDocs =
FileNameJoin[{appDir, appName, "Documentation", "English"}];
indexDir = FileNameJoin[{appDocs, "Index"}];
dirs = FileNames[appDocs <> "/*"];
If[Length@dirs == 0,
Print[Style["There are no documents to add... ", "MSG", Orange]];
Return[]];
Print[Row[{Style["Working in: ", "MSG", Black],
Style[appDocs, "MSG", Red]}]];
num = Length@FileNameSplit[appDocs];
index =
DocumentationSearch`NewDocumentationNotebookIndexer[indexDir];
pacFile = OpenWrite[FileNameJoin[{appDir, appName, "PacletInfo.m"}]];
WriteString[pacFile, "Paclet[
Name -> \"" <> appName <> "\",
Version -> \"5.2.0\",
MathematicaVersion -> \"7+\",
Extensions -> {
{
\"Kernel\",
\"Context\" -> {
}
},
{
\"Documentation\",
Language -> \"English\",
LinkBase -> \"" <> appName <> "\",
Resources -> {\n"];
Do[If[DirectoryQ[dirs[[i]]], str = FileNameDrop[dirs[[i]], {1, num}];
Print[
Row[{Style["Adding from: ", "MSG", Black],
Style[str, "MSG", Gray]}]];
FormatDoc[dirs[[i]], i == Length@dirs, num, appName, pacFile,
index];], {i, Length@dirs}];
WriteString[pacFile, "\t\t\t}
}
}
]\n"];
Close[pacFile];
DocumentationSearch`CloseDocumentationNotebookIndexer[index];
PacletManager`RestartPacletManager[];]
在我的例子中,由于我使用Mac OS X,我得到:
/Users/jmlopez/Library/Mathematica
找出你的是什么。在此目录中,您应该可以看到文件夹应用程序
。在应用程序内部
创建将放置MMA5文档的文件夹。我把我的文件夹命名为MMA5
,因为它很短,但你可以给它取任何你想要的名字,对于Alexey,我们可以称它为LegacyDocumentation
。在此文件夹内,传输MMA5安装目录中名为Documentation
的文件夹副本
我们差不多完成了。现在调用函数AddDocs
。此函数只接受一个参数:我们希望添加其文档的应用程序的名称。在我的例子中,由于我将文件夹命名为MMA5
,因此我将其命名如下:
AddDocs["MMA5"]
@@resource HelpBrowserSetup
HelpDirectoryListing[SystemHelpPath, False, True, True]
接下来你应该看到的是一系列笔记本的出现和消失,以及一系列正在打印的信息。以下是该消息序列的一部分:
由于MMA5的文档非常广泛,因此此过程需要一段时间。我对这个函数进行了计时,它说大约需要40秒(对我来说似乎要长得多)
你完了。MMA5的文档现在应该可以在文档中心获得
试驾
假设您希望在DSolve
上查找一些信息。如果搜索DSolve
,将看到以下内容:
Clear[FormatDoc, AddDocs];
FormatDoc[dir_, last_, num_, appName_, pacFile_, index_] :=
Module[{dirs, nbs, nb, str, comma = ",", title, tags},
nbs = FileNames[dir <> "/*.nb"];
dirs = FileNames[dir <> "/*"];
Do[If[last && i == Length@nbs, comma = ""];
str = FileNameDrop[nbs[[i]], {1, num}];
title = StringDrop[FileNameTake[nbs[[i]]], -3];
Print[Row[{Style["Adding: ", "MSG", Black],
Style[str, "MSG", Blue]}]];
str = StringDrop[str, -3];
WriteString[pacFile,
"\t\t\t\t\"" <> str <> "\"" <> comma <> "\n"];
nb = NotebookOpen[nbs[[i]]];
tags =
DeleteDuplicates@
Flatten@Map[#[[2]] &,
Cases[NotebookGet[
nb], (_Dummy | (CellTags -> _)), \[Infinity]]];
SetOptions[nb,
DockedCells ->
FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"],
Saveable -> False,
WindowTitle ->
"Mathematica 5.2 | " <> FileNameDrop[str] <> " | " <> title,
TaggingRules -> {"ModificationHighlight" -> False,
"Metadata" -> {"context" -> appName <> "`", "keywords" -> tags,
"index" -> True,
"label" -> "Mathematica 5.2 | " <> FileNameDrop[str],
"language" -> "en", "paclet" -> appName, "status" -> "",
"summary" -> ToString@tags, "synonyms" -> {},
"title" -> title, "windowtitle" -> title, "type" -> "Doc",
"uri" ->
StringReplace[FileNameJoin[{appName, str}], "\\" -> "/"]},
"SearchTextTranslated" -> "", "LinkTrails" -> ""}];
NotebookSave[nb];
NotebookClose[nb];
DocumentationSearch`AddDocumentationNotebook[index, nbs[[i]]];, {i,
Length@nbs}];
Do[If[DirectoryQ[dirs[[i]]], str = FileNameDrop[dirs[[i]], {1, num}];
Print[
Row[{Style["Adding from: ", "MSG", Black],
Style[str, "MSG", Gray]}]];
FormatDoc[dirs[[i]], last, num, appName, pacFile, index];], {i,
Length@dirs}]]
AddDocs[appName_] :=
Module[{appDir, appDocs, dirs, pacFile, index, indexDir, str, num},
appDir = FileNameJoin[{$UserBaseDirectory, "Applications"}];
appDocs =
FileNameJoin[{appDir, appName, "Documentation", "English"}];
indexDir = FileNameJoin[{appDocs, "Index"}];
dirs = FileNames[appDocs <> "/*"];
If[Length@dirs == 0,
Print[Style["There are no documents to add... ", "MSG", Orange]];
Return[]];
Print[Row[{Style["Working in: ", "MSG", Black],
Style[appDocs, "MSG", Red]}]];
num = Length@FileNameSplit[appDocs];
index =
DocumentationSearch`NewDocumentationNotebookIndexer[indexDir];
pacFile = OpenWrite[FileNameJoin[{appDir, appName, "PacletInfo.m"}]];
WriteString[pacFile, "Paclet[
Name -> \"" <> appName <> "\",
Version -> \"5.2.0\",
MathematicaVersion -> \"7+\",
Extensions -> {
{
\"Kernel\",
\"Context\" -> {
}
},
{
\"Documentation\",
Language -> \"English\",
LinkBase -> \"" <> appName <> "\",
Resources -> {\n"];
Do[If[DirectoryQ[dirs[[i]]], str = FileNameDrop[dirs[[i]], {1, num}];
Print[
Row[{Style["Adding from: ", "MSG", Black],
Style[str, "MSG", Gray]}]];
FormatDoc[dirs[[i]], i == Length@dirs, num, appName, pacFile,
index];], {i, Length@dirs}];
WriteString[pacFile, "\t\t\t}
}
}
]\n"];
Close[pacFile];
DocumentationSearch`CloseDocumentationNotebookIndexer[index];
PacletManager`RestartPacletManager[];]
要查找MMA5文档,我们需要单击位于“搜索包含DSolve的所有页面”中的DSolve
链接。现在我们得到如下结果:
在上面的截图中,我用红色标记了允许我们访问Mathematica 5文档的条目。我没有办法为文档中的每个文件编写一个好的摘要,所以我让Mathematica编写笔记本中的CellTags
。这就是为什么会看到字符串列表
如果你点击第一个红色条目,这就是我们得到的
现在你有了它,一份关于Mathematica新版本的遗留文档的工作副本。我没有在MMA7中测试过这个,但我感觉它会起作用。如果有人尝试这个,请让我知道
笔记
如果要将此应用于其他应用程序中的其他文档。您需要注意以下几点:
WindowTitle ->
"Mathematica 5.2 | " <> FileNameDrop[str] <> " | " <> title,
TaggingRules -> {
"ModificationHighlight" -> False,
"Metadata" -> {
"context" -> appName <> "`",
"keywords" -> tags,
"index" -> True,
"label" -> "Mathematica 5.2 | " <> FileNameDrop[str],
"language" -> "en",
"paclet" -> appName,
"status" -> "",
"summary" -> ToString@tags,
"synonyms" -> {},
"title" -> title,
"windowtitle" -> title,
"type" -> "Doc",
"uri" ->
StringReplace[FileNameJoin[{appName, str}], "\\" -> "/"]
},
WindowTitle->
“Mathematica 5.2 |”文件名删除[str]“|”标题,
标记规则->{
“ModificationHighlight”->False,
“元数据”->{
“上下文”->appName“`”,
“关键词”->标签,
“索引”->正确,
“标签”->“Mathematica 5.2 |”文件名删除[str],
“语言”->“英语”,
“paclet”->appName,
“状态”->”,
“摘要”->ToString@tags,
“同义词”->{},
“标题”->标题,
“windowtitle”->标题,
“类型”->“单据”,
“uri”->
StringReplace[FileNameJoin[{appName,str}],“\\\”->“/”]
},
请注意,我在标签中硬编码了“Mathematica 5.2”。如果您愿意,您甚至可以将其更改为“LegacyDocumentation”。这只是一个标签。另一个重要的点是
关键字
。我已将关键字
设置为变量标记
。笔记本中的每个单元格都可以选择添加单元格标记
。如果您要编写一些文档,您应该使用它们。我利用这一点让文档中心知道如何搜索文档。这是一件了不起的事情我最近刚刚学到,我一定会在一个包中实现
如果你想写一个完整的应用程序及其文档,我建议你看看我的帖子。在这里你会发现更多的信息,让你了解我在这里提供的功能是如何工作的
作为最后一点,我想补充一点,我也在windows机器上测试过,它运行良好,这就是这行代码背后的原因:
StringReplace[FileNameJoin[{appName,str}],“\\\”->“/”]
编辑:
我更改了函数,使其能够在MMA7中正确工作。结果表明,pacletInfo.m
文件需要有行MathematicaVersion->7+
,才能在MMA7和MMA8中工作
编辑2:
我在复制和粘贴函数时出错。现在应该修复它。如果您同时拥有MMA7和MMA8,我建议在MMA7中只运行一次。这样,MMA7和MMA8都可以使用文档
C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\FrontEnd\TextResources
@@resource HelpBrowserSetup
BrowserCategory["Help Browser", None, {
HelpDirectoryListing[{"RefGuide"}, False],
HelpDirectoryListing[{"AddOns"}, False],
HelpDirectoryListing[{"MainBook"}, False],
HelpDirectoryListing[{"OtherInformation"}, False],
HelpDirectoryListing[{"GettingStarted"}, False],
HelpDirectoryListing[{"Tour"}, False],
HelpDirectoryListing[{"Demos"}, False],
BrowserCategory["Master Index", None, {HelpMasterIndex[]}]
}]
C:\Documents and Settings\All Users\Application Data\Mathematica
FrontEndTokenExecute["HelpDialog"]
@@resource HelpBrowserSetup
HelpDirectoryListing[SystemHelpPath, False, True, True]
SetOptions[$FrontEnd,
SystemHelpPath ->
Union[SystemHelpPath /.
Options[$FrontEnd,
SystemHelpPath], {"C:/Program Files/Wolfram \
Research/Mathematica/5.2/"}]]
@@resource HelpBrowserSetup
HelpDirectoryListing[{"C:/Program Files/Wolfram Research/Mathematica/5.2/"}, False, True, True]
FrontEndTokenExecute["RebuildHelpIndex"]
FrontEndTokenExecute["HelpDialog"]
HelpMenu["&Help",
{
MenuItem["Documentation &Center", "OpenHelpLink"],
MenuItem["Help Browser...", "HelpDialog"],