-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyahelp.m
More file actions
174 lines (155 loc) · 4.57 KB
/
yahelp.m
File metadata and controls
174 lines (155 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
function out = yahelp(yafile, section)
% \manchap
%
% Display the help associated to a yawtb file.
%
% \mansecSyntax
%
% yahelp yafile
% yahelp(yafile [,section] )
%
% \mansecDescription
%
% YAHELP display a userfriendly help of any yawtb function.
%
% \mansubsecInputData
% \begin{description}
%
% \item[yafile] [STRING]: the name of this file.
%
% \item[section] [SET OF STRING]: tells to yahelp which part of the
% help must be displayed. Type yahelp([]) to obtain a complete list
% of the available sections.
%
% \end{description}
%
% \mansecExample
% \begin{code}
% >> yahelp yashow
% >> yahelp yashow syntax
% \end{code}
%
% \mansecLicense
%
% This file is part of YAW Toolbox (Yet Another Wavelet Toolbox)
% You can get it at
% \url{"http://www.fyma.ucl.ac.be/projects/yawtb"}{"yawtb homepage"}
%
% $Header: /home/cvs/yawtb/tools/help/yahelp.m,v 1.8 2003-06-16 07:35:22 ljacques Exp $
%
% Copyright (C) 2001-2002, the YAWTB Team (see the file AUTHORS distributed with
% this library) (See the notice at the end of the file.)
%% Input manipulations
if ~exist('yafile')
yafile = 'yahelp';
end
if ~exist('section')
section = '';
else
section = upper(section);
end
%% Elements to replace
actions = { ...
%% PATTERN REPLACEMENT
['\manchap' char([10 32 10])], upper(yafile), ...
'\manchap', upper(yafile), ...
'\mansecSyntax', 'SYNTAX', ...
'\mansecDescription', 'DESCRIPTION', ...
'\mansubsecInputData', 'INPUTS', ...
'\mansubsecOutputData', 'OUTPUTS', ...
'\mansecExample', 'EXAMPLE', ...
'\mansecReference', 'REFERENCE', ...
['\mansecSeeAlso' char([10 32 10])], 'SEE ALSO', ...
'\mansecSeeAlso', 'SEE ALSO', ...
'\mansecLicense', 'LICENSE:', ...
'\begin{description}', '', ...
'\end{description}', '', ...
'\item[', '* [', ...
'\begin{itemize}', '', ...
'\end{itemize}', '', ...
'\item', '- ', ...
'\begin{code}', '', ...
'\end{code}', '', ...
'\url{"', '"', ...
'\libfun{', '''', ...
'\libvar{', '''', ...
'\', '', ...
'$', '' };
%% Possible marks. Order is important.
marks = { 'USAGE', 'SYNTAX', 'DESCRIPTION', ...
'INPUTS', 'OUTPUTS', 'CODE', 'EXAMPLE', ...
'REFERENCE', 'SEE ALSO', 'LICENSE' };
if rem(length(actions),1)
error('Check your actions of replacement');
end;
%% Recording standard help
helpfun = help(yafile);
%% Adding some pattern replacements for other section than 'CODE'.
%% In this latter for instance, '{' make sense.
if ((~strcmp('CODE',section)) & (~strcmp('EXAMPLE',section)))
actions = { actions{:}, ...
'{"', '"', ...
'{', '''', ...
'"}', '"', ...
'}', '''' };
end
%% Processing
for k=1:2:length(actions)
helpfun = strrep(helpfun, actions{k}, actions{k+1});
end
%% Possible marks
if isempty(section)
%% Removing License specification
helpfun(strfind(helpfun,'LICENSE'):end) = '';
else
if ~any(strcmp(marks,section))
error('This section is not valid');
end
%% Possible synonyms
switch section
case 'USAGE'
section = 'SYNTAX';
case 'CODE'
section = 'EXAMPLE';
end
first = strfind(helpfun, section);
if isempty(first)
if (nargout == 1)
out = '';
end
return;
end
section_id = find(strcmp(marks,section));
section_id = section_id(1);
nb_sections = length(marks);
last = [];
k = 1;
while isempty(last) & ((section_id + k) < nb_sections)
next_section = marks{section_id+k};
last = strfind(helpfun, next_section);
k = k + 1;
end
if isempty(last)
helpfun = helpfun(first:end);
else
helpfun = helpfun(first:last-1);
end
end
if (nargout == 1)
out = helpfun;
else
disp(helpfun);
end
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA