5
$\begingroup$

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.

$\endgroup$

2 Answers 2

7
$\begingroup$

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"}
$\endgroup$
6
  • $\begingroup$ It works, thanks for helping :). And +1 for digging into the notebook expression. $\endgroup$
    – mmjang
    Aug 24, 2013 at 15:27
  • $\begingroup$ @pheiztu I'm glad it works. Please take a look at an edit, this seems to be shorter way. $\endgroup$
    – Kuba
    Aug 24, 2013 at 15:31
  • $\begingroup$ Cool, I wish I can cast another vote for it. $\endgroup$
    – mmjang
    Aug 24, 2013 at 15:33
  • $\begingroup$ +1 although Using NotebookGet on documentation interface often freezes for me. $\endgroup$
    – William
    Aug 24, 2013 at 15:37
  • $\begingroup$ @Kuba Well, ok, I just think "accept" = "another vote" :p $\endgroup$
    – mmjang
    Aug 24, 2013 at 15:53
2
$\begingroup$
"paclet:ref/" <> FileBaseName[Last[FileNameSplit[NotebookFileName[
SelectedNotebook[]]]]]

Will return a string of the paclet of the currently selected notebook document iff it is a reference. Change the "ref" for guide if needed for guides.

$\endgroup$
1
  • 1
    $\begingroup$ +1, it looks better for me :) but you need to place it in palette or use it after selecting automatically the Help Notebook because now it is not handy I think. I can copy a link directly if I have to put it in Help Notebook :) $\endgroup$
    – Kuba
    Aug 24, 2013 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.