List:Commits« Previous MessageNext Message »
From:mcbrown Date:November 28 2007 6:19pm
Subject:svn commit - mysqldoc@docsrva: r8946 - in trunk/tools/MySQL: . DynXML
View as plain text  
Author: mcbrown
Date: 2007-11-28 19:19:58 +0100 (Wed, 28 Nov 2007)
New Revision: 8946

Log:
Adding BuildOpts to DynXML processors



Added:
   trunk/tools/MySQL/DynXML/BuildOpts.pm
   trunk/tools/MySQL/DynXML/BuildOptsParser.pm
Modified:
   trunk/tools/MySQL/DynXML/Optvar.pm
   trunk/tools/MySQL/DynXMLParse.pm

Property changes on: trunk/tools/MySQL/DynXML/BuildOpts.pm
___________________________________________________________________
Name: svn:executable
   + *


Added: trunk/tools/MySQL/DynXML/BuildOpts.pm
===================================================================
--- trunk/tools/MySQL/DynXML/BuildOpts.pm	                        (rev 0)
+++ trunk/tools/MySQL/DynXML/BuildOpts.pm	2007-11-28 18:19:58 UTC (rev 8946)
Changed blocks: 1, Lines Added: 201, Lines Deleted: 0; 5395 bytes

@@ -0,0 +1,201 @@
+package MySQL::DynXML::BuildOpts;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load MySQL modules
+
+use MySQL::DynXML::BuildOptsParser;
+use MySQL::XML::Writer;
+
+# Load local modules
+
+use Data::Dumper;
+use IO::String;
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+    my $dynxmlcore = shift;
+    my $options = shift;
+
+    return bless {
+        dynxmlcore => $dynxmlcore,
+        options => $options,
+        tdcache => {},
+        sources => {},
+        dependencyreq => 0,
+    }, $class;
+}
+
+sub force_load_xml
+{
+    my ($self,$product,$options) = @_;
+    
+    return($self->load_buildopt_xml($product,$options));
+}
+
+sub validate
+{
+    my ($self,$options) = @_;
+}
+
+sub generate
+{
+    my ($self,$options,$item) = @_;
+    $self->{dependencyreq} = 1;
+
+    my ($tableclass,$tabletype) = ($item =~ m/condition="dynamic:(.*?):(.*?)"/);
+    my ($version,$product,$filter) = ($item =~ m/role="(.*?):(.*?):(.*?)"/);
+
+    $options->{product} = $product;
+
+    if (!exists($self->{tdcache}->{$product}))
+    {
+        $self->load_buildopt_xml($product,$options);
+    }
+
+    my $string;
+
+    if ($tabletype eq 'fullsummary')
+    {
+        $string = $self->generate_fullsummary($version,$options);
+    }
+    return($string);
+}
+
+sub generate_fullsummary
+{
+    my ($self,$version,$options) = @_;
+    # Load the ID maps for the different manual versions
+    my $idmap = MySQL::IDMap->new();
+
+    # Initialize the structure to hold the output
+
+    my $outfile = IO::String->new();
+
+    print $outfile <<EOF;
+<table>
+<title>Build (<literal>configure</literal>) Reference</title>
+<tgroup cols="4">
+<colspec colwidth="30*"/>
+<colspec colwidth="40*"/>
+<colspec colwidth="20*"/>
+<colspec colwidth="10*"/>
+<thead>
+<row>
+<entry><emphasis role="bold">Formats</emphasis></entry>
+<entry><emphasis role="bold">Description</emphasis></entry>
+<entry><emphasis role="bold">Default</emphasis></entry>
+<entry><emphasis role="bold">Introduced</emphasis></entry>
+</row>
+</thead>
+<tbody>
+EOF
+
+my $td = $self->{tdcache}->{$options->{product}};
+
+    foreach my $buildopt (sort keys %{$td})
+    {
+        next unless (exists($td->{$buildopt}->{manualversion}->{$version}));
+
+        if ($buildopt eq 'help')
+        {
+            print STDERR Dumper($td->{$buildopt}),"\n";
+        }
+        
+        my @formats = sort {length($a) <=> length($b) } keys %{$td->{$buildopt}->{formats}};
+
+        my @introduced = grep(m/^$version/,keys %{$td->{$buildopt}->{introduced}});
+
+        my $version = xml_entry('');
+        if (exists ($td->{$buildopt}->{introduced}) && 
+            (scalar @introduced))
+        {
+            $version = xml_entry($introduced[0]);
+        }
+
+        my $basedesc = $td->{$buildopt}->{formats}->{$formats[0]}->{description};
+
+        print $outfile xml_row(xml_entry($formats[0]),
+                               xml_entry($td->{$buildopt}->{formats}->{$formats[0]}->{description}),
+                               xml_entry($td->{$buildopt}->{default} || ''),
+                               $version,
+        );
+        
+        foreach my $format (@formats[1..$#formats])
+        {
+            my $desc = xml_entry('');
+            if ($basedesc ne $td->{$buildopt}->{formats}->{$format}->{description})
+            {
+                $desc = xml_entry($td->{$buildopt}->{formats}->{$format}->{description});
+            }
+
+            print $outfile xml_row(xml_entry($format),
+                                   $desc,
+                                   xml_entry($td->{$buildopt}->{default} || ''),
+                                   xml_entry(''));
+        }
+    }
+    print $outfile "</tbody></tgroup></table>";
+
+    $outfile->pos(0);
+    my $string = join('',<$outfile>);
+    return ($string);
+
+}
+
+sub generate_dependencies
+{
+    my ($self) = @_;
+
+    return('') unless ($self->{dependencyreq});
+
+    my @lines;
+
+    foreach my $file (keys %{$self->{sources}})
+    {
+        push @lines,sprintf('<remark role="dependency" condition="%s"/>',$file);
+    }
+    return(join("\n",@lines));
+}
+
+sub load_buildopt_xml
+{
+    my ($self,$product,$options) = @_;
+
+    my $sourcedir = $options->{usecustombasedir} || 'build-configure';
+
+    my $filename = sprintf('%s/%s/%s.xml',
+                           $options->{srcdir},
+                           $sourcedir,
+                           $product);
+    if (!-f $filename)
+    {
+        print STDERR "WARNING: Couldn't load $filename for parsing ($!)\n";
+        return(undef);
+    }
+ 
+    if (-f $filename)
+    {
+        $self->{sources}->{$filename} = 1;
+
+        my $my_handler = MySQL::DynXML::BuildOptsParser->new();
+
+        XML::Parser::PerlSAX->new->parse(Source => { SystemId => $filename}, 
+                                         Handler => $my_handler,
+                                         );
+        $self->{tdcache}->{$product} = $my_handler->{buildoptions};
+
+        return $self->{tdcache}->{$product};
+    }
+}
+
+1;


Property changes on: trunk/tools/MySQL/DynXML/BuildOpts.pm
___________________________________________________________________
Name: svn:executable
   + *


Added: trunk/tools/MySQL/DynXML/BuildOptsParser.pm
===================================================================
--- trunk/tools/MySQL/DynXML/BuildOptsParser.pm	                        (rev 0)
+++ trunk/tools/MySQL/DynXML/BuildOptsParser.pm	2007-11-28 18:19:58 UTC (rev 8946)
Changed blocks: 1, Lines Added: 118, Lines Deleted: 0; 3044 bytes

@@ -0,0 +1,118 @@
+package MySQL::DynXML::BuildOptsParser;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load local modules
+
+use Digest::MD5 qw(md5_hex);
+use Encode qw(encode_utf8);
+use Data::Dumper; 
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+
+    return bless {
+        'currententry' => {},
+        'currenttext' => [],
+        'remapxmldata' => 0,
+        'savecdata' => 0,
+        'counter' => 0,
+        'custom' => {},
+    }, $class;
+}
+
+sub start_element
+{
+    my ($self, $element) = @_;
+
+    if ($element->{Name} eq 'buildoption')
+    {
+        $self->{currententry} = {id => $element->{Attributes}->{id},
+                                 currentformat => '',
+                                 formats => {},
+                                 description => "",
+                                 introduced => {},
+                                 manualversion => {},
+                        };
+    }
+    elsif ($element->{Name} eq 'formatbase')
+    {
+        $self->{currentformat} = $element->{Attributes}->{format};
+    }
+    elsif ($element->{Name} eq 'description')
+    {
+        $self->{savecdata} = 1;
+    }
+    elsif ($element->{Name} eq 'manual')
+    {
+        $self->{currententry}->{manualversion}->{$element->{Attributes}->{version}} = 1;
+    }
+    elsif ($element->{Name} eq 'introduced')
+    {
+        $self->{currententry}->{introduced}->{$element->{Attributes}->{version}} = 1;
+    }
+    elsif ($element->{Name} eq 'default')
+    {
+        $self->{savecdata} = 1;
+    }
+}
+
+sub end_element
+{
+    my ($self, $element) = @_;
+
+    if ($element->{Name} eq 'buildoption')
+    {
+        $self->{buildoptions}->{$self->{currententry}->{id}} = $self->{currententry};
+        $self->{currententry} = {};
+    }
+    if ($element->{Name} eq 'description')
+    {
+        $self->{currententry}->{formats}->{$self->{currentformat}}->{description} = join('',@{$self->{currenttext}});
+            
+        $self->{savecdata} = 0;
+        $self->{currenttext} = [],
+    }
+    if ($element->{Name} eq 'default')
+    {
+        $self->{currententry}->{default} = join('',@{$self->{currenttext}});
+            
+        $self->{savecdata} = 0;
+        $self->{currenttext} = [],
+    }
+}
+
+sub characters
+{
+    my ($self, $element) = @_;
+
+    if ($self->{savecdata})
+    {
+        my $rawtext = $element->{Data};
+        $rawtext =~ s/&/&amp;/g;
+        $rawtext =~ s/&amp;([a-z_]);/&$1;/g;
+        $rawtext =~ s/</&lt;/g;
+        $rawtext =~ s/>/&gt;/g;
+        
+        push @{$self->{currenttext}},$rawtext;
+    }
+}
+
+sub entity_reference
+{
+    my ($self,$element) = @_;
+
+    push @{$self->{currenttext}},sprintf('&%s;',$element->{Name}) if ($self->{savecdata});
+
+}
+
+1;


Modified: trunk/tools/MySQL/DynXML/Optvar.pm
===================================================================
--- trunk/tools/MySQL/DynXML/Optvar.pm	2007-11-28 16:43:48 UTC (rev 8945)
+++ trunk/tools/MySQL/DynXML/Optvar.pm	2007-11-28 18:19:58 UTC (rev 8946)
Changed blocks: 1, Lines Added: 5, Lines Deleted: 0; 736 bytes

@@ -384,6 +384,11 @@
                     {
                         $linkloc = generate_html_xref($idmap,$td->{$id}->{xrefto});
                     }
+                    if (($ver eq '6.0') &&
+                        exists($idmap->{byprefixid}->{'refman-6.0'}->{$td->{$id}->{xrefto}}))
+                    {
+                        $linkloc = generate_html_xref($idmap,$td->{$id}->{xrefto});
+                    }
 
                     if (defined($linkloc))
                     {


Modified: trunk/tools/MySQL/DynXMLParse.pm
===================================================================
--- trunk/tools/MySQL/DynXMLParse.pm	2007-11-28 16:43:48 UTC (rev 8945)
+++ trunk/tools/MySQL/DynXMLParse.pm	2007-11-28 18:19:58 UTC (rev 8946)
Changed blocks: 3, Lines Added: 11, Lines Deleted: 0; 1227 bytes

@@ -22,6 +22,7 @@
 use MySQL::DynXML::Opfuncs;
 use MySQL::DynXML::ReservedWords;
 use MySQL::DynXML::Changelog;
+use MySQL::DynXML::BuildOpts;
 
 # Load the local modules
 

@@ -44,6 +45,7 @@
         reservedwords => undef,
         changelog => undef,
         openbugs => undef,
+        buildopts => undef,
     };
 
     my $dynxml = new MySQL::DynXML();

@@ -81,6 +83,15 @@
             }
             $string = $DynXMLParsers->{opfuncs}->generate($parser_options,$item);
         }
+        elsif ($inserttype eq 'buildopts')
+        {
+            if (!exists($DynXMLParsers->{buildopts}) || 
+                !defined($DynXMLParsers->{buildopts}))
+            {
+                $DynXMLParsers->{buildopts} = new MySQL::DynXML::BuildOpts($dynxml,$parser_options);
+            }
+            $string = $DynXMLParsers->{buildopts}->generate($parser_options,$item);
+        }
         elsif ($inserttype eq 'reservedwords')
         {
             if (!exists($DynXMLParsers->{reserveredwords}) || 


Thread
svn commit - mysqldoc@docsrva: r8946 - in trunk/tools/MySQL: . DynXMLmcbrown28 Nov