front end - How can I determine the hyperlink of a currently opened documentation page programmatically?
Every pages in the documentation has a hyperlink. Here are some examples:
"paclet:ref/NotebookRead"
"paclet:guide/GraphStylingAndLabeling"
"paclet:tutorial/ListsOverview"
Well, my question is:
If I open a docs page, then how can I get the hyperlink of it programmatically?
my tries
Till now, I can get the NotebookInformation of documentation notebooks (if it exist):
Select[NotebookInformation /@
Notebooks[], ("DocumentType" /. #) == "Help" &]
The output might be:
{{"FileName" ->
FrontEnd`FileName[{$RootDirectory, "C:", "Program Files",
"Wolfram Research", "Mathematica", "9.0", "Documentation",
"ChineseSimplified", "System", "Tutorials"}, "ListsOverview.nb",
CharacterEncoding -> "CP936"],
"FileModificationTime" -> 3.56977*10^9,
"WindowTitle" -> "List - Wolfram Mathematica",
"MemoryModificationTime" -> 3.58634*10^9,
"ModifiedInMemory" -> True, "DocumentType" -> "Help",
"StyleDefinitions" -> {NotebookObject[
FrontEndObject[LinkObject["d5i_shm", 3, 1]], 46]}}}
But I don't know what to do next. The correspondence between the FileName and hyperlink seems to be confusing.
Answer
Not very sophisticated but works so far:
nb = (Select[Notebooks[], ("DocumentType" /. NotebookInformation[#]) == "Help" &])
"uri" /. Options[Options[#, TaggingRules][[1, 2]], Metadata][[1, 2]] & /@ nb
{"tutorial/SettingUpFunctionsWithOptionalArguments"}
Please tell me if this works for you too.
Edit
Shorter one:
nb = (Select[Notebooks[], ("DocumentType" /. NotebookInformation[#]) == "Help" &])
Cases[Options /@ nb, HoldPattern["uri" -> x_] :> x, Infinity]
{"guide/Calculus"}
Comments
Post a Comment