source: box/trunk/docs/tools/generate_except_xml.pl @ 2474

Revision 2474, 1.7 KB checked in by chris, 3 years ago (diff)

Reorganise docs in trunk to match distribution layout, which is cleaner,
and makes Makefile work on distributions and trunk equally.

Line 
1#!/usr/bin/perl -w
2use strict;
3
4open (EXCEPT,  "< $ARGV[0]") or die "Can't open $ARGV[0]: $!\n";
5open (DOCBOOK, "> $ARGV[1]") or die "Can't open $ARGV[1] for writing: $!\n";
6
7print DOCBOOK <<EOD;
8<?xml version="1.0" encoding="UTF-8"?>
9
10<appendix>
11    <title>Exception codes</title>
12
13EOD
14my $sectionName;
15my $sectionNum;
16my $sectionDesc;
17my $exceptionCode;
18my $exceptionShortDesc;
19my $exceptionLongDesc;
20while(<EXCEPT>)
21{
22    next if(m/^#/);
23    chomp;
24    if(m/^EXCEPTION TYPE (\w+) (\d+)/)
25    {
26        $sectionName = ucfirst(lc($1));
27        $sectionNum = $2;
28        if($sectionName ne "Common")
29        {
30            $sectionDesc = "the " . $sectionName;
31        }
32        else
33        {
34            $sectionDesc = "any";
35        }
36        print DOCBOOK <<EOD;
37    <section>
38      <title>$sectionName Exceptions ($sectionNum)</title>
39     
40      <para>These are exceptions that can occur in $sectionDesc module
41      of the system.</para>
42     
43      <itemizedlist>
44EOD
45    }
46   
47    # The END TYPE line
48    if(m/^END TYPE$/)
49    {
50        print DOCBOOK "      </itemizedlist>\n    </section>\n";
51    }
52   
53    # The actual exceptions
54    if(m/(\(\d+\/\d+\)) - (\w+ \w+)(?: - )?(.*)$/)
55    {
56        $exceptionCode = $1;
57        $exceptionShortDesc = $2;
58        $exceptionLongDesc = $3;
59       
60        print DOCBOOK "        <listitem>\n          <para><emphasis role=\"bold\">";
61        print DOCBOOK $exceptionCode . ": " . $exceptionShortDesc . "</emphasis>";
62        if($exceptionLongDesc ne "")
63        {
64            print DOCBOOK " -- " . $exceptionLongDesc;
65        }
66        print DOCBOOK "</para>\n        </listitem>\n";
67    }
68}
69
70print DOCBOOK "</appendix>\n";
71
72close EXCEPT;
73close DOCBOOK;
74       
Note: See TracBrowser for help on using the repository browser.