MATLAB Answers

Directly open custom documentation

12 views (last 30 days)
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?

  2 Comments

Faker Mayfield
Faker Mayfield on 23 Dec 2019
Performing "doc name" will just search all documentation and not directly open up my custom documentation.
As noted in the "doc" help reference:
"To access third-party or custom documentation, open the Help browser and navigate to the documentation home page. Then, at the bottom of the page, click Supplemental Software."
I'm attempting to avoid this step of clicking Supplemental Software, if possible.

Sign in to comment.

Accepted Answer

per isakson
per isakson on 23 Dec 2019
Edited: per isakson on 25 Dec 2019
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).

  4 Comments

Show 1 older comment
per isakson
per isakson on 23 Dec 2019
I've added a solution that accepts
doc custom_toolbox_name
It requires thorough error handling and is not for faint-hearted.
Faker Mayfield
Faker Mayfield on 24 Dec 2019
Appreciate integrating the use of doc as best as possible.
The web answers seems acceptable, but for me it opens a barebones HTML doc and not one with the navigation on the side. Are you pointing to an HTML file within a specific directory? I'm able to do as Sean suggested below ( navigating to your custom doc page's Index, right clicking and "Get Page Address" ) and I do get an address with the panel. I'm curious as to how you did it with just an HTML file.
per isakson
per isakson on 25 Dec 2019
"Are you pointing to an HTML file within a specific directory?" Yes, I try to explain in my answer.

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 23 Dec 2019
web(fullfile(docroot, '3ptoolbox/toolbox_name/doc/Index.html'))
You can get this by navigating to your custom doc page's Index, right clicking and "Get Page Address". This provides the nav panel on the right-hand side.

  4 Comments

Show 1 older comment
Sean de Wolski
Sean de Wolski on 24 Dec 2019
I just confirmed it works in 19b and not 18b. This is the structure of the helptoc.xml I'm using:
<?xml version='1.0' encoding="utf-8"?>
<toc version="2.0">
<tocitem target="Index.html">Load Forecaster
<tocitem target="Setup/Index.html">Setup
<tocitem target="Setup/DemoSetup.html">Demo Setup</tocitem>
<tocitem target="Setup/ProductionSetup.html">Production Setup</tocitem>
</tocitem>
<tocitem target="Examples/DemoingIndex.html">Demoing Load Forecaster
<tocitem target="Examples/DemoingOnlineOffline.html">Demoing Online and Offline</tocitem>
<tocitem target="Examples/MakeForecast.html">Make a Load Forecast</tocitem>
<tocitem target="Examples/TrainModels.html">Train Models</tocitem>
<tocitem target="Examples/GenerateReport.html">Generate a Forecast Report</tocitem>
<tocitem target="Examples/DealingData.html">Dealing with the Data</tocitem>
</tocitem>
</SNIP>
Faker Mayfield
Faker Mayfield on 24 Dec 2019
So, is there no similar solution to this in sub-2019b versions? Appreciate the support from the both of you!
Sean de Wolski
Sean de Wolski on 24 Dec 2019
Just confirmed it works in 19a as well so was apparently added then.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!