[Mono-list] System.* galeon bookmarks

Daniel Stodden stodden@in.tum.de
26 Feb 2002 13:12:13 +0100


--=-9F5GMjAsbK1nstqv7jwV
Content-Type: multipart/mixed; boundary="=-Yq5ksDHnNPmDNrStGikB"


--=-Yq5ksDHnNPmDNrStGikB
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable


hi.

i've written a perl script which parses the ecma xml class spec into
an xbel bookmark file linking to msdn online docs. importable by galeon,
with classnames aliased to nicknames, e.g. just typing "UInt32" takes
you directly to the class spec.

found this pretty useful. maybe people around here are interested.

the script is pretty ugly, but just in case someone wants to customize
things for his/her needs.

regards,
dns

--=20
___________________________________________________________________________
 mailto:stodden@in.tum.de

--=-Yq5ksDHnNPmDNrStGikB
Content-Disposition: attachment; filename=parse-ecma-all.pl
Content-Type: text/x-perl; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/perl -w

use XML::Parser;
use XML::Generator;
use Data::Dumper;

$p =3D new XML::Parser( Handlers =3D> { Start =3D> \&start } );

$p->parsefile( $ARGV[0] );

my %NS;

$count =3D 0;

sub start {
    my ( $expat, $element, %attr ) =3D @_;

    if ( $element eq 'Type' ) {

	$string =3D $attr{FullName};
	die( "no FullName\n" ) if ( ! $string );

	$string =3D~ /^(.*)\.([^.]+)$/;
	$namespace =3D $1;
	$class =3D $2;
	@ns =3D split /\./, $namespace;
	die( "no namespace: $string" ) if ( ! @ns );

	print STDERR ( "ns=3D(" . join( ". ", @ns ) . ") class=3D$class\n" );

	$ns =3D \%NS;
	foreach $n ( @ns ) {
	    if ( ! defined( $ns->{$n} ) ) {
		$ns->{$n} =3D {};
	    }
	    $ns =3D $ns->{$n};
	}
=09
	if ( defined($ns->{$class}) ) {
	    die( "$namespace.$class already seen\n" );
	}
	$ns->{$class} =3D '_class';

#  	if ( ++$count =3D=3D 100 ) {=20
#  	    $expat->finish();
#  	}
    }
}


sub urlgen {
    my ( $name, $topic, @ns ) =3D @_;

    $ns =3D join( '', @ns );

    return
      "http://msdn.microsoft.com/library/default.asp?"
	. "url=3D/library/en-us/cpref/html/frlrf"
	  . "$ns$name$topic.asp";
}


sub foldergen {
    my ( $tree, @ns ) =3D @_;

    my @folders;
    my @classes;
    my $numclasses =3D 0;

    print STDERR "foldergen: ", $ns[-1], "\n";

    my $xml =3D XML::Generator->new( pretty =3D> 2,
				   conformance =3D> 'strict' );

    my $count =3D 0;

    foreach $name ( sort keys %$tree ) {
	if ( $tree->{$name} eq '_class' ) {
	    $firstchar =3D ord $name;
	    if ( ! $count[$firstchar] ) {
		$classes[$firstchar] =3D [];
	    }
	    $count[$firstchar] +=3D 1;
	    $count +=3D 1;
	    push @{$classes[$firstchar]},=20
	      $xml->bookmark( { href =3D> urlgen( $name, 'ClassTopic', @ns ) },
			      $xml->info( $xml->metadata( { owner =3D> 'http://galeon.sourceforg=
e.net/' },
							  $xml->nick( $name ) ) ),
			      $xml->title( $name ) );
	} else {
	    push @ns, $name;
	    push @folders,  foldergen( $tree->{$name}, @ns );
	    pop @ns;
	}
    }

    my $maxperfolder =3D 40;
    my @clfolders =3D ();
    if ( $count <=3D $maxperfolder ) {
	foreach $classes ( @classes ) {
	    if ( $classes ) {
		push @clfolders, @{$classes};
	    }
	}
    } else {
	$i =3D ord 'A';
	$done =3D 0;
	while ( ! $done ) {
	    @clfolder =3D ();
	    while ( ! $classes[$i] && ($i <=3D ord 'Z') ) {
		++$i;
	    }
	    $title =3D chr( $i ) . "..";
	    while ( (@clfolder < $maxperfolder) && ( $i <=3D ord 'Z' ) ) {
		if ( $classes[$i] ) {
		    push @clfolder, @{$classes[$i]};
		}
		++$i;
	    }
	    if ( $i > ord 'Z') {
		$done =3D 1;
		$lastchar =3D ord 'Z';
	    } else {
		$lastchar =3D $i-1;
	    }
	    while ( ! $classes[$lastchar] ) {
		--$lastchar;
	    }

	    $title .=3D chr( $lastchar );
	    print STDERR "$title: " . scalar( @clfolder ) . "\n";
	    push @clfolders, $xml->folder( { 'folded' =3D> 'yes' },
					   $xml->title( $title ),
					   @clfolder );
	}
    }

    return $xml->folder( { folded =3D> 'yes' },
			 $xml->title( $ns[-1] ),
			 $xml->bookmark( { 'href' =3D> urlgen( '', '', @ns ) },
 					 $xml->info( $xml->metadata( { owner =3D> 'http://galeon.sourceforge.=
net/' },
 								     $xml->nick( join( '.', @ns ) ) ) ),
					 $xml->title( $ns[-1] ) ),
			 $xml->separator(),
			 @folders,
			 @folders ? $xml->separator() : (),
			 @clfolders );
}

foreach $ns ( keys %NS ) {
    push @folders, foldergen( $NS{$ns}, $ns );
}

my $xml =3D XML::Generator->new( pretty =3D> 2,
			       conformanc =3D> 'strict' );

print "<?xml version=3D\"1.0\"?>\n";
print $xml->xbel( { version =3D> "1.0" }, $xml->title( '.net ECMA' ), @fold=
ers ), "\n";

--=-Yq5ksDHnNPmDNrStGikB
Content-Type: application/x-gzip
Content-Disposition: attachment; filename=dotnet.xbel.gz
Content-Transfer-Encoding: base64

H4sICIe3dTwCA2RvdG5ldC54YmVsANWda2/juBWGv++vGMz3Jt22WBTF7C4yTjJjNDfE8WzRb7TM
2Gwk0qWobLy/vrqLkign00PznAALzG3zvkfPkSiKl8NPv74k8YdnrlOh5M8ffzz588dff/nh08uK
D/72lx8+fPhkhIn5LyeSmw8Xs+uzT6fVXxT/9KjiNdcfyl/WP3/c87T8kfaHFvvU8MT6ifxfVko9
JUw/fdhq/vjzx60xu3+cnibpWp4kItIqVY/mJFLJaSxWmun96Zo/siw2Jyzd/Zrp+Of2H7j8U5ae
Rrtc53Rrkvj0Ucf6sfIs/u86ltxTyEfV/CH/Y8INWzPDPqjfJddtDBsWcyVPUpXpiD8qveHFRZ9+
7H4y/1kpoqf2uso/dLqnjXBrfGo7H4By2lCp/5zyHdPMKP3htP6bSdSt7kzFMY9Mnry0Jx6MuRVA
D/8oAbAU9JNw0rvsfkJcKRkm5S34Btlx5edwhrrc73gkWCz+4OuBCUaWrGgGCXOkDJq06bSd9KgM
U+hO4jiNb2M8SqU7mcjZuGEJ/8bijHf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J7mJYIm5iW8F1MS1LbmJYI+5iW8I1MS1I7mZYYW5mW
HvYyLWltZlpKlpmt0uIPjrum+EAgMN6HdKnkYFuOeXYvTaQigAcCAebggC7pHKCUDjwcyzEyQay8
4FKLwMS1gGEtfp4Mu8+ZiINX9eh8oSRbGTJAUSurjf2hgInWV8sj+6pSc8OqecDglG1zKOK+Fhm+
d0wXY0/B0da+UKqtDA2g31icIdyqrS0Ip6VChCbXafDGtTaFkWw0iHBUYh0YYu4II1gKvHk+rfv9
p9OXFY9/+eF/C5wPH365AQA=

--=-Yq5ksDHnNPmDNrStGikB--

--=-9F5GMjAsbK1nstqv7jwV
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA8e3udSPSplX5M5nQRAnR9AJ4o2HBtj5/4Hn+/HP/v4iaF/aV8QACfX9jf
FCxjiGUEwbL8RQdd/0DHYC4=
=QLIC
-----END PGP SIGNATURE-----

--=-9F5GMjAsbK1nstqv7jwV--