MATLAB: Directly open custom documentation

custom documentationdocdocumentationhelphtml

I've created custom documentation that when typing "doc" is viewable by following the trail under Supplemental Software. However, I would prefer to access the custom documentation directly without having to use "doc" and then follow down the Supplemental Software trail. Is there any way to directly open custom documentation with a single command?

Best Answer

It hasn't bothered me, but
doc toolbox_name
If the name is unique enough it produces a short list of search results. In my case the page of interest is the top one. One extra click needed.
Next a one-liner, which opens the documentation home page in the help browser (using a bit of magic)
web('documentation_home_page.html','-new')
However, this must be hidden from the user in one way or another and still be easy to use. A favorite doesn't really provide much of an improvement.
/R2018b
In response to comment
The magic works better for me
>> web('m2umlToolbox.html', '-new')
produces this
The function, builtin, doesn't work with doc, but How do I invoke a shadowed core MATLAB function does. Now
doc m2uml
opens the page shown above and
doc plot
opens the expected Matlab page.
Listing of doc
function doc( varargin )
persistent mdc
if isempty( mdc )
wch = which('doc.m','-all');
isf = contains( wch, matlabroot ); % there should only be one
wch = wch{isf};
pth = fileparts( wch );
old = cd( pth );
mdc = str2func('doc'); % create a function-handle
cd( old );
end
switch varargin{1}
case 'm2uml'
web('m2umlToolbox.html', '-new')
otherwise
mdc( varargin{:} )
end
end
Files and search path
I've used the word "magic" a couple of times to indicate that I don't understand how it works or what's required to make it work. I've stumbled upon one way that hasn't failed so far.
My starting point was the blog, Best Practices – Adapt, then Adopt! Posted by Andy Campbell, January 13, 2017 , which predates my R2018b. This blog "presents" the FEX-submission, Toolbox Tools 1.1 by Amy Koh, [Staff], A toolbox for developing custom toolboxes in MATLAB. This toolbox was "Created with R2017b" and is "Compatible with any release".
Important files, i.e files which I beleive are required
  • ...\tbx\info.xml where tbx is on the search path. Used by Matlab to find the documentation (i.e. create some kind of database entry)
  • ...\tbx\doc\helptoc.xml where doc is on the search path.
  • ...\tbx\doc\*.html all the html-files
where info.xml (there must be exactly one info.xml with the name-tag-value m2uml)
<productinfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="optional">
<?xml-stylesheet type="text/xsl"href="optional"?>
<!-- Copyright 2019 The MathWorks Ltd. -->
<matlabrelease>R2018b</matlabrelease>
<name>m2uml</name>
<type>toolbox</type>
<icon></icon>
<help_location>doc</help_location>
</productinfo>
and helptoc.xml
<?xml version='1.0' encoding="utf-8"?>
<toc version="2.0">
<tocitem target="m2umlToolbox.html"> m2uml Toolbox
<tocitem target="Overview.html"> Overview </tocitem>
<tocitem target="Installation.html"> Installation </tocitem>
<tocitem target="Limitations.html"> Limitations </tocitem>
<tocitem target="IntroductoryExamples.html"> Introductory examples </tocitem>
<tocitem target="Options.html"> Options </tocitem>
<tocitem target="UserInterface.html"> User interface </tocitem>
<tocitem target="Layout.html"> Layout </tocitem>
<tocitem target="Relationships.html"> Relationships </tocitem>
<tocitem target="ImageRow.html"> ImageRow </tocitem>
<tocitem target="Examples.html"> Examples </tocitem>
<tocitem target="TechnicalDocumentation.html"> Technical documentation </tocitem>
</tocitem>
</toc>
It seems, it doesn't matter which html-file (in the folder, doc) I open
>> web('ImageRow.html','-new')
works as I have come to expect (i.e. navigation panel to the left).