[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kdoc
Subject:    Array support for variables and typedefs
From:       Wolfgang Bangerth <wolf () gaia ! IWR ! Uni-Heidelberg ! De>
Date:       1998-12-11 16:36:37
[Download RAW message or body]




Hi there,

since I felt the strong desire to again patch a little bit into kdoc,
I did some changes regarding the recognition of arrays in variable
declarations and typedefs like this:
  int a[2];
  typedef typename BoundaryHelper<dim>::local_exported_type \
strange_type[GeometryInfo<dim>::vertices_per_cell];

Basically, nothing more is done than appending some regular
expressions to those that already recognize typedefs and variables,
and add a new property to the respecctive entries in the database.
Also some changes were needed to output the array declarations in HTML
(the diffs look a bit larger than the changes really are because some
lines got too long and I had to wrap them). I did not change things
for the LaTeX, man, etc output, because I do not know much about
that. The changes should be straightforward, however, to the
knowledgeable by looking at the changes made to kdocHTML.

The diffs below are against my own CVS archive of kdoc, in which I
made some additional changes, so line numbers are certainly off from
anyone's version at most places, but I hope I added enough context to
accomplish for that.

Regards,
  Wolfgang


PS: I noted several places with the sequence
           refString(escape($someThing))
This may not be a good choice of order, because escape() mangles
'<' and '>', which gives templates quite another look, and finally
refString() does not find the respective entry in its
database. However, changing the order does not help either, because
then escape() would mangle the '<>' that were thought to indicate
the HTML reference... Anyone has an idea on that?



===================================================================
RCS file: /home/people/cvs/deal/deal.II/doc/kdoc/kdoc,v
retrieving revision 1.8
diff -c -6 -r1.8 kdoc
*** kdoc	1998/09/28 15:53:19	1.8
--- kdoc	1998/12/11 16:22:29
***************
*** 353,366 ****
  			print "CPP: Skipped: $_" if $debug;
  		}
  	}
  
  	#### Typedef
  
! 	elsif( /^\s*typedef\s+(.*)\s+([\w-:_]+)\s*;\s*$/ ) {
! 
  		print "TYPED: $2: $1\n" if $debug;
  
  		if( ( $methInternal == 0 || $docInternal)
  			&& ($methDeprecated == 0  || $docDeprecated) ) {
  
  			addReference( $class."::".$2, $class.".html#".$2 );
--- 353,370 ----
  			print "CPP: Skipped: $_" if $debug;
  		}
  	}
  
  	#### Typedef
  
! 	elsif( /^\s*typedef\s+(.*[&\*\s])\s*([\w-:_]+)\s*(\[[^\]]*\])*;\s*$/ ) {
! 	    #                  1        2           3             4
! 	    # 1: type name, possibly more than one
! 	    # 2: name of new type
! 	    # 3: possible array declaration(s)
! 	    # 4: anything else
  		print "TYPED: $2: $1\n" if $debug;
  
  		if( ( $methInternal == 0 || $docInternal)
  			&& ($methDeprecated == 0  || $docDeprecated) ) {
  
  			addReference( $class."::".$2, $class.".html#".$2 );
***************
*** 373,384 ****
--- 377,389 ----
  			$newNode->AddProp( "Description", $text );
  			$newNode->AddProp( "See", $see );
  			$newNode->AddProp( "MethInternal", $methInternal );
  			$newNode->AddProp( "MethDeprecated", $methDeprecated );
  
  			$newNode->AddProp( "Type", $1 );
+ 			$newNode->AddProp( "Array", $3 );
  		}
  
  		resetMemberDoc();
  	}
  
  	#### Enum
***************
*** 430,449 ****
  	elsif ( /^\s*Q_OBJECT[^\w]+(\/\/.*)?/ ) {
  		# dont do anything
  	}
  
  
  	#### Variables
! 
! 	elsif ( /^[^\(]*$/ && /^[\w_\:\s]+[\&\s*]+[\w_]+\s*;\s*(\/\/.*)?$/ )
  	{
  	    $str = $_;
  	    
! 	    $str =~ /^(.*)([\s&\s\*])([\w_]*)\s*;\s*$/;
! 	    $var = $3;
! 	    $rest = $1.$2;
  
  	
  	    if( ( !$methInternal || $docInternal)
  			    && (!$methDeprecated || $docDeprecated) ) {
  
  		    addReference( $class."::".$var, $class.".html#".$var );
--- 435,466 ----
  	elsif ( /^\s*Q_OBJECT[^\w]+(\/\/.*)?/ ) {
  		# dont do anything
  	}
  
  
  	#### Variables
! 	elsif ( /^[^\(]*$/ && /^[\w_\:\s]+[\&\s*]+[\w_]+\s*(\[[^\]]*\])*\s*;\s*(\/\/.*)?$/ \
                )
! 	    #       1               2        3      4           5                 6
! 	    # 1: variable declarations have no ()
! 	    # 2: data type, possibly several words as in 'unsigned int'
! 	    # 3: reference pointer or at least a space before variable name
! 	    # 4: variable name
! 	    # 5: array declaration
! 	    # 6: spaces and or comments
  	{
  	    $str = $_;
  	    
! 	    # split variable declaration:
! 	    # $1 = data type
! 	    # $2 = reference or pointer (why are there two \s's?)
! 	    # $3 = variable name
! 	    # $4 = array declaration
! 	    $str =~ /^(.+)([\s&\s\*])([\w_]+)\s*((\[[^\]]*\])*)\s*;\s*$/;
! 	    $var               = $3;
! 	    $rest              = $1.$2;
! 	    $array_declaration = $4;
  
  	
  	    if( ( !$methInternal || $docInternal)
  			    && (!$methDeprecated || $docDeprecated) ) {
  
  		    addReference( $class."::".$var, $class.".html#".$var );
***************
*** 453,464 ****
--- 470,482 ----
  		    $text =~ s/^\s*$//g;
  
  		    $newNode = Ast::New( $var );
  		    $classNode->AddPropList( $access, $newNode );
  		    $newNode->AddProp( "Keyword", "property" );
  		    $newNode->AddProp( "Type", $rest );
+ 		    $newNode->AddProp( "Array", $array_declaration);
  		    $newNode->AddProp( "Description", $text );
  		    $newNode->AddProp( "See", $see );
  		    $newNode->AddProp( "MethInternal", $methInternal );
  		    $newNode->AddProp( "MethDeprecated", $methDeprecated );
  	    }
  
Index: kdocHTML.pm
===================================================================
RCS file: /home/people/cvs/deal/deal.II/doc/kdoc/kdocHTML.pm,v
retrieving revision 1.13
diff -c -6 -r1.13 kdocHTML.pm
*** kdocHTML.pm	1998/11/03 18:47:43	1.13
--- kdocHTML.pm	1998/12/11 16:22:29
***************
*** 622,634 ****
  			$link = "href=\"\#";
  		}
  
  		if( $Keyword eq "property" ) {
  			print CLASS escape($Type), 
  				"<b><a ",$link,"ref$linkRef\">",
! 				escape($astNodeName), "</a></b>\n";
  		}
  		elsif( $Keyword eq "method" ) {
  			print CLASS escape($ReturnType),
  				" <b><a ", $link, "ref$linkRef\">",
  				escape($astNodeName), "</a></b> (",
  				escape($Parameters),
--- 622,636 ----
  			$link = "href=\"\#";
  		}
  
  		if( $Keyword eq "property" ) {
  			print CLASS escape($Type), 
  				"<b><a ",$link,"ref$linkRef\">",
! 				escape($astNodeName), "</a></b>",
! 			        escape($Array),
! 			        "\n";
  		}
  		elsif( $Keyword eq "method" ) {
  			print CLASS escape($ReturnType),
  				" <b><a ", $link, "ref$linkRef\">",
  				escape($astNodeName), "</a></b> (",
  				escape($Parameters),
***************
*** 637,650 ****
  		elsif( $Keyword eq "enum" ) {
  			print CLASS "enum <b><a ", $link, "ref$linkRef\">",
  				escape($astNodeName),"</a></b> {",
  				escape($Constants),"}\n";
  		}
  		elsif( $Keyword eq "typedef" ) {
! 			print CLASS "typedef ", $Type, " <b><a ", $link, 
! 				"ref$linkRef\">", escape($astNodeName),"</a></b>";
  		}
  
  		print CLASS "</LI>\n";
  
  		$linkRef += 1;
  
--- 639,653 ----
  		elsif( $Keyword eq "enum" ) {
  			print CLASS "enum <b><a ", $link, "ref$linkRef\">",
  				escape($astNodeName),"</a></b> {",
  				escape($Constants),"}\n";
  		}
  		elsif( $Keyword eq "typedef" ) {
! 			print CLASS "typedef ", escape($Type), " <b><a ", $link, 
! 				"ref$linkRef\">", escape($astNodeName),
! 			        "</a>", escape($Array), "</b>";
  		}
  
  		print CLASS "</LI>\n";
  
  		$linkRef += 1;
  
***************
*** 708,724 ****
  			$linkRef++;
  			Ast::UnVisit();
  			next;
  		}
  			
  		if( $Keyword eq "property" ) {
! 			print CLASS "<H4><b>",refString(escape($Type)), 
! 			"<a name=\"ref",$linkRef,"\"></a>", 
! 			"<a name=\"",$astNodeName,"\">", 
! 			escape($astNodeName), "</a></b><code>[", 
! 			$visibility, "]</code></H4>\n";	
  		}
  		elsif( $Keyword eq "method" ) {
  			$myvis = $visibility;
  
  			if ( $ReturnType =~ /virtual/ ) {
  				$myvis .= " virtual";
--- 711,729 ----
  			$linkRef++;
  			Ast::UnVisit();
  			next;
  		}
  			
  		if( $Keyword eq "property" ) {
! 			print CLASS "<H4><b>",refString(escape($Type)),
! 			"<a name=\"ref",$linkRef,"\"></a>",
! 			"<a name=\"",$astNodeName,"\">",
! 			escape($astNodeName), "</a>",
! 			refString(escape($Array)),
! 			"   </b><font color=gray><code>[", $visibility, "]</code>",
! 			"</font></H4>\n";	
  		}
  		elsif( $Keyword eq "method" ) {
  			$myvis = $visibility;
  
  			if ( $ReturnType =~ /virtual/ ) {
  				$myvis .= " virtual";
***************
*** 733,759 ****
  			print CLASS "<H4><b>",
  			refString(escape($ReturnType)), 
  			" <a name=\"ref",$linkRef,"\"></a>", 
  			"<a name=\"",$astNodeName,"\">", 
  			escape($astNodeName), "</a>(",
  			refString(escape($Parameters)),
! 			") $Const </b><code>[", $myvis, "]</code></H4>\n";
  		}
  		elsif( $Keyword eq "enum" ) {
  			print CLASS "<H4><b>enum <a name=\"ref", 
  			$linkRef,"\"></a>",
  			"<a name=\"",$astNodeName, "\"></a>",
  			escape($astNodeName), " (",
! 			$Constants,") </b><code>[", $visibility, "]</code></H4>\n";
  		}
  		elsif( $Keyword eq "typedef" ) {
  			print CLASS "<H4><b>typedef ",refString(escape($Type)),
! 			"<a name=\"ref", $linkRef,"\"></a>",
! 			" <a ", $link, "ref$linkRef\">", 
! 			escape($astNodeName),"</a> </b><code>[", 
! 			$visibility, "]</code></H4>";
  		}
  
  		print CLASS "<p><strong>Deprecated member.</strong></p>\n" 
  			if $MethDeprecated;
  		print CLASS "<p><strong>For internal use only.</strong></p>\n" 
  			if $MethInternal;
--- 738,767 ----
  			print CLASS "<H4><b>",
  			refString(escape($ReturnType)), 
  			" <a name=\"ref",$linkRef,"\"></a>", 
  			"<a name=\"",$astNodeName,"\">", 
  			escape($astNodeName), "</a>(",
  			refString(escape($Parameters)),
! 			") $Const </b><font color=gray>",
! 			"<code>[", $myvis, "]</code></font></H4>\n";
  		}
  		elsif( $Keyword eq "enum" ) {
  			print CLASS "<H4><b>enum <a name=\"ref", 
  			$linkRef,"\"></a>",
  			"<a name=\"",$astNodeName, "\"></a>",
  			escape($astNodeName), " (",
! 			$Constants,") </b><font color=gray>",
! 			"<code>[", $visibility, "]</code></font></H4>\n";
  		}
  		elsif( $Keyword eq "typedef" ) {
  			print CLASS "<H4><b>typedef ",refString(escape($Type)),
! 			" <a name=\"ref", $linkRef,"\"></a>",
! 			escape($astNodeName),
! 			refString(escape($Array)),
! 			"  </b><font color=gray>",
! 			"<code>[", $visibility, "]</code></font></H4>";
  		}
  
  		print CLASS "<p><strong>Deprecated member.</strong></p>\n" 
  			if $MethDeprecated;
  		print CLASS "<p><strong>For internal use only.</strong></p>\n" 
  			if $MethInternal;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic