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.

The Mathematica help menu contains an entry Find Selected Function (Cmd+Shift+F on OSX). If you are working with say Transpose and want to look up its reference page, you just select Transpose with the mouse, hit Cmd+Shift+F and Mathematica opens the reference page for Transpose. Works beautifully.

Question: How to get this to work for your own packages?

So, suppose your package is correctly built, and it has its own functions:

MySuperFunc
FunkyMonkey
FunkMeister2

and the documentation pages are correctly created, correctly defined and correctly installed for each of those functions. You select MySuperFunc with the mouse, select Find Selected Function, expecting Mathematica to open the reference page for that function but it doesn't work.

Instead, Mathematica opens up something akin to a Google search on "MySuperFunc", providing a list to anything it can find on that name. But that's not what I want. And it's also not what that menu function is supposed to be doing: Find SELECTED Function! Not a google-type search. Just open the reference page for the selected Function.

Anyone have some tips on how to make this work as advertised?


Addendum: If one enters:

 ?MySuperFunc

... you get the usual Help blurb on the function, such as:

MySuperFunc[b] returns blah given b. >>

... and if you then click on those two little >> arrows, Mathematica opens the Help Reference page for MySuperFunc PERFECTLY, which is exactly what FindSelectedFunction should be doing, but is not doing. And if it works perfectly for the >> info blurb, why can't it work just as perfectly for FindSelectedFunction?

share|improve this question
2  
This behavior is expected and I discussed it with someone a while ago. The essence was: This is not supposed to work for AddOn functions like the ones from your own package. Btw, you have the same functionality if you (without selecting) just go anywhere inside Transpose and press F1. I would be happy to hear about a solution to this. –  halirutan Oct 2 '13 at 7:18
2  
The whole point of package design is that one is supposed to be able to seamlessly extend Mathematica. I cannot agree that this behaviour is 'expected' ... it is just bad user-interface design for some functions to work in one way, and other funcs to then not work in the same way. Makes no sense to me. –  wolfies Oct 2 '13 at 7:27
1  
I really hope there is a solution, but I'm afraid exactly this seamless integration of the doc of extra packages is not possible. I tried this with version 8 the last time, when I remember correctly. –  halirutan Oct 2 '13 at 7:33
    
Have you tried installing the documentation directly into the $InstallationDirectory\Documentation\English\System\ReferencePages\Symbols path? I'm not saying this is an acceptable solution even if it works, but I'd like to know if it works. –  Mr.Wizard Oct 2 '13 at 11:59
    
Hi @Mr.Wizard ... just tried that ... nice idea ... but alas did not help. –  wolfies Oct 2 '13 at 15:15
show 3 more comments

1 Answer

Let me put on record why I think that there is no obvious (no hack-free) solution to your problem. The behavior you are seeing is not restricted to third party packages. Even the most popular AddOn packages are not seamless integrated when it comes to the documentation reference pages.

Try to do the following. Load JLink`

<<JLink`

and type AddToClassPath and press F1. As you can see even JLink`, which is deeply integrated into Mathematica since several versions, has not the privilege to bring reference pages up directly.

In my opinion the reason is simple: If you press F1 (or Find Selected Function as you do), it is only checked whether an URL of the form

ref/FunctionName

exists. This is not the case for all functions which are inside packages that need to be loaded and are not integrated into the kernel. As you can easily check, all package functions have their context prepended in the documentation URL. Examples:

ANOVA/ref/PostTests
JLink/ref/AddToClassPath

or

mathStatica/ref/CentralToRaw

Currently I see only two possible solutions:

  1. You can tweak the created documentation to your package so that the URL does not contain the package context
  2. Write your own search which additionally searches all AddOn reference pages.

Reference implementation for the second suggestion

Since I did something similar for Symbol Information Palette (you can find the code online), let me give some code for an implementation of a search function. The created button Find Selected Function can be used to navigate directly to the reference page of all system functions and, in addition, to all functions of the specified extra packages. If the function cannot be found, the documentation is searched like usual. You could try it for instance with AddToClassPath, PostTests or CCodeGenerate...

With[{searchedPackages = {"JLink", "CCodeGenerator", 
    "CCompilerDriver", "ANOVA"}},
 Function[package,
   Block[{$ContextPath, context = package <> "`"},
    Needs[context];
    $$extraNames[package] = Names[context <> "*"]
    ]
   ] /@ searchedPackages;

 getSymbol[nb_] := 
  Block[{sel, heldSymbol}, 
   If[(sel = NotebookRead[nb]) === {}, 
    SelectionMove[nb, All, Expression];
    sel = NotebookRead[nb]];
   sel
   ];
 openDoc[___] := Null;
 openDoc[func_String /; StringLength[func] > 0] := 
  Module[{searchName = func},
   If[Names[func] === {},
    With[{addOnPack = 
       Select[searchedPackages, MemberQ[$$extraNames[#], func] &]},
     If[addOnPack =!= {},
      searchName = addOnPack <> "/ref/" <> func;
      ]
     ]];
   Documentation`HelpLookup[searchName, Null]
   ]
 ]

Button["Find Selected Function", 
 openDoc[getSymbol[SelectedNotebook[]]]]
share|improve this answer
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.