]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/rpp_update_doc.m
34a99c48f7d1f7eaef925093ac0579c3c3a1ebbc
[jenkicar/rpp-simulink.git] / rpp / blocks / rpp_update_doc.m
1 function updated = rpp_update_doc
2 % RPP_UPDATE_DOC Update built-in S-functions documentation.
3 %    The documentation is updated based on the YAML comment in .c files.
4 %    The number of updated blocks is returned.
5 set_param('rpp_lib', 'Lock', 'off');
6 blocks = find_system('rpp_lib', 'Type', 'block');
7 updated = 0;
8 for i=1:length(blocks),
9     params = get_param(blocks{i}, 'ObjectParameters');
10     fields = fieldnames(params);
11     fn = get_param(blocks{i}, 'FunctionName');
12     % We have to unset Matlab's library path in order to run pandoc - it
13     % needs newer libc than the one shipped with Matlab
14     [rc, new_help] = system(['unset LD_LIBRARY_PATH; scripts/doc_parse.py --html ' fn '.c']);
15     if rc ~= 0,
16         disp(new_help)
17         throw(MException('rpp:pandoc_failure', ['Failed to extract doc from ' fn '.c']))
18     end
19     old_help = get_param(blocks{i}, 'MaskHelp');
20     if ~strcmp(old_help, new_help),
21         disp([blocks{i} ': Help not up-to-date - upating'])
22         set_param(blocks{i}, 'MaskHelp', new_help)
23         updated = updated + 1;
24     else
25         disp([blocks{i} ': Help up-to-date'])
26     end
27 end
28 set_param('rpp_lib', 'Lock', 'on');