-function updated = rpp_update_doc
+function updated = rpp_update_doc(varargin)
% RPP_UPDATE_DOC Update built-in S-functions documentation.
% The documentation is updated based on the YAML comment in .c files.
% The number of updated blocks is returned.
+if nargin > 0,
+ arg = varargin{1};
+else
+ arg = '';
+end
+open('rpp_lib');
set_param('rpp_lib', 'Lock', 'off');
blocks = find_system('rpp_lib', 'Type', 'block');
updated = 0;
old_help = get_param(blocks{i}, 'MaskHelp');
if ~strcmp(old_help, new_help),
disp([blocks{i} ': Help not up-to-date - upating'])
- set_param(blocks{i}, 'MaskHelp', new_help)
+ if strcmp(arg, 'diff'),
+ print_diff(fn, old_help, new_help)
+ else
+ set_param(blocks{i}, 'MaskHelp', new_help)
+ end
updated = updated + 1;
else
disp([blocks{i} ': Help up-to-date'])
end
end
-set_param('rpp_lib', 'Lock', 'on');
\ No newline at end of file
+set_param('rpp_lib', 'Lock', 'on');
+
+function print_diff(fn, old, new)
+ f = fopen([fn '.help.old'], 'w');
+ fprintf(f, '%s', old);
+ fclose(f);
+
+ f = fopen([fn '.help.new'], 'w');
+ fprintf(f, '%s', new);
+ fclose(f);
+
+ [rc, diff] = system(['diff -u ' fn '.help.old ' fn '.help.new']);
+ disp(diff);
+ delete([fn '.help.old']);
+ delete([fn '.help.new']);