source: trunk/HELP_SOURCE/postxslt.pl

Last change on this file was 19575, checked in by westram, 8 days ago
  • reintegrates 'help' into 'trunk'
    • preformatted text gets checked for width now (to enforce it fits into the arb help window).
    • fixed help following these checks, using the following steps:
      • ignore problems in foreign documentation.
      • increase default help window width.
      • introduce control comments to
        • accept oversized preformatted sections.
        • enforce preformatted style for whole sections.
        • simply define single-line preformatted sections
          Used intensive for definition of internal script languages.
    • fixed several non-related problems found in documentation.
    • minor layout changes for HTML version of arb help (more compacted; highlight anchored/all sections).
    • refactor system interface (GUI version) and use it from help module.
  • adds: log:branches/help@19532:19574
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/usr/bin/perl
2# ========================================================= #
3#                                                           #
4#   File      : postxslt.pl                                 #
5#   Purpose   : abort if xslt printed warnings              #
6#                                                           #
7#   Coded by Ralf Westram (coder@reallysoft.de) in Aug 25   #
8#   http://www.arb-home.de/                                 #
9#                                                           #
10# ========================================================= #
11
12use strict;
13use warnings;
14
15my $exitcode = 0;
16
17sub die_usage($) {
18  my ($err) = @_;
19  print "Usage: postxslt.pl [Options] sourcefile\n";
20  print "Used as compilation output filter for xsltproc\n";
21  print "Options:\n";
22  print "    --fail-if-warning             if warnings occur => fail with error\n";
23  print "    --hide-warnings               hide warnings (will override --fail-if-warning)\n";
24
25  if (defined $err) {
26    die "Error in postxslt.pl: $err";
27  }
28}
29
30sub main() {
31  my $args = scalar(@ARGV);
32  my $fail_if_warning = 0;
33  my $hide_warnings = 0;
34  my $sourcefile = undef;
35
36  while ($args>0) {
37    my $arg = shift(@ARGV);
38    if    ($arg eq '--fail-if-warning') { $fail_if_warning = 1; }
39    elsif ($arg eq '--hide-warnings') { $hide_warnings = 1; }
40    elsif (not defined $sourcefile) { $sourcefile = $arg; }
41    else {
42      die_usage("Unknown argument '$arg'");
43    }
44    $args--;
45  }
46
47  # dynamic configuration:
48  if (defined $sourcefile) {
49    if ($sourcefile =~ /\/agde_/o) {
50      print "activating --hide_warnings for '$sourcefile' (generated from foreign source)\n";
51      $hide_warnings = 1;
52    }
53  }
54  else {
55    $sourcefile = 'unknown';
56  }
57  if ($hide_warnings) {
58    if ($fail_if_warning) { print "disabling --fail-if-warning (caused by --hide_warnings)\n"; }
59    $fail_if_warning = 0;
60  }
61
62  eval {
63    my $warnings = 0;
64    while (defined($_=<STDIN>)) {
65      if (/^Warning:/o) {
66        $warnings++;
67        if (not $hide_warnings) {
68          print $sourcefile.':0: '.$_;
69        }
70      }
71      else {
72        print $_;
73      }
74    }
75    if ($warnings>0) {
76      if ($fail_if_warning) {
77        die "$sourcefile:0: Error: $warnings warnings encountered\n";
78      }
79    }
80  };
81  my $err = $@;
82  if ($err) { die $err; }
83}
84
85main();
86exit $exitcode;
87
Note: See TracBrowser for help on using the repository browser.