You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2012/08/30 21:35:32 UTC

svn commit: r1379083 - in /trafficserver/site/trunk/lib: WikiVar.pm doxy-link.pm

Author: amc
Date: Thu Aug 30 19:35:31 2012
New Revision: 1379083

URL: http://svn.apache.org/viewvc?rev=1379083&view=rev
Log:
Fixed bug in WikiVar, updated WikiVar processing to auto-escape bracketed text that are not WikiVar functions.

Modified:
    trafficserver/site/trunk/lib/WikiVar.pm
    trafficserver/site/trunk/lib/doxy-link.pm

Modified: trafficserver/site/trunk/lib/WikiVar.pm
URL: http://svn.apache.org/viewvc/trafficserver/site/trunk/lib/WikiVar.pm?rev=1379083&r1=1379082&r2=1379083&view=diff
==============================================================================
--- trafficserver/site/trunk/lib/WikiVar.pm (original)
+++ trafficserver/site/trunk/lib/WikiVar.pm Thu Aug 30 19:35:31 2012
@@ -1,16 +1,13 @@
 #
 # WikiVar  -  A class for doing Wiki style variable processing on text.
 # by Alan M. Carroll
-# http://thought-mesh.net
+# http://network-geographics.com
 #
-# Version 1.2.1
-# 04 Dec 2008
-#
-# See the readme or POD for details, installation instructions, and
-# license information.
-#
-# Copyright (c) 2008-2010, Network Geographics, Inc.
+# Version 1.2.3
+# 04 Aug 2012
 #
+# Copyright (c) 2008-2012, Network Geographics, Inc.
+# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
 # -----------------------------------------------------------------------------
 use strict;
 # -----------------------------------------------------------------------------
@@ -148,7 +145,7 @@ sub required_args {
 }
 # -----------------------------------------------------------------------------
 package Text::WikiVar;
-our $VERSION = "1.2.3";
+our $VERSION = '1.2.3';
 
 use constant TRUE => 1;
 use constant FALSE => 0;
@@ -367,6 +364,11 @@ sub _invoke {
     my $errText;
     if (not ref $func) { # simple text, just use it
         $output = $func;
+    } elsif (ref $func eq 'CODE') {
+        $output = eval { &$func(@_); }; # wrap in eval to trap exceptions
+        $errText = 'Error: Invocation of "' . $name
+                 . '" failed because "' . $@ . '"'
+                 if $@; # failure during invocation
     } elsif ($func->isa('Text::WikiVar::CodeRef')) { # something to call
         my $code = $func->getCode();
         if (ref $code eq 'CODE') { # found the code
@@ -655,8 +657,9 @@ and keyword. In general, positional argu
 arguments are optional, but this is by convention. Each argument value is
 delimited in the same way as macro text. Named arguments are indicated by
 putting the undelimited name in front of the argument value E<without
-intervening whitespace>. Keyword arguments are names with a leading keyword mark
-character if keywords have been enabled (keyword arguments are disabled by
+intervening whitespace>. Note that the argument name will be separated from the
+value by a quote character. Keyword arguments are names with a leading keyword
+mark character if keywords have been enabled (keyword arguments are disabled by
 default). Named arguments have values, keyword arguments don't, and positional
 arguments are just values.
 
@@ -666,6 +669,10 @@ passed in the same order as they occur i
 are ignored for the purposes of positional arguments, so that the following are
 equivalent (presuming ':' has been set as the keyword marking character):
 
+If multiple named arguments with the same name are found they are grouped
+together in a single array value. See C<force_array> for a mechanism to force
+the array in all case.q
+
 =over 4
 
 C<$func (arg1) 'arg2' <arg3E<gt> name1(value1) name2%value2% :key1 :key2$>
@@ -703,7 +710,10 @@ The variable delimiter which must be a s
 non-alphanumeric/underscore/dash character. Default value is '$'. Setting this
 to '%' will make invocations look more like normal Wiki variables. Note that the
 value for this will be forbidden for use as a value delimiter (and if set to
-something other than '$', then '$' can be used for delimiting values).
+something other than '$', then '$' can be used for delimiting values). If the
+value is one of the assymmetric delimiters it should be the opening one, the
+closing one will be automatically used. Further the replacement of doubled
+delimiters with a single delimiter will not be done.
 
 =item KEYWORD_MARK
 
@@ -969,6 +979,7 @@ After processing, this yields
     1.1 : 16 May 2008
     1.2 : 26 Oct 2008
     1.2.1 : 04 Dec 2008
+    1.2.3 : 04 Aug 2012
 
 =head1 Author
 
@@ -993,7 +1004,7 @@ customized, more consistent, and more ef
 
 =head1 Copyright and License
 
-    Copyright (c) 2008 Network Geographics Inc.
+    Copyright (c) 2008-2012 Network Geographics Inc.
     (https://network-geographics.com/)
     All rights reserved.
 

Modified: trafficserver/site/trunk/lib/doxy-link.pm
URL: http://svn.apache.org/viewvc/trafficserver/site/trunk/lib/doxy-link.pm?rev=1379083&r1=1379082&r2=1379083&view=diff
==============================================================================
--- trafficserver/site/trunk/lib/doxy-link.pm (original)
+++ trafficserver/site/trunk/lib/doxy-link.pm Thu Aug 30 19:35:31 2012
@@ -22,8 +22,19 @@ our $LOADED_P = 0;
 our $SYMBOLS;
 # Array of source files
 our $FILES;
+
+sub wikivar_fallback {
+    # Just generate the function name, in effect escaping WikiVar uses
+    # that are not defined.
+    return $_[0]->[0];
+}
+
 # Our instance of WikiVar
-our $WV = Text::WikiVar->new(KEYWORD_MARK => ':', DELIMITER => '[');
+our $WV = Text::WikiVar->new
+    ( KEYWORD_MARK => ':'
+    , DELIMITER => '['
+    , FALLBACK => \&wikivar_fallback
+);
 
 sub load_symbol_table {
     my $path = SYMBOL_TABLE_PATH;
@@ -70,7 +81,8 @@ $WV->assign('dox', sub {
         $data = $SYMBOLS->{$src};
         return "[Source file $src for symbol $name not found]" unless $data;
         if (ref $data eq 'ARRAY') {
-            $data = $data->[0]; # Just pick first one for now, need to handle better.
+            # Really we should never encounter this - source files can't have overloads.
+            $data = $data->[0];
         }
     }
     # Generate the link
@@ -78,9 +90,9 @@ $WV->assign('dox', sub {
     $url .= '#' . $data->id if $data->id;
     $link = "<a href=\"$url\"";
     if ($data->arg_text) {
-        $link .= ' alt="'. $data->name . $data->arg_text . '"';
+        $link .= ' title="'. $data->name . $data->arg_text . '"';
     } elsif ($data->text) {
-        $link .= ' alt="' . $data->text . '"'
+        $link .= ' title="' . $data->text . '"'
     }
     $link .= '>' . $data->name . '</a>';
     return $link;