- Add a space in between the license information and documentation in your code
How to use SPDX Licenseinformation in .mat matlab files?
4 次查看(过去 30 天)
显示 更早的评论
SPDX is an ISO standard which enables one to add structured human and machine readabel license information to files.
I do not want to clutter the preview function of matlab.
How should the SPDX information be added to the file?
Is it possible to tell matlab, that comments with SPDX data should be ignored in the preview?
0 个评论
采纳的回答
Suvansh Arora
2022-11-4
I think the “preview” function you are talking about is the “help” function that is used to provide help for the programs you write.
I would like to recommend a way to not clutter the help data with unwanted license information.
function c = addMe(a,b)
% ADDME Add two values together.
% C = ADDME(A) adds A to itself.
%
% C = ADDME(A,B) adds A and B together.
%
% See also SUM, PLUS.
% License information:
switch nargin
case 2
c = a + b;
case 1
c = a + a;
otherwise
c = 0;
end
>> help addME % In order to view the documentation.
addMe Add two values together.
C = addMe(A) adds A to itself.
C = addMe(A,B) adds A and B together.
See also sum, plus.
I hope the above information helps you.
2 个评论
Suvansh Arora
2022-11-7
A better way of achieving this would be:
FOR ALL .mat FILES DO
IF there_is_a_function
THEN
skip_lines_with_comments
Add_space_and_add_spdx_information_as_a_comment
ELSE
skip_lines_with_comments
Add_space_and_add_spdx_information_as_a_comment
- “skip_lines_with_comments”: This will be useful in having a “help” output of the functions/scripts.
- “Add_space_and_add_spdx_information_as_a_comment”: Adding space would break the “help” output and the comments further on can be used to add “spdx” information.
In order to achieve above automation, you can follow the ML answers article mentioned below:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Manage Products 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!