Mercurial > octave-nkf
comparison scripts/help/__makeinfo__.m @ 10803:75780a2b0417
__makeinfo__.m: Add support to process @nopsell macro.
Fix bug when more than one @seealso block exists.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 19 Jul 2010 23:33:17 -0700 |
parents | be55736a0783 |
children | 2c356a35d7f5 |
comparison
equal
deleted
inserted
replaced
10802:c7475803e0c0 | 10803:75780a2b0417 |
---|---|
68 | 68 |
69 if (!ischar (output_type)) | 69 if (!ischar (output_type)) |
70 error ("__makeinfo__: second input argument must be a string"); | 70 error ("__makeinfo__: second input argument must be a string"); |
71 endif | 71 endif |
72 | 72 |
73 ## Define the @seealso macro | 73 ## Define the function which expands @seealso macro |
74 if (isempty (see_also)) | 74 if (isempty (see_also)) |
75 if (strcmpi (output_type, "plain text")) | 75 if (strcmpi (output_type, "plain text")) |
76 see_also = @simple_see_also; | 76 see_also = @simple_see_also; |
77 else | 77 else |
78 see_also = @simple_see_also_with_refs; | 78 see_also = @simple_see_also_with_refs; |
81 | 81 |
82 if (!isa (see_also, "function_handle")) | 82 if (!isa (see_also, "function_handle")) |
83 error ("__makeinfo__: third input argument must be the empty matrix, or a function handle"); | 83 error ("__makeinfo__: third input argument must be the empty matrix, or a function handle"); |
84 endif | 84 endif |
85 | 85 |
86 ## It seems like makeinfo sometimes gets angry if the character on a line is | 86 ## It seems like makeinfo sometimes gets angry if the first character |
87 ## a space, so we remove these. | 87 ## on a line is a space, so we remove these. |
88 text = strrep (text, "\n ", "\n"); | 88 text = strrep (text, "\n ", "\n"); |
89 | 89 |
90 ## Handle @seealso macro | 90 ## Handle @seealso macro |
91 SEE_ALSO = "@seealso"; | 91 SEE_ALSO = "@seealso"; |
92 starts = strfind (text, SEE_ALSO); | 92 starts = strfind (text, SEE_ALSO); |
93 for start = starts | 93 for start = fliplr (starts) |
94 if (start == 1 || (text (start-1) != "@")) | 94 if (start == 1 || (text (start-1) != "@")) |
95 bracket_start = find (text (start:end) == "{", 1); | 95 bracket_start = find (text (start:end) == "{", 1); |
96 stop = find (text (start:end) == "}", 1); | 96 stop = find (text (start:end) == "}", 1); |
97 if (!isempty (stop) && !isempty (bracket_start)) | 97 if (!isempty (stop) && !isempty (bracket_start)) |
98 stop += start - 1; | 98 stop += start - 1; |
110 see_also_args = strtrim (strsplit (see_also_args, ",")); | 110 see_also_args = strtrim (strsplit (see_also_args, ",")); |
111 expanded = see_also (see_also_args); | 111 expanded = see_also (see_also_args); |
112 text = strcat (text (1:start-1), expanded, text (stop+1:end)); | 112 text = strcat (text (1:start-1), expanded, text (stop+1:end)); |
113 endif | 113 endif |
114 endfor | 114 endfor |
115 | 115 |
116 ## Handle @nospell macro | |
117 NOSPELL = "@nospell"; | |
118 starts = strfind (text, NOSPELL); | |
119 for start = fliplr (starts) | |
120 if (start == 1 || (text (start-1) != "@")) | |
121 bracket_start = find (text (start:end) == "{", 1); | |
122 stop = find (text (start:end) == "}", 1); | |
123 if (!isempty (stop) && !isempty (bracket_start)) | |
124 stop += start - 1; | |
125 bracket_start += start - 1; | |
126 else | |
127 bracket_start = start + length (NOSPELL); | |
128 stop = find (text (start:end) == "\n", 1); | |
129 if (isempty (stop)) | |
130 stop = length (text); | |
131 else | |
132 stop += start - 1; | |
133 endif | |
134 endif | |
135 text(stop) = []; | |
136 text(start:bracket_start) = []; | |
137 endif | |
138 endfor | |
139 | |
116 if (strcmpi (output_type, "texinfo")) | 140 if (strcmpi (output_type, "texinfo")) |
117 status = 0; | 141 status = 0; |
118 retval = text; | 142 retval = text; |
119 return; | 143 return; |
120 endif | 144 endif |
144 error ("__makeinfo__: unsupported output type: '%s'", output_type); | 168 error ("__makeinfo__: unsupported output type: '%s'", output_type); |
145 endswitch | 169 endswitch |
146 | 170 |
147 ## Call makeinfo | 171 ## Call makeinfo |
148 [status, retval] = system (cmd); | 172 [status, retval] = system (cmd); |
149 | 173 |
150 unwind_protect_cleanup | 174 unwind_protect_cleanup |
151 if (exist (name, "file")) | 175 if (exist (name, "file")) |
152 delete (name); | 176 delete (name); |
153 endif | 177 endif |
154 end_unwind_protect | 178 end_unwind_protect |