List:Commits« Previous MessageNext Message »
From:mcbrown Date:November 1 2007 2:01pm
Subject:svn commit - mysqldoc@docsrva: r8470 - in trunk: make.d tools tools/MySQL/IDMap
View as plain text  
Author: mcbrown
Date: 2007-11-01 15:01:53 +0100 (Thu, 01 Nov 2007)
New Revision: 8470

Log:
Some more improvements to IDMap in light of the metadata interface

- We now only produce extented info (options, functions, etc) when specifically requested
- Added an idmap-extended make target to enable this
- Added loading of DynDocs info to make parsing <literal> elements more intelligent



Modified:
   trunk/make.d/xml-valid
   trunk/tools/MySQL/IDMap/XMLParser.pm
   trunk/tools/idmap.pl
   trunk/tools/update-dictionaries.pl


Modified: trunk/make.d/xml-valid
===================================================================
--- trunk/make.d/xml-valid	2007-11-01 13:24:28 UTC (rev 8469)
+++ trunk/make.d/xml-valid	2007-11-01 14:01:53 UTC (rev 8470)
Changed blocks: 1, Lines Added: 4, Lines Deleted: 0; 509 bytes

@@ -71,6 +71,10 @@
 	@ echo Rebuilding maps for $(IDMAP_URLBASE)
 	@ $(IDMAP) --debug $(IDMAP_URLBASE) $(IDMAP_SRCS)
 
+idmap-extended: $(IDMAP_SRCS)
+	@ echo Rebuilding maps for $(IDMAP_URLBASE)
+	@ $(IDMAP) --extendinfo --srcdir=$(DYN_SRCDIR) $(IDMAP_URLBASE) $(IDMAP_SRCS)
+
 else
 
 idmap.refs:


Modified: trunk/tools/MySQL/IDMap/XMLParser.pm
===================================================================
--- trunk/tools/MySQL/IDMap/XMLParser.pm	2007-11-01 13:24:28 UTC (rev 8469)
+++ trunk/tools/MySQL/IDMap/XMLParser.pm	2007-11-01 14:01:53 UTC (rev 8470)
Changed blocks: 6, Lines Added: 84, Lines Deleted: 64; 6351 bytes

@@ -23,12 +23,12 @@
 {
     my $self = shift;
     my $class = ref($self) || $self;
-    my $tag = shift;
+    my $parse_options = shift;
 
-    return bless {'tag' => $tag,
+    return bless {'_options' => $parse_options,
                   'foundroot' => 0,
                   'rootid' => undef,
-                  'roottype' => undef,,
+                  'roottype' => undef,
                   'sectionids' => {},
                   'currid' => '',
                   'currsection' => '',

@@ -53,6 +53,8 @@
                   'functions' => {},
                   'infunction' => 0,
                   'functiontext' => '',
+                  'literals' => {},
+                  'literaltext' => '',
               }, $class;
 }
 

@@ -60,36 +62,44 @@
 {
     my ($self, $element) = @_;
 
-    if ($element->{Name} eq 'indexterm')
+    if ($self->{_options}->{extendinfo})
     {
-        $self->{inindex} = 1;
-        $self->{indexlevel} = { 'parent' => $self->{currsection} } ;
-        if (exists($element->{Attributes}->{significance}))
+        if ($element->{Name} eq 'indexterm')
         {
-            $self->{indexlevel}->{significance} = $element->{Attributes}->{significance};
+            $self->{inindex} = 1;
+            $self->{indexlevel} = { 'parent' => $self->{currsection} } ;
+            if (exists($element->{Attributes}->{significance}))
+            {
+                $self->{indexlevel}->{significance} = $element->{Attributes}->{significance};
+            }
         }
-    }
+        
+        if ($element->{Name} =~ m/(primary|secondary|tertiary|see|seealso)/)
+        {
+            $self->{indexlevel}->{$element->{Name}} = '';
+        }
 
-    if ($element->{Name} =~ m/(primary|secondary|tertiary|see|seealso)/)
-    {
-        $self->{indexlevel}->{$element->{Name}} = '';
+        if ($element->{Name} eq 'command')
+        {
+            $self->{incommand} = 1;
+        }
+        
+        if ($element->{Name} eq 'function')
+        {
+            $self->{infunction} = 1;
+        }
+        
+        if ($element->{Name} eq 'literal')
+        {
+            $self->{inliteral} = 1;
+        }
+        
+        if ($element->{Name} eq 'option')
+        {
+            $self->{inoption} = 1;
+        }
     }
 
-    if ($element->{Name} eq 'command')
-    {
-        $self->{incommand} = 1;
-    }
-
-    if ($element->{Name} eq 'function')
-    {
-        $self->{infunction} = 1;
-    }
-
-    if ($element->{Name} eq 'option')
-    {
-        $self->{inoption} = 1;
-    }
-
     if (($element->{Name} eq 'link') ||
         ($element->{Name} eq 'xref'))
     {

@@ -144,8 +154,6 @@
                    'title' => undef,
             };
 
-            
-
             if ($element->{Name} eq 'section' ||
                 $element->{Name} eq 'refsection' ||
                 $element->{Name} eq 'chapter'

@@ -207,44 +215,55 @@
         $self->{currtext} .= sprintf('</%s>',$element->{Name});
     }
 
-    if ($element->{Name} eq 'command')
+    if ($self->{_options}->{extendinfo})
     {
-        $self->{incommand} = 0;
-        $self->{commands}->{$self->{commandtext}}->{$self->{currsection} || ''} = 1;
-        $self->{commandtext} = '';
-    }
-
-    if ($element->{Name} eq 'function')
-    {
-        $self->{infunction} = 0;
-        $self->{functions}->{$self->{functiontext}}->{$self->{currsection} || ''} = 1
-            if ($self->{functiontext} =~ m/\S+/);
-        $self->{functiontext} = '';
-    }
-
-    if ($element->{Name} eq 'option')
-    {
-        $self->{inoption} = 0;
-        $self->{options}->{$self->{optiontext}}->{$self->{currsection} || ''} = 1
-            if ($self->{optiontext} =~ m/\S+/);
-        $self->{optiontext} = '';
-    }
-
-    if ($element->{Name} =~ m/(primary|secondary|tertiary|see|seealso)/)
-    {
-        $self->{indextext} =~ s{^\s+}{};
-        $self->{indextext} =~ s{\s+$}{};
-        $self->{indexlevel}->{$element->{Name}} = $self->{indextext}
+        if ($element->{Name} eq 'command')
+        {
+            $self->{incommand} = 0;
+            $self->{commands}->{$self->{commandtext}}->{$self->{currsection} || ''} = 1;
+            $self->{commandtext} = '';
+        }
+        
+        if ($element->{Name} eq 'function')
+        {
+            $self->{infunction} = 0;
+            $self->{functions}->{$self->{functiontext}}->{$self->{currsection} || ''} = 1
+                if ($self->{functiontext} =~ m/\S+/);
+            $self->{functiontext} = '';
+        }
+        
+        if ($element->{Name} eq 'literal')
+        {
+            $self->{inliteral} = 0;
+            $self->{literals}->{$self->{literaltext}}->{$self->{currsection} || ''} = 1
+                if ($self->{literaltext} =~ m/\S+/);
+            $self->{literaltext} = '';
+        }
+        
+        if ($element->{Name} eq 'option')
+        {
+            $self->{inoption} = 0;
+            $self->{options}->{$self->{optiontext}}->{$self->{currsection} || ''} = 1
+                if ($self->{optiontext} =~ m/\S+/);
+            $self->{optiontext} = '';
+        }
+        
+        if ($element->{Name} =~ m/(primary|secondary|tertiary|see|seealso)/)
+        {
+            $self->{indextext} =~ s{^\s+}{};
+            $self->{indextext} =~ s{\s+$}{};
+            $self->{indexlevel}->{$element->{Name}} = $self->{indextext}
             if ($self->{indextext} =~ m/\S+/);
-        $self->{indextext} = '';
+            $self->{indextext} = '';
+        }
+        
+        if ($element->{Name} eq 'indexterm')
+        {
+            push @{$self->{indexterms}},$self->{indexlevel};
+            $self->{indexlevel} = {};
+            $self->{inindex} = 0;
+        }
     }
-
-    if ($element->{Name} eq 'indexterm')
-    {
-        push @{$self->{indexterms}},$self->{indexlevel};
-        $self->{indexlevel} = {};
-        $self->{inindex} = 0;
-    }
 }    
 
 sub characters

@@ -256,6 +275,7 @@
     $self->{indextext} .= $element->{Data} if ($self->{inindex});
     $self->{commandtext} .= $element->{Data} if ($self->{incommand});
     $self->{functiontext} .= $element->{Data} if ($self->{infunction});
+    $self->{literaltext} .= $element->{Data} if ($self->{inliteral});
     $self->{optiontext} .= $element->{Data} if ($self->{inoption});
 }
 


Modified: trunk/tools/idmap.pl
===================================================================
--- trunk/tools/idmap.pl	2007-11-01 13:24:28 UTC (rev 8469)
+++ trunk/tools/idmap.pl	2007-11-01 14:01:53 UTC (rev 8470)
Changed blocks: 3, Lines Added: 55, Lines Deleted: 4; 2693 bytes

@@ -29,16 +29,26 @@
 use IO::File;
 use Data::Dumper;
 
-# The version of the ID MApping system that this script expects or implements
+# The version of the ID Mapping system that this script expects or implements
 
 my $idmapversion = 3;
 
+# Command line options
+
 my $opt_reconcile = 0;
 my $opt_debug = 0;
+my $opt_extendinfo = 0;
+my $opt_srcdir = '';
 
-GetOptions("reconcile" => \$opt_reconcile,
-           "debug" => \$opt_debug);
+GetOptions(
+    "reconcile" => \$opt_reconcile,
+    "extendinfo" => \$opt_extendinfo,
+    "debug" => \$opt_debug,
+    "srcdir=s" => \$opt_srcdir,
+    );
 
+# Get the document base URL stub
+
 my $urlbase = shift;
 
 print STDERR "$0: DEBUG: URL Base is $urlbase\n" if ($opt_debug);

@@ -100,7 +110,7 @@
 
     mkpath($mapdir);
 
-    my $my_handler = MySQL::IDMap::XMLParser->new();
+    my $my_handler = MySQL::IDMap::XMLParser->new({extendinfo => $opt_extendinfo});
     my $my_dtdhandler = MySQL::IDMap::DTDParser->new();
 
     XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file}, 

@@ -235,6 +245,47 @@
         }
     }
 
+    if (scalar keys %{$my_handler->{literals}} &&
+        $opt_extendinfo)
+    {
+        require MySQL::DynXML;
+        require MySQL::DynXML::ReservedWords;
+        require MySQL::DynXML::Optvar;
+        require MySQL::DynXML::Opfuncs;
+
+# Dynamic Docs stubs
+
+        my $options = {srcdir => $opt_srcdir};
+        
+        my $dynxml = MySQL::DynXML->new();
+        my $OptVars = new MySQL::DynXML::Optvar($dynxml,$options);
+        my $OpFuncs = new MySQL::DynXML::Opfuncs($dynxml,$options);
+
+        my ($optionmap,$opfuncmap);
+        map { $optionmap->{$_} = 1 } $OptVars->generate_dictwords($options);
+        map { $opfuncmap->{$_} = 1 } $OpFuncs->generate_dictwords($options);
+
+        foreach my $literal (keys %{$my_handler->{literals}})
+        {
+            $literal =~ s/\s\s+/ /g;
+
+            if (exists($optionmap->{$literal}))
+            {
+                foreach my $parent (keys %{$my_handler->{literals}->{$literal}})
+                {
+                    $my_handler->{options}->{$literal}->{$parent} = 1;
+                }
+            }
+            if (exists($opfuncmap->{$literal}))
+            {
+                foreach my $parent (keys %{$my_handler->{literals}->{$literal}})
+                {
+                    $my_handler->{functions}->{$literal}->{$parent} = 1;
+                }
+            }
+        }
+    }
+
     if (scalar keys %{$my_handler->{commands}})
     {
         # Write out the entity imports


Modified: trunk/tools/update-dictionaries.pl
===================================================================
--- trunk/tools/update-dictionaries.pl	2007-11-01 13:24:28 UTC (rev 8469)
+++ trunk/tools/update-dictionaries.pl	2007-11-01 14:01:53 UTC (rev 8470)
Changed blocks: 1, Lines Added: 3, Lines Deleted: 3; 569 bytes

@@ -15,9 +15,9 @@
 
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
 use MySQL::DynXML;
-use MySQL::DynXML::Optvar();
-use MySQL::DynXML::Opfuncs();
-use MySQL::DynXML::ReservedWords();
+use MySQL::DynXML::Optvar;
+use MySQL::DynXML::Opfuncs;
+use MySQL::DynXML::ReservedWords;
 
 # Load the local modules
 


Thread
svn commit - mysqldoc@docsrva: r8470 - in trunk: make.d tools tools/MySQL/IDMapmcbrown1 Nov