Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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"}
share|improve this answer
    
It works, thanks for helping :). And +1 for digging into the notebook expression. –  mm.Jang Aug 24 '13 at 15:27
    
@pheiztu I'm glad it works. Please take a look at an edit, this seems to be shorter way. –  Kuba Aug 24 '13 at 15:31
    
Cool, I wish I can cast another vote for it. –  mm.Jang Aug 24 '13 at 15:33
    
+1 although Using NotebookGet on documentation interface often freezes for me. –  Liam William Aug 24 '13 at 15:37
    
@Kuba Well, ok, I just think "accept" = "another vote" :p –  mm.Jang Aug 24 '13 at 15:53
show 1 more comment
"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.

share|improve this answer
1  
+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 :) –  Kuba Aug 24 '13 at 15:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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