Mercurial > hg > octave-nkf
view doc/interpreter/munge-texi.pl @ 20657:c6224b4e7774
maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Octave's default save format is '-text' which is confusingly referred to in the
code base as LS_ASCII (looks like '-ascii' mode).
* ls-oct-text.cc, ls-oct-text.h: Renamed from ls-oct-ascii.[cc|h].
* ls-oct-ascii.cc, ls-oct-ascii.h: Removed files.
* libinterp/corefcn/module.mk: Add ls-oct-text.cc, ls-oct-text.h to build
system.
* load-save.h (load_save_format_type): Change first value of enum from
LS_ASCII to LS_TEXT.
* load-save.cc: Rename instances of LS_ASCII to LS_TEXT. Rename instances of
read_ascii_data to read_text_data.
* ov-base-diag.cc, ov-base-int.cc, ov-base-sparse.cc, ov-bool-mat.cc,
ov-bool.cc, ov-complex.cc, ov-cx-mat.cc ov-fcn-inline.cc, ov-float.cc,
ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-perm.cc, ov-re-mat.cc, ov-scalar.cc,
ov-str-mat.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc:
Use '#include "ls-oct-text.h"' rather than ls-oct-ascii.h.
ov-cell.cc, ov-class.cc, ov-fcn-handle.cc, ov-lazy-idx.cc, ov-struct.cc:
Use '#include "ls-oct-text.h"' rather than ls-oct-ascii.h.
Rename save_ascii_data to save_text_data, read_ascii_data to read_text_data.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 17 Aug 2015 09:20:03 -0700 |
parents | 0e1f5a750d00 |
children |
line wrap: on
line source
#!/usr/bin/perl -w # Validate program call die "usage: munge-texi TOP-SRCDIR DOCSTRING-FILE < file" if (@ARGV < 2); $top_srcdir = shift (@ARGV); # Constant patterns $doc_delim = qr/^\x{1d}/; $tex_delim = qr/\Q-*- texinfo -*-\E/; $comment_line = qr/^\s*(?:$|#)/; # Pre-declare hash size for efficiency keys(%help_text) = 1800; ################################################################################ # Load DOCSTRINGS into memory while expanding @seealso references foreach $DOCSTRING_file (@ARGV) { open (DOCFH, $DOCSTRING_file) or die "Unable to open $DOCSTRING_file\n"; # Skip comments while (defined ($_ = <DOCFH>) and /$comment_line/o) {;} # Validate DOCSTRING file format die "invalid doc file format\n" if (! /$doc_delim/o); do { s/\s*$//; # strip EOL character(s) $symbol = substr ($_,1); $docstring = extract_docstring (); if ($help_text{$symbol}) { warn "ignoring duplicate entry for $symbol\n"; } else { $help_text{$symbol} = $docstring; } } while (! eof); } ################################################################################ # Process .txi to .texi by expanding @DOCSTRING, @EXAMPLEFILE macros # Add warning header print '@c DO NOT EDIT! Generated automatically by munge-texi.pl.',"\n\n"; TXI_LINE: while (<STDIN>) { if (/^\s*\@DOCSTRING\((\S+)\)/) { $func = $1; $docstring = $help_text{$func}; if (! $docstring) { warn "no docstring entry for $func\n"; next TXI_LINE; } $func =~ s/^@/@@/; # Texinfo uses @@ to produce '@' $docstring =~ s/^$tex_delim$/\@anchor{XREF$func}/m; print $docstring,"\n"; next TXI_LINE; } if (/^\s*\@EXAMPLEFILE\((\S+)\)/) { $fname = "$top_srcdir/examples/code/$1"; print '@verbatim',"\n"; open (EXAMPFH, $fname) or die "unable to open example file $fname\n"; while (<EXAMPFH>) { print $_; print "\n" if (eof and substr ($_, -1) ne "\n"); } close (EXAMPFH); print '@end verbatim',"\n\n"; next TXI_LINE; } # pass ordinary lines straight through to output print $_; } ################################################################################ # Subroutines ################################################################################ sub extract_docstring { my ($docstring, $arg_list, $func_list, $repl, $rest_of_line); while (defined ($_ = <DOCFH>) and ! /$doc_delim/o) { # expand any @seealso references if (m'^@seealso{') { # Join multiple lines until full macro body found while (! /}/m) { $_ .= <DOCFH>; } ($arg_list, $rest_of_line) = m'^@seealso{(.*)}(.*)?'s; $func_list = $arg_list; $func_list =~ s/\s+//gs; $repl = ""; foreach $func (split (/,/, $func_list)) { $func =~ s/^@/@@/; # Texinfo uses @@ to produce '@' $repl .= "\@ref{XREF$func,,$func}, "; } substr($repl,-2) = ""; # Remove last ', ' $_ = "\@seealso{$repl}$rest_of_line"; } $docstring .= $_; } return $docstring; }