use Texinfo::Report; my $registrar = Texinfo::Report::new(); if ($warning_happened) { $registrar->line_warn($converter, sprintf(__("\@%s is wrongly used"), $current->{'cmdname'}), $current->{'source_info'}); } my ($errors, $errors_count) = $registrar->errors(); foreach my $error_message (@$errors) { warn $error_message->{'error_line'}; } $registrar->clear();
The Texinfo Perl module main purpose is to be used in texi2any
to convert
Texinfo to other formats. There is no promise of API stability.
The Texinfo::Report
module helps with error handling. Errors
and warnings can be setup, stored and retrieved later on.
This module is used by the Texinfo modules Texinfo::Parser and
Texinfo::Convert::Converter.
No method is exported in the default case.
The new
method initializes a Texinfo::Report
object.
The errors collected are available through the errors
method, the other
methods allow registering errors and warnings.
Return an initialized Texinfo::Report
object.
This function returns as $error_count the count of errors since
calling new
. The $error_warnings_list is an array of hash references
one for each error, warning or error line continuation. Each of these has
the following keys:
If set, the line is a continuation line of a message.
The text of the error formatted with the macro name, as needed.
The file name where the error or warning occurs.
The line number of the error or warning.
The user macro name that is expanded at the location of the error or warning.
The text of the error.
May be warning
, or error
.
Clear the previously registered messages.
Register the $msg hash reference corresponding to an error, warning or error line
continuation. The $msg hash reference should correspond to the structure returned
by errors
.
Register a warning or an error. The $text is the text of the
error or warning. The mandatory $error_location_info holds the information
on the error or warning location. The $error_location_info reference on
hash may be obtained from Texinfo elements source_info keys. It may also
be setup to point to a file name, using the file_name
key and to a line
number, using the line_nr
key. The file_name
key value should be a
binary string.
The $continuation optional arguments, if true, conveys that the line is a continuation line of a message.
The $debug optional integer arguments sets the debug level.
The $silent optional arguments, if true, suppresses the output of a message that is output immediatly if debugging is set.
The source_info key of Texinfo tree elements is described in more details in Texinfo::Parser source_info.
Register a document-wide error or warning. $text is the error or warning message. The $program_name is prepended to the message, if defined. The $continuation optional arguments, if true, conveys that the line is a continuation line of a message.
Copyright 2010- Free Software Foundation, Inc. See the source file for all copyright years.
This library 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 3 of the License, or (at your option) any later version.