Skip to main content

workbench - How to make notebooks suitable for the Documentation Center?


Normally, documentation meant to be integrated into the Documentation Center is built from special source notebooks.


According to the Workbench documentation, it should also be possible to use alternative formats. Just create the notebooks and put them at the specified location. They will be copied over during documentation build and they will get a suitable URI for the Documentation Center.



I tried this and it works, but there are some problems. The biggest one is that pressing the Reload button opens the notebooks in a standard window instead of in a documentation window.


enter image description here


How should a notebook be prepared so that it properly integrates into the Documentation Center and is well-behaved there?


This question is specifically about simple notebooks that do not go through the documentation build process.


As a first test, I was simply building a license page, for which there is no standard template. But eventually I would like to use this for documentation in alternative formats, as I won't always have time to create standard format documentation.




"What have you tried?"


The toolbar source can be examined using


FrontEndResource["FEExpressions", "HelpViewerToolbar"]


The button seems to invoke the Revert front end token, i.e. it's similar to (the same as?) File -> Revert... This explains the behaviour I see but I still don't know why normal documentation notebooks don't behave this way.


I tried taking StyleDefinitions (which also adds the toolbar docked cell) and TaggingRules from a normally built doc notebook and trasferring them to my custom notebook. I manually edited the URIs to match. The Revert button still re-opens the notebook in a new window.


Note that I am not asking for adding the help toolbar to the notebook. This can indeed by accomplished by ensuring that the notebook or its stylesheet has DockedCells -> FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"]. But the Reload button will still open a new window which, while it does have the help toolbar, isn't the same as the documentation browser. There are clear differences:



  • The doc browser disappears and the notebook window appear at a new position on screen

  • The notebook window doesn't show "- Wolfram Mathematica 10.0" in the title bar

  • When using the search toolbar in the notebook window, it will open a new doc browser instead of showing the results in the same window

  • The Back button doesn't work


What I want is to stay within the documentation browser and not open a separate notebook.





Cross posted on Wolfram Community



Answer



For notebook to stay in the same place, after Revert action, it needs Saveable -> False option.


Note: A notebook with Saveable -> False cannot be saved using the GUI through File -> Save... It can be saved programmatically using NotebookSave, or exported using Export[..., "NB"], etc.




Let's create basic test application with documentation support:


appName = "docNotebookTest";
appPath = FileNameJoin@{$UserBaseDirectory, "Applications", appName};
nbPath = FileNameJoin@{appPath, "Documentation", "English", "altDoc", "test.nb"};

CreateDirectory@DirectoryName@nbPath
Export[FileNameJoin@{appPath, "PacletInfo.m"},
Paclet[Name -> appName, Version -> "0.0.1",
Extensions -> {{"Documentation", Language -> "English"}}
]
]

Now create simple un-Saveable notebook and restart paclet manager, so that it can find our new documentation notebook:


Export[nbPath,
Notebook[{Cell["Contents of alternative documentation notebook.", "Text"]},

Saveable -> False
]
]
RestartPacletManager[]

Now if we go to documentation center and search for docNotebookTest/altDoc/test, we'll get our example notebook open in the same window with "HelpViewerToolbar". You can click on reload button and notebook will remain in the same place and it'll retain "HelpViewerToolbar". Close this test documentation notebook for now, so it won't interfere with further tests.


I don't know internals of mechanism behind this, but the fact that toolbar stays there feels a bit accidental. "Ordinary" documentation notebook appears with "HelpViewerToolbar" no matter how you open it e.g.:


NotebookOpen@"paclet:ref/List"

Opens List documentation notebook with "HelpViewerToolbar" on. This is because it uses StyleDefinitions -> FrontEnd`FileName[{"Wolfram"}, "Reference.nb", CharacterEncoding -> "UTF-8"] and Reference.nb style-sheet has:



Cell[StyleData[All, "Working"],
DockedCells->FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"]
]

as one of declarations.


If we open our notebook in any other way than searching in documentation center:


nbObj = NotebookOpen@"paclet:docNotebookTest/altDoc/test"

it opens without "HelpViewerToolbar" (if you didn't close test.nb previously opened through documentation center, then above command will just make its window, with toolbar, active).


If we want our notebook to always open with "HelpViewerToolbar", as "ordinary" documentation notebooks do, we should add this toolbar to notebook DockedCells, either directly, or through o style-sheet:



nbObj // NotebookClose
Export[nbPath,
Notebook[{Cell["Contents of alternative documentation notebook.", "Text"]},
Saveable -> False,
DockedCells ->
FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"]
]
]

Now our notebook always opens with desired toolbar:



nbObj = NotebookOpen@"paclet:docNotebookTest/altDoc/test"

Close notebook and delete our test application:


nbObj // NotebookClose
DeleteDirectory[appPath, DeleteContents -> True]

Comments

Popular posts from this blog

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1....