Using this technique when generating documentation in Mathematica 6 (with the method described in my other answerother answer), along with Teake's techniques of generating the index in Mathematica 9generating the index in Mathematica 9 and writing a cross-version PacletInfo.m
writing a cross-version PacletInfo.m
, seems to completely solve the cross-version documentation problem.
I was inspired by Teake's commentcomment that he'd like to do something like
If[$Version < 9., "More Information", "Details and options"]
if it were possible. It turns out that it's not possible to include functions in cell contents, but functions can be included in cell options, as mentioned in the documentation here (bottom of the page).
I couldn't call the
"crossVersionReplacements"
target from the"main"
target, because the"docbuild"
target has already loaded the J/Link library, and Ant doesn't want to load it a second time. Probably there's some other way around this, but I just called"crossVersionReplacements"
from inside"docbuild"
, to piggyback on the already-loaded library.The "Details and Options" section heading should just read "Details" if there are no options for the function listed. To accomplish that, I search for the substring "option" or "Option" in the Details section, and replace the heading if no instances are found (other than in the heading itself).
WRI added spacer cells at the beginning and ends of sections in the version 9 documentation, to obtain spacing that disappears when the sections are closed. To get a cross-version version of this, I added spacer cells in the appropriate places that display as very thin cells in pre-version 9 Front Ends.
The Guide pages have been totally redesigned in version 9, so there's no way to match them exactly. In particular, the Tutorials heading and links have been completely restyled. I tried to give things a consistent look by undoing these changes, to match the Tutorials style with the style of the other sections. Update: I realized I could do this a little more simply by swapping out the cell style in the Tutorials heading for another section heading style.
I encountered a rendering bug on the pre-version 9 Guide pages, affecting the layout on the whole page, which I found was triggered by the use of a non-integer value for a frame specification in the Abstract text. I adjusted the value to avoid the bug.
To get the total number of examples on a symbol page, I added together the existing example counts for all of the example subsections.
I learned some interesting things along the way, such as that the box representation of a
Spacer
is given byToBoxes@Spacer[24]
InterpretationBox[StyleBox[GraphicsBox[{}, ImageSize -> {24, 0}, BaselinePosition -> Baseline], "CacheGraphics" -> False], Spacer[24]]
Update 3: In testing on Windows, I found that when a magnification level of less than 100% is chosen for the documentation notebook, the cell frame label is reduced by a different amount than the enclosing cell, causing layout errors. These are the same glitches as Teake reported seeing in OS Xreported seeing in OS X. There isn't much we can do about the different magnification factors. (Mathematica's magnification functionality has always been a bit of a crapshoot.) However, a workaround is to increase the width of the frame label cell, so as to run the rendering glitch right off of the page. This is implemented in the updated code. Please let me know if you encounter any other issues.