Change documentation color for help

1 回表示 (過去 30 日間)
Kambren Rowlan
Kambren Rowlan 2017 年 8 月 4 日
編集済み: Baptiste Ottino 2017 年 8 月 8 日
I'd like to change the color that some of the documentation that is displayed when entering the command
help myfunction
function myfunc = afunction()
%my documentation
%DOCUMENTATION THAT I WOULD LIKE RED
functionstuff
end
Any way to do this?

採用された回答

Walter Roberson
Walter Roberson 2017 年 8 月 4 日
No, there is no way to do that, not using help.
If you were using Live Scripts then you could embed Latex formatted comments and those could potentially have color information in them.

その他の回答 (1 件)

Baptiste Ottino
Baptiste Ottino 2017 年 8 月 8 日
編集済み: Baptiste Ottino 2017 年 8 月 8 日
It is not possible to do something like this for:
help afunction
However, it is perfectly possible to do this for the ouput of
doc afunction
which is more elegant, but it is a bit tricky. Here is how.
The idea is to directly use html tags inside your documentation. For this you have to open the help2html function
edit help2html
and between lines 69 and 70 add
helpstr = regexprep(helpstr,'&lt;','<');
helpstr = regexprep(helpstr,'&gt;','>');
Which will ensure that html tags can be used in your help. Then, use the span tag to define the color:
function myfunc = afunction()
%my documentation
%<span style="color:red">DOCUMENTATION THAT I WOULD LIKE RED</span>
functionstuff
end
For the following result:
Hope this helps.
EDIT:
I thought of a better solution. First, you can copy the help2html file and its 'private' directory above in the Matlab path to overload it, which is safer, second, instead of adding the lines I suggested, just comment line 25
% helpstr = fixsymbols(helpstr);
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 8 月 8 日
(I touched up your code so that it shows up correctly. It is an oddity of the system that HTML named entities are translated into the designated entity even in code blocks, so when you wrote &lt; in your code, that gets translated to < . To get it to show up right you have to replace the & with &amp;
Baptiste Ottino
Baptiste Ottino 2017 年 8 月 8 日
Thank you very much, it is good to know.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by