嘗試在官方文檔中的其他部分。它更徹底。 MATLAB>用戶手冊>桌面工具和開發環境>自定義幫助和演示>提供您自己的幫助和演示。這描述了簡單的幫助文本和生成單獨的HTML幫助文件。
這裏是我選擇的幫助文本格式,並發現有用。
function foo(x,y,z)
%FOO One-line description goes here
%
% foo(x,y,z)
%
% Multi-line paragraphs of descriptive text go here. It's fine for them to
% span lines. It's treated as preformatted text; help() and doc() will not
% re-wrap lines. In the editor, you can highlight paragraphs, right-click,
% and choose "Wrap selected comments" to re-flow the text.
%
% More detailed help is in the <a href="matlab: help foo>extended_help">extended help</a>.
% It's broken out like this so you can keep the main "help foo" text on
% a single screen, and then break out obscure parts to separate sections.
%
% Examples:
% foo(1,2,3)
%
% See also:
% BAR
% SOMECLASS/SOMEMETHOD
disp(x+y+z);
function extended_help
%EXTENDED_HELP Some additional technical details and examples
%
% Here is where you would put additional examples, technical discussions,
% documentation on obscure features and options, and so on.
error('This is a placeholder function just for helptext');
- 函數簽名後的第一行被稱爲「H1線」。它需要只是一行,因此它可以由contentrpt()正確拾取,它可以從函數中的幫助文本自動生成Contents.m文件。
- H1行中的函數名稱全部爲大寫,無論實際大寫在簽名中的函數名稱
- 「另請參見」的情況。我不確定哪些案件都有效;這個確實如此。
- 「另請參閱:」後的函數名稱全部大寫。方法名稱是合格的;我認爲與當前方法在相同類中的方法名稱可能是不合格的。
H1行與「Examples:」之間的所有內容都是我發現可讀的傳統格式; help()不會專門處理它。
您可以在幫助中使用有限形式的超鏈接。特別是,您可以使用超鏈接來調用任意的Matlab命令,並通過調用help()指向helptext的其他部分。你可以用它來指向任何函數; 「function> subfunction」只是在help()調用中尋址子函數的語法。不幸的是,由於您需要在這些超鏈接中放置「幫助」或「文檔」,它只能以一種或另一種表示形式工作。如果有一個直接的helptext超鏈接表單,會更好。
您添加第二個環節正是我正要建議。那裏非常有用的東西。 – gnovice 2010-10-01 16:52:22
你應該把你的UPDATE作爲答案,並接受它! – 2010-10-01 16:57:57
@Alex,我打算收集關於m文件格式的信息。創建單獨的文檔只是一個側面問題。 – yuk 2010-10-01 18:42:35