comparison m-toolbox/classes/@plist/tohtml.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 % TOHTML produces an html table from the plist.
2 %
3 % CALL:
4 % pl.tohtml; % table will be shown in document browser
5 % txt = pl.tohtml; % stand-alone table for inclusion in html doc
6 %
7 % M Hewitson
8 % 16-09-10
9 %
10 % $Id: tohtml.m,v 1.4 2011/04/08 08:56:21 hewitson Exp $
11 %
12
13 function varargout = tohtml(pl, anchor)
14
15 txt = '';
16
17 name = pl.name;
18 if isempty(name)
19 name = 'Unknown Plist';
20 end
21
22 if nargin > 1 && ischar(anchor)
23 txt = [txt sprintf(' <a name="%s"/>', anchor)];
24 end
25 txt = [txt sprintf(' <p><!-- Parameter List Table: %s -->\n', name)];
26 txt = [txt sprintf(' <table cellspacing="0" class="body" cellpadding="4" summary="" width="100%%" border="2">\n')];
27 txt = [txt sprintf(' <colgroup>\n')];
28 txt = [txt sprintf(' <col width="15%%"/>\n')];
29 txt = [txt sprintf(' <col width="20%%"/>\n')];
30 txt = [txt sprintf(' <col width="20%%"/>\n')];
31 txt = [txt sprintf(' <col width="45%%"/>\n')];
32 txt = [txt sprintf(' </colgroup>\n')];
33
34 txt = [txt sprintf(' <thead>\n')];
35 txt = [txt sprintf(' <tr valign="top">\n')];
36 txt = [txt sprintf(' <th bgcolor="#B9C6DD" colspan="4"><h3>%s</h3></th>\n', name)];
37 txt = [txt sprintf(' </tr>\n')];
38 txt = [txt sprintf(' <tr valign="top">\n')];
39 txt = [txt sprintf(' <th bgcolor="#D7D7D7">Key</th>\n')];
40 txt = [txt sprintf(' <th bgcolor="#D7D7D7">Default Value</th>\n')];
41 txt = [txt sprintf(' <th bgcolor="#D7D7D7">Options</th>\n')];
42 txt = [txt sprintf(' <th bgcolor="#D7D7D7">Description</th>\n')];
43 txt = [txt sprintf(' </tr>\n')];
44 txt = [txt sprintf(' </thead>\n')];
45
46
47 txt = [txt sprintf(' <tbody>\n')];
48 for kk=1:pl.nparams
49 txt = [txt sprintf(' <tr valign="top">\n')];
50 txt = [txt sprintf(' <td bgcolor="#F2F2F2">%s</td>\n', pl.params(kk).key)];
51 ptxt = display(pl.params(kk));
52 txt = [txt sprintf(' <td bgcolor="#F2F2F2">%s</td>\n', strtrim(strrep(ptxt{3}, 'val:', '')))];
53 if numel(pl.params(kk).getOptions) > 1
54 opts = pl.params(kk).getOptions;
55 optlist ='<ul>';
56 for oo=1:numel(opts)
57 optlist = [optlist '<li><font color="#1111FF">' utils.helper.val2str(opts{oo}) '</font></li>'];
58 end
59 optlist = [optlist '</ul>'];
60 txt = [txt sprintf(' <td bgcolor="#F2F2F2">%s</td>\n', optlist)];
61 else
62 txt = [txt sprintf(' <td bgcolor="#F2F2F2"><i>none</i></td>\n')];
63 end
64 txt = [txt sprintf(' <td bgcolor="#F2F2F2">%s</td>\n', char(strrep(pl.params(kk).desc, '\n', '<br></br>')))];
65 txt = [txt sprintf(' </tr>\n')];
66
67 end
68 txt = [txt sprintf(' </tbody>\n')];
69 txt = [txt sprintf(' </table>\n')];
70
71
72 if nargout == 1
73 varargout{1} = txt;
74 else
75
76 helpPath = utils.helper.getHelpPath();
77 docStyleFile = strcat('file://', helpPath, '/ug/docstyle.css');
78
79 html = 'text://';
80
81 % First the header table
82 html = [html sprintf('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n')];
83 html = [html sprintf(' "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">\n\n')];
84
85 html = [html sprintf('<html lang="en">\n')];
86
87 % Header definition
88 html = [html sprintf(' <head>\n')];
89 html = [html sprintf(' <title>Plist Report: %s</title>\n', name)];
90 html = [html sprintf(' <link rel="stylesheet" type="text/css" href="file://%s">\n', docStyleFile)];
91 html = [html sprintf(' </head>\n\n')];
92
93 html = [html sprintf(' <body>\n\n')];
94
95 html = [html txt]; % table
96
97 html = [html sprintf(' </body>\n')];
98 html = [html sprintf('</html>')];
99 web(html, '-helpbrowser');
100
101 end
102
103
104 end