Mercurial > hg > octave-nkf
changeset 13122:f80273b38cc4
more fixes to __makeinfo__
* __makeinfo__.m: fix handling of multiple @seealso macros
and a few style fixes.
author | Carlo de Falco <kingcrimson@tiscali.it> |
---|---|
date | Sun, 11 Sep 2011 11:40:22 +0200 |
parents | 390add500107 |
children | 6efa1a691713 |
files | scripts/help/__makeinfo__.m |
diffstat | 1 files changed, 12 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/help/__makeinfo__.m +++ b/scripts/help/__makeinfo__.m @@ -57,30 +57,32 @@ ## The optional output argument @var{status} contains the exit status of the ## @code{makeinfo} program as returned by @code{system}. -function [retval, status] = __makeinfo__ (text, output_type = "plain text", see_also = []) +function [retval, status] = __makeinfo__ (text, output_type = "plain text", fsee_also) ## Check input if (nargin < 1 || nargin > 3) print_usage (); endif - if (!ischar (text)) + if (! ischar (text)) error ("__makeinfo__: first input argument must be a string"); endif - if (!ischar (output_type)) + if (! ischar (output_type)) error ("__makeinfo__: second input argument must be a string"); endif - if (isempty (see_also)) + if (nargin < 3) if (strcmpi (output_type, "plain text")) - see_also = @simple_see_also; + fsee_also = @(T) strcat ... + ("\nSee also:", sprintf (" %s,", T{:})(1:end-1), "\n"); else - see_also = @simple_see_also_with_refs; + fsee_also = @(T) strcat ... + ("\nSee also:", sprintf (" @ref{%s},", T{:})(1:end-1), "\n"); endif endif - if (!isa (see_also, "function_handle")) + if (! isa (fsee_also, "function_handle")) error (["__makeinfo__: third input argument must ", ... "be the empty matrix, or a function handle"]); endif @@ -94,8 +96,8 @@ see_also_pat = '@seealso *\{([^}]*)\}'; args = regexp (text, see_also_pat, 'tokens'); for ii = 1:numel (args) - expanded = feval (see_also, strtrim (strsplit (args{ii}{:}, ',', true))); - text = regexprep (text, see_also_pat, expanded); + expanded = fsee_also (strtrim (strsplit (args{ii}{:}, ',', true))); + text = regexprep (text, see_also_pat, expanded, 'once'); endfor ## Handle @nospell macro @@ -113,7 +115,7 @@ unwind_protect ## Write Texinfo to tmp file template = "octave-help-XXXXXX"; - [fid, name, msg] = mkstemp (fullfile (P_tmpdir, template), true); + [fid, name] = mkstemp (fullfile (P_tmpdir, template), true); if (fid < 0) error ("__makeinfo__: could not create temporary file"); endif @@ -142,16 +144,6 @@ end_unwind_protect endfunction -function expanded = simple_see_also_with_refs (args) - expanded = strcat ("\nSee also:", sprintf (" @ref{%s},", args {:})); - expanded = strcat (expanded (1:end-1), "\n\n"); -endfunction - -function expanded = simple_see_also (args) - expanded = strcat ("\nSee also:", sprintf (" %s,", args {:})); - expanded = strcat (expanded (1:end-1), "\n\n"); -endfunction - ## No test needed for internal helper function. %!assert (1)