8
$\begingroup$

Fixed in 10.0.
Works correctly since Mathematica 10.0.


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?

$\endgroup$
8
  • 2
    $\begingroup$ 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. $\endgroup$
    – halirutan
    Oct 2, 2013 at 7:18
  • 2
    $\begingroup$ 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. $\endgroup$
    – wolfies
    Oct 2, 2013 at 7:27
  • 1
    $\begingroup$ 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. $\endgroup$
    – halirutan
    Oct 2, 2013 at 7:33
  • $\begingroup$ 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. $\endgroup$
    – Mr.Wizard
    Oct 2, 2013 at 11:59
  • $\begingroup$ Hi @Mr.Wizard ... just tried that ... nice idea ... but alas did not help. $\endgroup$
    – wolfies
    Oct 2, 2013 at 15:15

1 Answer 1

6
$\begingroup$

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[]]]]
$\endgroup$

Your Answer

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

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