custom class documentation question

2 views (last 30 days)
mcg
mcg on 17 Apr 2020
Commented: Daniel Dolan on 11 Nov 2020
If I build a class in Matlab and type doc(class_name) the documentation comes up with information on the properties, methods, etc. of that class, somehow automatically generated from the .m code file itself. Is there a way to capture this in an .html file or a .m file that could be published into .html using publish()? With the help() command you can specify an output argument to capture the help as a character array (then fprintf() into a .m file and publish() it), but with doc() you cannot do this.
  2 Comments
mcg
mcg on 17 Apr 2020
Well I at least figured out what Matlab is doing, to a point. Debug stepping through doc() it eventually gets the html with this command:
html = help2html(topic,'','-doc');
I can simply write this html to a text file, and it displays in Help or a web browser okay but the format is messed up, not pretty like what doc() spits out. If you continue passed this where the html string is created, it goes through a bunch of mumbo jumbo, pre-pending a 'text://' string to the html string, and finally gets to a nested function
doc() >> showHelpwin() >> helpwin() >> displayFile() >> web() >> openMatlabBrowser()
Inside of this function it calls
com.mathworks.mlservices.MLHelpServices.setHtmlText(html_file(8:end));
which is where the magic happens. But you can't step into this function, and you can't get an output from it. I think inside of here the html is being massaged to look nice, but I still don't see a way to capture the result. I can't even right click and "Get Page Source" because the result is blank.
Daniel Dolan
Daniel Dolan on 11 Nov 2020
com.mathworks.mlservices.MLHelpServices.setHtmlText is a static Java method.

Sign in to comment.

Answers (1)

Daniel Dolan
Daniel Dolan on 11 Nov 2020
You might take a look at the help2html function, located in the same directory as the doc function. It is an unsupported file and gould change at any time, so be wary.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!