]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
Add function that updates documentation of RPP blocks
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Nov 2014 16:28:02 +0000 (17:28 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Nov 2014 16:28:02 +0000 (17:28 +0100)
The documentation is extracted from YAML comments in .c files.

rpp/blocks/rpp_update_doc.m [new file with mode: 0644]

diff --git a/rpp/blocks/rpp_update_doc.m b/rpp/blocks/rpp_update_doc.m
new file mode 100644 (file)
index 0000000..3bb95d8
--- /dev/null
@@ -0,0 +1,25 @@
+function rpp_update_doc
+% RPP_UPDATE_DOC Update built-in S-functions documentation.
+%    The documentation is updated based on the YAML comment in .c files.
+set_param('rpp_lib', 'Lock', 'off');
+blocks = find_system('rpp_lib', 'Type', 'block');
+for i=1:length(blocks),
+    params = get_param(blocks{i}, 'ObjectParameters');
+    fields = fieldnames(params);
+    fn = get_param(blocks{i}, 'FunctionName');
+    % We have to unset Matlab's library path in order to run pandoc - it
+    % needs newer libc than the one shipped with Matlab
+    [rc, new_help] = system(['unset LD_LIBRARY_PATH; scripts/doc_parse.py --html ' fn '.c']);
+    if rc ~= 0,
+        disp(new_help)
+        throw(MException('rpp:pandoc_failure', ['Failed to extract doc from ' fn '.c']))
+    end
+    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)
+    else
+        disp([blocks{i} ': Help up-to-date'])
+    end
+end
+set_param('rpp_lib', 'Lock', 'on');
\ No newline at end of file