MATLAB:强制doc命令打开指定的参考HTML页面 [英] MATLAB: force doc command to open a specified reference HTML page
问题描述
说我已经在一个名为mypackage.myclass
的程序包中编写了一个类.我已经为包和类编写了自己的HTML文档,并将其包含在MATLAB帮助浏览器中,如
Say I've written a class in a package, called mypackage.myclass
. I've written my own HTML documentation for the package and the class, and have included this within the MATLAB help browser as described in the MATLAB documentation.
我可以使用帮助浏览器直接导航到此HTML文档,但是键入doc mypackage.myclass
不会显示它;而是显示doc mypackage.myclass
.而是显示一些由helpwin
自动生成的HTML文档(这是一个不错的功能,但不是我想要的-自动生成的文档对我的用户来说太过挑剔了).
I can display this HTML documentation by using the help browser to navigate directly to it, but typing doc mypackage.myclass
does not display it; instead it displays some HTML documentation that is auto-generated by helpwin
(which is a nice feature, but not what I want - the auto-generated documentation is too techy for my users).
如何强制doc
显示我的文档,而不是自动生成的文档?
How can I force doc
to display my documentation, rather than the auto-generated documentation?
等效地:
运行doc docTopic
时,在doc命令中将调用Java类com.mathworks.mlservices.MLHelpServices.showReferencePage(docTopic)
.如果存在docTopic
的参考页,则将其显示并返回成功值.如果参考页不存在,它将返回一个失败值,然后导致调用helpwin(docTopic)
.在某处必须有一些目录,该目录将docTopic
的值与各个参考HTML文件连接起来.我该如何摆弄该目录-或者可以为我的包裹创建一个目录?
When you run doc docTopic
, inside the doc command the Java class com.mathworks.mlservices.MLHelpServices.showReferencePage(docTopic)
gets called. If a reference page for docTopic
exists, it displays it and returns a success value. If a reference page doesn't exist, it returns a failure value, which then causes helpwin(docTopic)
to get called. Somewhere there must be some catalog that connects values of docTopic
with individual reference HTML files. How can I fiddle with that catalog - or can I create one for my package?
MathWorkers和@Yair,请给我足够多的无证绳索以使自己吊死:)
MathWorkers and @Yair, please give me enough undocumented rope to hang myself with :)
推荐答案
据我所知这是不可能的,也不是MathWorks想要的.我也不知道这样做的无证方式.据我记得,doc
的关键字在某处进行了硬编码.
As far as I know this is not possible and not intended by MathWorks. I don't know of an undocumented way of doing this either. As far as I remember the keywords for doc
are hard-coded somewhere.
根据您的设置,您可以尝试以下操作:准备自己的doc
命令,该命令使用web(..., '-helpbrowser')
在MATLAB的帮助浏览器中显示HTML页面:
Depending on your setup you can try the following: Prepare your own doc
command that uses web(..., '-helpbrowser')
to display HTML pages in MATLAB's help browser:
function doc(topic)
my_topics = {
'foo', 'foo.html'
'bar', 'bar/help/intro.html'
};
for i = 1 : size(my_topics, 1)
if strcmpi(topic, my_topics{i, 1})
web(my_topics{i, 2}, '-helpbrowser');
return;
end
end
% Fall back to MATLAB's doc. Note that our doc shadows MATLAB's doc.
docs = which('doc', '-all');
old_dir = cd();
c = onCleanup(@() cd(old_dir));
cd(fileparts(docs{2}));
doc(topic);
end
如果将该函数放在文件doc.m
中,并将相应的目录放在MATLAB路径的开头(请参见help addpath
),则它将被调用,而不是内置的doc
.
If you put that function in a file doc.m
and put the corresponding directory at the beginning of the MATLAB path (see help addpath
) then it will be called instead of the built-in doc
.
当然,您可以在其他地方存储自定义doc映射(例如文件)或使用某种动态查找方案.
Of course you could use some other place to store your custom doc mapping (a file, for instance) or use some kind of dynamic lookup scheme.
更新:从MATLAB R2012b开始,未记录web
的'-helpbrowser'
选项.这可能与该MATLAB版本中的GUI更改有关,该版本还包括帮助浏览器. web(..., '-helpbrowser')
仍可按预期工作,但是在将来的MATLAB版本中可能会有所变化.据我所知,在R2012b的帮助浏览器中没有打开任何 HTML页面的书面记录.
UPDATE: As of MATLAB R2012b, the '-helpbrowser'
option of web
is undocumented. This is probably related to the GUI changes in that MATLAB version, which also include the help browser. web(..., '-helpbrowser')
still works as intended, but that may change in future versions of MATLAB. As far as I know, there is no documented way of opening any HTML page in the help browser in R2012b.
这篇关于MATLAB:强制doc命令打开指定的参考HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!