I have a package that uses custom documentation pages that are not generated with Wolfram Workbench.
How can I create search indices for these pages?
Requirements:
- Searching should work in Mathematica 10.0–11.1
- Auto-updating search indices in Mathematica 11.2 should also work
I expect an answer which shows the simplest possible package that fits the requirements: a single barebones documentation page, and straightforward instructions for creating the indices.
The obligatory "what have you tried?"
The following is a small example package that is searchable in M11.1 but not in M11.2.
Create the TestApp
directory in $UserBaseDirectory/Applications
, and add the following PacletInfo.m
file:
Paclet[
Name -> "TestApp",
Version -> "0.0.1",
MathematicaVersion -> "10.0+",
Extensions -> {{"Documentation", Language -> "English", MainPage -> "TestApp"}}
]
Then create the Documentation/English
subdirectory within TestApp
and add the following notebook:
Notebook[{
Cell[CellGroupData[{
Cell["Lorem Ipsum", \
"Section",ExpressionUUID->"cbc045dc-447e-4711-8aac-cb341b739ef9"],
Cell["\<\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur non \
volutpat lectus. Orci varius natoque penatibus et magnis dis parturient \
montes, nascetur ridiculus mus. Class aptent taciti sociosqu ad litora \
torquent per conubia nostra, per inceptos himenaeos. Lorem ipsum dolor sit \
amet, consectetur adipiscing elit. Aliquam eget efficitur quam. Sed a aliquam \
libero, non porta erat. Mauris facilisis velit felis, hendrerit consequat \
massa posuere ac. Sed luctus suscipit dictum. Aliquam egestas orci vitae \
turpis ultricies sollicitudin. Etiam vitae nisi lobortis, scelerisque nulla \
ut, euismod lorem. Sed non nulla ex. In vel eros venenatis, mollis tortor ac, \
convallis nibh. Aenean vestibulum dui dolor, sed ultricies lacus dignissim \
nec. Aenean iaculis sapien et tincidunt porttitor. Nulla pulvinar est dapibus \
posuere convallis.\
\>", "Text",ExpressionUUID->"a609adb0-6225-4cdd-9894-e399706c82ac"]
}, Open ]]
},
TaggingRules -> {
"Metadata" -> {
"keywords" -> {"lipsum", "testapp", "foobarbaz"},
"index" -> True,
"label" -> "TestApp page",
"language" -> "en",
"paclet" -> "TestApp",
"summary" -> "This is a doc page test.",
"title" -> "TestApp Title",
"windowtitle" -> "TestApp",
"type" -> "Guide",
"uri" -> "TestApp/TestApp"
}
},
Saveable->False,
DockedCells -> FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"]
TrackCellChangeTimes->False,
StyleDefinitions->"Default.nb"
]
Some "Metadata"
must be present in the TaggingRules
of the notebook, but it is not clear to me how much is required (other than "index" -> True
). Without it, indexing will fail.
Now evaluate in M11.1 or earlier:
SetDirectory@FileNameJoin[{$UserBaseDirectory, "Applications", "TestApp", "Documentation", "English"}]
Needs["DocumentationSearch`"]
indexDir = CreateDirectory["Index"]
ind = NewDocumentationNotebookIndexer[indexDir]
AddDocumentationNotebook[ind, "TestApp.nb"];
CloseDocumentationNotebookIndexer[ind]
Finally, restart Mathematica (including the front end), open the documentation centre, and search for "lipsum" (a keyword) or "consequat" (a word in the body of the notebook). These queries will all return the TestApp page.
This works in M11.1 or earlier, but it does not work in M11.2. How can I fix this test package to make sure that it will work in M11.2, and that M11.2 can automatically convert the indices?
{"$UserBaseDirectory/TestApp/Documentation/English"}
, each time there is an attempt to convert indices. Since the conversion fails and is re-tried on next startup, I have multiple entries there. Today I did manage to get this working. The solution is in the answer below. I am not 100% confident about this, so I would welcome a Wolfram developer's blessing. $\endgroup$