Best practice to add license text to matlab code.
5 ビュー (過去 30 日間)
古いコメントを表示
Hi!
I have been working on some Matlab code recently and I would like to publish it under some open source license. If I were programming in C, I would just add the license text as a comment at top of each file. However, Matlab considers the first comment to be the documentation. Thus, I can't really put it there because nobody will be able to lookup what the function does. In GNU/Octave I could do this, because it ignores the first comment if it starts with the word "Copyright". So my question is: What's the best way to add an open source license text to Matlab code? Should I put it below the help comment? If I remember correctly, it is, at least for the GPL, recommended to put the notice on top of each file. Or should I place it in a separate file exclusively and not in each individual m-file?
Thanks for your suggestions, Laurent
0 件のコメント
採用された回答
Jan
2011 年 5 月 31 日
You can insert a comment after the initial help block separated by an empty line:
function Output = FuncName(Input)
% FuncName - H1 line: Single line description
% Now the exhaustive help text
% descibing inputs, processing and outputs
%
% Author, Date
%
% See also SIN, COS, TheOtherFunction.
% Copyright: This is published under BSD ...
% Do not, but you are allowed to, as long as...
disp('Running the function FuncName');
...
The H1 line supports LOOKFOR, the HELP command shows the initial comment block until the first non-comment line, e.g. a blank line. The "See also" line appears as hyperlinks automatically.
By this way the license comment block is seen only, if the file is opened in the editor. This is the style used for Matlab's toolbox functions, see e.g. FILTFILT.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!