Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/create_class_desc/create_property_desc.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function create_property_desc(fid, meta_obj, indentation_in) | |
2 | |
3 % fid_read = fopen('property_descriptions.txt', 'r'); | |
4 % f_line = fgetl(fid_read); | |
5 % | |
6 % prop_desc = struct(); | |
7 % | |
8 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 % %%% Create from the desc_file a struct which contains %%% | |
10 % %%% all information of the file. %%% | |
11 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 % | |
13 % %%% Create a struct with | |
14 % %%% | |
15 % | |
16 % while ischar(f_line) | |
17 % | |
18 % f_line = strtrim(f_line); % Remove leading and ending whitespace | |
19 % if isempty(f_line) | |
20 % % skip this line | |
21 % elseif f_line(1) == '%' | |
22 % % skip comment line | |
23 % else | |
24 % | |
25 % [prop_name, desc] = strtok(f_line, '-'); | |
26 % | |
27 % prop_name = strtrim(prop_name); | |
28 % desc = strtrim(desc(2:end)); | |
29 % | |
30 % [class_name, prop_name] = strtok(prop_name, '.'); | |
31 % | |
32 % prop_name = prop_name(2:end); | |
33 % | |
34 % prop_desc.(class_name).(prop_name) = desc; | |
35 % end | |
36 % f_line = fgetl(fid_read); | |
37 % end | |
38 % | |
39 % fclose(fid_read); | |
40 | |
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
42 %%% Append to the fid the Information of the properties %%% | |
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
44 | |
45 indentation(1:indentation_in) = ' '; | |
46 | |
47 %%% Headline | |
48 fprintf(fid, '%s<h2 class="title"><a name="top_properties"/>Properties</h2>\n', indentation); | |
49 | |
50 fprintf(fid, '%s<p>\n', indentation); | |
51 fprintf(fid, '%s The LTPDA toolbox restrict access of the properties.<br></br>\n', indentation); | |
52 fprintf(fid, '%s The get access is ''public'' and thus it is possible to get the values with the dot-command (similar to structures).<br></br>\n', indentation); | |
53 fprintf(fid, '%s <pre class="programlisting">For example:<br></br>val = obj.prop(2).prop;</pre>\n', indentation); | |
54 fprintf(fid, '%s The set access is ''protected'' and thus it is only possible to assign a value to a property with a set-method.\n', indentation); | |
55 fprintf(fid, '%s <pre class="programlisting">\n', indentation); | |
56 fprintf(fid, 'For example:\n'); | |
57 fprintf(fid, 'obj2 = obj1.setName(<span class="string">''my name''</span>) <span class="comment">%% This command creates a copy of obj1 (obj1 ~= obj2)</span>\n'); | |
58 fprintf(fid, 'obj.setName(<span class="string">''my name''</span>); <span class="comment">%% This command applies to obj</span>'); | |
59 fprintf(fid, '%s </pre>\n', indentation); | |
60 fprintf(fid, '%s</p>\n', indentation); | |
61 | |
62 %%% Table predefinitions %%% | |
63 fprintf(fid, '%s<!-- ===== Properties ===== -->\n', indentation); | |
64 fprintf(fid, '%s<p>\n', indentation); | |
65 fprintf(fid, '%s <table cellspacing="0" class="body" cellpadding="2" border="0" width="80%%">\n', indentation); | |
66 fprintf(fid, '%s <colgroup>\n', indentation); | |
67 fprintf(fid, '%s <col width="15%%"/>\n', indentation); | |
68 fprintf(fid, '%s <col width="73%%"/>\n', indentation); | |
69 fprintf(fid, '%s <col width="12%%"/>\n', indentation); | |
70 fprintf(fid, '%s </colgroup>\n', indentation); | |
71 fprintf(fid, '%s <thead>\n', indentation); | |
72 fprintf(fid, '%s <tr valign="top">\n', indentation); | |
73 fprintf(fid, '%s <th class="categorylist">Properties</th>\n', indentation); | |
74 fprintf(fid, '%s <th class="categorylist">Description</th>\n', indentation); | |
75 fprintf(fid, '%s <th class="categorylist">Defined in class</th>\n', indentation); | |
76 fprintf(fid, '%s </tr>\n', indentation); | |
77 fprintf(fid, '%s </thead>\n', indentation); | |
78 fprintf(fid, '%s <tbody>\n', indentation); | |
79 | |
80 for ii = 1:length(meta_obj.Properties) | |
81 | |
82 prop = meta_obj.Properties{ii}; | |
83 | |
84 if ~prop.Hidden && ~prop.Dependent | |
85 | |
86 try | |
87 | |
88 % Special case for ao.hist because the AO class have a method with | |
89 % this name :( | |
90 if strcmp(meta_obj.Name, 'ao') && strcmp(prop.Name, 'hist') | |
91 description = 'History of the object (history object)'; | |
92 elseif strcmp(meta_obj.Name, 'filterbank') && strcmp(prop.Name, 'type') | |
93 description = 'Type of the bank'; | |
94 else | |
95 description = help(sprintf('%s.%s', meta_obj.Name, prop.Name)); | |
96 description = regexp(description, '(?<= - ).*', 'match'); | |
97 description = strtrim(description{1}); | |
98 end | |
99 | |
100 catch | |
101 description = '-- No description found --'; | |
102 end | |
103 | |
104 if mod(ii,2) == 0 | |
105 bgcolor = ''; | |
106 else | |
107 bgcolor = ' bgcolor="#f3f4f5"'; | |
108 end | |
109 | |
110 fprintf(fid, '%s <!-- Property: ''%s'' -->\n', indentation, prop.Name); | |
111 fprintf(fid, '%s <tr valign="top">\n', indentation); | |
112 fprintf(fid, '%s <td%s>\n', indentation, bgcolor); | |
113 fprintf(fid, '%s <p><a href="matlab:doc(''%s.%s'')">%s</a></p>\n', indentation, meta_obj.Name, prop.Name, prop.Name); | |
114 fprintf(fid, '%s </td>\n', indentation); | |
115 fprintf(fid, '%s <td%s>\n', indentation, bgcolor); | |
116 fprintf(fid, '%s <p>%s</p>\n', indentation, description); | |
117 fprintf(fid, '%s </td>\n', indentation); | |
118 fprintf(fid, '%s <td%s>\n', indentation, bgcolor); | |
119 fprintf(fid, '%s <p>%s</p>\n', indentation, prop.DefiningClass.Name); | |
120 fprintf(fid, '%s </td>\n', indentation); | |
121 fprintf(fid, '%s </tr>\n', indentation); | |
122 | |
123 end | |
124 end | |
125 | |
126 %%% Table end %%% | |
127 fprintf(fid, '%s </tbody>\n', indentation); | |
128 fprintf(fid, '%s </table>\n', indentation); | |
129 fprintf(fid, '%s</p>\n\n', indentation); | |
130 | |
131 %%% Top of page link | |
132 create_top_of_page(fid, indentation_in); | |
133 | |
134 end | |
135 | |
136 | |
137 | |
138 | |
139 | |
140 |