comparison scripts/help/get_first_help_sentence.m @ 17591:7c479b7d3aab

get_first_help_sentence.m: Fix code for m-files with multiple @deftypefn pairs like gallery (bug #40197). * scripts/help/get_first_help_sentence.m: Remove everything after the first @def block before passing to __makeinfo__.
author Rik <rik@octave.org>
date Mon, 07 Oct 2013 15:16:36 -0700
parents 1c89599167a6
children d63878346099
comparison
equal deleted inserted replaced
17590:a53a97faf61a 17591:7c479b7d3aab
105 if (! isempty (def_idx)) 105 if (! isempty (def_idx))
106 endl_idx = find (help_text == "\n"); 106 endl_idx = find (help_text == "\n");
107 for k = 1:length (def_idx) 107 for k = 1:length (def_idx)
108 endl = endl_idx(find (endl_idx > def_idx(k), 1)); 108 endl = endl_idx(find (endl_idx > def_idx(k), 1));
109 if (isempty (endl)) 109 if (isempty (endl))
110 keep(def_idx(k):end) = false; 110 endl = numel (keep);
111 else
112 keep(def_idx(k):endl) = false;
113 endif 111 endif
112 keep(def_idx(k):endl) = false;
114 endfor 113 endfor
115 114
116 ## Remove the @end ... that corresponds to the @def we removed above 115 ## Remove the @end ... that corresponds to the @def we removed above
117 def1 = def_idx(1); 116 def1 = def_idx(1);
118 space_idx = find (help_text == " "); 117 space_idx = find (help_text == " ");
123 error ("get_first_help_sentence: couldn't parse texinfo"); 122 error ("get_first_help_sentence: couldn't parse texinfo");
124 endif 123 endif
125 sep_idx = min (space_idx, bracket_idx); 124 sep_idx = min (space_idx, bracket_idx);
126 def_type = help_text(def1+1:sep_idx-1); 125 def_type = help_text(def1+1:sep_idx-1);
127 126
128 end_idx = strfind (help_text, sprintf ("@end %s", def_type)); 127 end_idx = strfind (help_text, sprintf ("@end %s", def_type))(1);
129 if (isempty (end_idx)) 128 if (isempty (end_idx))
130 error ("get_first_help_sentence: couldn't parse texinfo"); 129 error ("get_first_help_sentence: couldn't parse texinfo");
131 endif 130 endif
132 endl = endl_idx(find (endl_idx > end_idx, 1)); 131 keep(end_idx:end) = false;
133 if (isempty (endl))
134 keep(end_idx:end) = false;
135 else
136 keep(end_idx:endl) = false;
137 endif
138 132
139 help_text = help_text(keep); 133 help_text = help_text(keep);
140 endif 134 endif
141 135
142 ## Run makeinfo to generate plain text 136 ## Run makeinfo to generate plain text