Making a working copy of the legacy documentation for version 5 inside new versions of Mathematica
Asked Answered
T

2

9

In new versions of Mathematica we have fully functional old-fashioned Mathematica Help Browser. But the legacy documentation of version 5 is not included in new versions of Mathematica. This legacy documentation takes only 209 МB of disk space and it would be useful to have it accessible from within the new versions of Mathematica.

Having Mathematica 5.2 and Mathematica 7 or 8 installed on the same machine, how can one make the legacy documentation accessible from within a new version through the old-fashioned Help Browser?

I tried to copy the Documentation folder from

C:\Program Files\Wolfram Research\Mathematica\5.2\Documentation

to

C:\Documents and Settings\All Users\Application Data\Mathematica\Application\LegacyDocumenation

and inside of the legacy Help Browser now appear "Help Browser" as an AddOn. But it does not work properly.

Some useful information on tuning the appearance of the Help Browser in Mathematica 5 can be found here. But I do not know how to apply this to new versions of Mathematica.

Translocate answered 25/4, 2011 at 15:12 Comment(9)
I don't have 5.2 installed and I have never tried something like this, so I cannot help, but +10 pts closer to edit privilege. ;-)Flaxen
@Flaxen After the release of version 6, many people complained about the new documentation center, and pointed to the advantages of the preceding. I myself still occasionally can easily find in the documentation for version 5, the answers to those questions for which I fail to find the answer in the documentation for the new versions. So it's not an idle question. It would be just wonderful to combine the advantages of two quite different ways of navigating the documentation...Translocate
Did you ever find out how to do this? I don't have the MMA5 much less the documentation but I'm assuming they are notebooks. If this is the case I think I know how to marge the documentation with MMA8.Gabi
@Gabi Yes, the MMa5 documentation consists of version 5 notebooks and "BrowserCategories.m" files. The main difference from the newer documentation is that in version 5 documentation for a different functions is assembled in one notebook. For example, 19Mb notebook "RefGuide.nb" contains documentation for the all main built-in functions.Translocate
So you can actually read the documentation for each function from MMa5 in the Documentation Center for MMa8? I really wish I could have MMa5 just to try it out.Gabi
@Gabi No, the Documentation Center uses another format of documentation. But new versions of MMa have working copy of old "Mathematica Help Browser" from version 5 for compatibility with packages developed for older versions of MMa. This Help Browser can read and display legacy documentation. The only problem is that it is tuned in some awkward way in new versions and cannot simply accept the legacy documentation if we just copy it to the "Documentation" folder of new version of MMa.Translocate
Oh, I thought you were able to access the documentation from there. In any case, it is possible to integrate the notebooks from the MMa5 Documentation to the new doc center. This requires you do a slight modification to the options of the documentation notebook (this however can be done with a script). Do you know any place where I can find a sample documentation notebook to check what it is required to integrate it?Gabi
@Gabi I can put an example notebook on a file hosting like rapidshare.com or any other you like. But the entire documentation for version 5 one may get for free since free 30-day trial version of Mathenatica 5.2 is still available on the Internet.Translocate
@AlexeyPopkov let us continue this discussion in chatGabi
T
7

The solution

Incidentally I have found the way to add all Mathematica 5.2 documentation to the legacy Help Browser in new versions of Mathematica.

The key is the "HelpBrowserSetup.tr" file located in the directory (under Windows)

C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\FrontEnd\TextResources

One should replace its contents with:

@@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[]}]
}]

Then, the "Documentation" folder from the $InstallationDirectory of Mathematica 5.2 should be copied to the $InstallationDirectory of new version of Mathematica with replacement (one unimportant file will be replaced). Another possibility is to copy it to directory (under Windows)

C:\Documents and Settings\All Users\Application Data\Mathematica

(probably the $UserBaseDirectory is also appropriate).

Now start Mathematica and evaluate

FrontEndTokenExecute["HelpDialog"]

The legacy Help Browser will open and will contain all the documentation from the version 5.2!

screenshot

Edit

I just have found even simpler solution. One may modify the "HelpBrowserSetup.tr" file as follows:

@@resource HelpBrowserSetup
HelpDirectoryListing[SystemHelpPath, False, True, True]

(or simply copy with replacement this file from the version 5.2 installation to the new version's folder).

Addition for those who have Mathematica 5.2 installed

You need not to copy the Documentation. You have two possibilities:

1.) Copy only the "HelpBrowserSetup.tr" file from the version 5.2 installation to new version's folder. Then evaluate something like

SetOptions[$FrontEnd, 
 SystemHelpPath -> 
  Union[SystemHelpPath /. 
    Options[$FrontEnd, 
     SystemHelpPath], {"C:/Program Files/Wolfram \
Research/Mathematica/5.2/"}]]

(where "C:/Program Files/Wolfram Research/Mathematica/5.2/" is the $InstallationDirectory of Mathematica 5.2).

2.) Just modify the "HelpBrowserSetup.tr" file as follows (but in this case all installed pre-version 6 Add-Ons will not appear in the legacy Help Browser):

@@resource HelpBrowserSetup
HelpDirectoryListing[{"C:/Program Files/Wolfram Research/Mathematica/5.2/"}, False, True, True]

and then evaluate

FrontEndTokenExecute["RebuildHelpIndex"]
FrontEndTokenExecute["HelpDialog"]

P.S. Adding Help Browser item to the Help menu

For this we just need to add row MenuItem["Help Browser...", "HelpDialog"], in appropriate place in MenuSetup.tr:

HelpMenu["&Help", 
{
    MenuItem["Documentation &Center", "OpenHelpLink"],
    MenuItem["Help Browser...", "HelpDialog"],

screenshot

Translocate answered 1/8, 2011 at 4:56 Comment(11)
How did you find out where to place the documentation? I can't get it to read it in Mac OS X. I have the path /Users/jmlopez/Library/Mathematica/ApplicationData. I created a directory Mathematica there and placed the documentation there but when I run the command you mentioned the help browser shows up with nothing.Gabi
@Gabi I just found that it is sufficient to copy legacy Documentation folder into Documentation folder of new Mathematica (just to consolidate them).Translocate
I copied the folders AddsOns and the rest from Documentation/English into the main directory of MMA8 but that didn't seem to have any effect.Gabi
By main directory of MMA8 I mean the documentation folder of MMA8.Gabi
@Gabi Have you copied it exactly from Documentation/English of MMa 5.2 to Documentation/English of 8.0?Translocate
That is exactly what I did. There is one thing I also did, I changed the HelpBrowserSetup.tr file you mentioned. Do I need to revert it back? I'll give it a try.Gabi
@Gabi See Edit section in my answer for an alternative.Translocate
Actually, I reverted back to the original contents of the HelpBrowserSetup.tr and something started to happen. It started building the index. This however was taking too long and at some point Mathematica crashed. Right now I changed it to what you mentioned on your edit. I'll report once it finishes.Gabi
@Gabi I forgot to mention one thing. When you experiment with the HelpBrowserSetup.tr file DO NOT create a copy of the original file with similar name in the same directory! For some reason Mathematica searches not exactly for "HelpBrowserSetup.tr" but takes first file which has similar name... It may not use the modified version for his reason!Translocate
Alexey, yes, I did get it to work with a small subset of the legacy documentation. If I try to put everything in there it takes forever to build the index and then it just crashes. I just added the folders Addons and Tours and it worked. +1 for your findings.Gabi
@Gabi Probably the reason why "it takes forever to build the index and then it just crashes" is that you have not deleted your copy of the legacy documentation from the $UserBaseDirectory. Delete all copies of the documentation from all locations available for Mathematica with except the one you choose (from possible locations I have showed).Translocate
G
5

WARNING: I recently learned that building the index for new documentation can have undesired effects in a windows machine. Please read Alexey's comments for more details. As far as I can tell, everything is working fine in Mac OS X. I'll give an update once I determine what the source of the problem is.

Here I present a function to allow any notebook to become part of the documentation center in Mathematica 8. You can start by letting Mathematica evaluate the following:

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[];]

How to use it:

In a new document or the same one where you evaluated the functions start by finding out what this variable is:

$UserBaseDirectory

In my case, since I'm using Mac OS X I get:

/Users/jmlopez/Library/Mathematica

Find out what yours is. In this directory you should see the folder Applications. Inside Applications create the folder where you will be placing the MMA5 documentation. I named my folder MMA5 because it is short but you can give it any name you want, in the case of Alexey we can call it LegacyDocumentation. Inside this folder transfer a copy of the folder named Documentation found in the installation directory for MMA5.

We are almost done. Now call the function AddDocs. This function takes only one argument: The name of the application whose documentation we wish to add. In my case, since I named the folder MMA5 I will call it as follows:

AddDocs["MMA5"]

The next thing you should see is a sequence of notebooks appearing and disappearing as well as a sequence of messages being printed. Here is part of that sequence of messages:

Output

Since the documentation of MMA5 is quite extensive this process will take a while. I did a timing on this function and it said it took about 40 seconds (It seemed a lot longer to me).

You are done. The documentation of MMA5 should now be available in the documentation center.

Test Drive

Say you wish to look up some information on DSolve. If you search for DSolve you see the following:

DSolve MM8

To look up for the MMA5 documentation we need to click on the link for DSolve located in "Search for all pages containing DSolve". Now we obtain something like this:

DSolve MM5

In the above screenshot I have marked in red the entries that give us access to the Mathematica 5 documentation. I have no way of writing a nice summary for each of the files in the documentation so I just made Mathematica write the CellTags located in the notebooks. This is why you see a list of strings.

If you click on the first red entry this is what we obtain

Jackpot

So there you have it, a working copy of legacy documentation working on the new version of Mathematica. I have not tested this in MMA7 but I have a feeling it would work. If someone tries this please let me know.

NOTES

If you want to apply this to other documents in a different application. You need to pay attention to this:

    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}], "\\" -> "/"]
        },

Notice that I have hardcoded "Mathematica 5.2" in the label. You may even want to change this to "LegacyDocumentation" if you want. This is just a label. Another important point is the keywords. I have set keywords to the variable tags. Every cell in a notebook has the option to add CellTags. If you are going to write some documentation you should use them. I have taken advantage of this to let the documentation center know how to search for the documents. This is something I have just recently learned and I will definitely implement in a package.

If you ever feel like writing a complete application with its documentation I suggest you take a look at my post integrating notebooks to MMA doc center. Here you will find more information that will let you figure out how the functions I have provided here work.

As a final note I'd like to add that I have also tested this in windows machine and it worked fine, that's the reason behind this line of code:

StringReplace[FileNameJoin[{appName, str}], "\\" -> "/"]

EDIT:

I changed the function so that it can correctly work in MMA7. Turns out that the pacletInfo.m file needs to have the line MathematicaVersion -> 7+ so that it can work in MMA7 and MMA8.

EDIT 2:

I made a mistake while copying and pasting the function. It should be fixed now. If you have both MMA7 and MMA8, I suggest running it only once in MMA7. That way the documentation will be available to both MMA7 and MMA8.

Gabi answered 31/7, 2011 at 16:31 Comment(13)
In MMa 7 the AddDocs["MMA5"] has finished its work as expected but searching for DSolve shows another picture: on the first 3 pages there is no link to Mathematica 5.2 DSolve and only links like A_09 (Mathematica 5.2 | MainBook). When clicked, such links produce "Why the beep?" pop-up window: "The file you tried to open was not found or could not be opened."Translocate
@Alexey, I see. I just tried it to repeat the steps and you are right. The links do not seem to work. What I did to make it work in mine I changed the paclet file. Try to modify the pacletInfo.m file, just change the line MathematicaVersion -> "8+", to MathematicaVersion -> "7+",. After that enter evaluate PacletManagerRestartPacletManager[];` to make mathematica aware of the change. See if that works.Gabi
@Alexey, I don't know how to make the backwards quote in comment mode. I hope you know I meant to write PacletManager'RestartPacletManager[]; where ' is the backwards quote.Gabi
You can inter the backward quote by wrapping text with it with double backward quotes: ''PacletManager'RestartPacletManager[];'' (replace all ' with backward quotes). After changing MathematicaVersion to "7+" links on the search pages start working. But other things are the same: even searching for DSolve 5.2 does not give the link to the legacy page for DSolve. And the links on the legacy pages open empty legacy Help Browser.Translocate
That's one thing I have no idea how to do. I nevered worked with Help Browser so I don't know how to make it work. I can however answer the question about the DSolve 5.2 not giving you the results. If you look in the code I have set the Keywords to be a list of all the tags found in documents. You would need to add more keywords such as DSolve 5.2 to the document that contains DSolve. You could also try to add keywords such as Legacy. To do this add this line after you define tags: tags = Flatten@ Append[tags, appName <> "5.2"] or any other keywords that allow you to find the info.Gabi
@Alexey, actually, it does work. I just tried it in MMA7 and after searching for DSolve 5.2 I get my links. One located in my MMA5 folder and one in LegacyDoc. Yeah, I made two copies of the documentation. For the Legacy Help Browser I will have to do more research to find out how to use it in MMA version 7+. Any tutorials on this? I think the easier thing to do is to write a function that changes the links in the legacy pages to point to the right documents and locations in the legacy documents instead of opening the Help Browser.Gabi
This is the only source of information on the Help Browser I know at the moment. In really the versions of MMa before v.6 had another concept of searching in help: it was not ordinary search but a set of sets of pointers defined for different keywords. This method has its own advantages since these sets of pointers were chosen with care. In this way it would be of course better to use Help Browser for the legacy documentation.Translocate
The only way to add documentation to Help Browser which I know is similar to adding documentation to the Documentation Center: see the original question.Translocate
Here are additional notes on the Help Browser: "Adding Material to the Help Browser", "Customizing the Help Browser".Translocate
I have discovered that my Documentation Center search does not work well now. For example, searching Plot does not open the documentation page for Plot and this page even is not in the top of the search results. I think it is probably due to documentation index modifications produced by your code (I have removed the folder MMA5 from the $UserBaseDirectory). Is it possible to recover Documentation Center search without re-installing Mathematica?Translocate
@Alexey, this is a serious problem. So even after you removed MMA5 from $UserBaseDirectory the doc center doesn't return to normal? This doesn't seem to be a problem in MMA8 though. I have also tried it in MMA7 and it works fine. Actually, even if I have the doc for MMA5 when I search for Plot I get the documentation page for it. I wonder if this is a problem related to windows. I won't be able to check this problem for the next two days in a windows machine. Try not to reinstall it. Did you restart MMA7 after you removed the documentation that my code generated?Gabi
Yes, I have restarted MMa several times after removing the MMA5 folder and the problem persist.Translocate
@Alexey, sorry for taking a while to respond. I ran the code I provided here in a windows 7 machine with MMA8. I obtain the same behavior as in my mac machine, that is, what I described in the test drive section. Since I do not have MMA7 in the windows machine I cannot verify your problem. It seems very weird though. I'm wondering if the problem may be do to the modifications of the HelpBrowserSetup.tr file. Not likely since they are 2 different things. For now, given your current situation I can only say that this doesn't work in MMA7 for windows.Gabi

© 2022 - 2024 — McMap. All rights reserved.