| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Acegi
Revision: 3273
Author: luke_t
Date: 05 Sep 2008 10:26:26
Changes:Class index generation files
Files:| ... | ...@@ -0,0 +1,90 @@ | |
| 1 | #! /usr/bin/perl | |
| 2 | ||
| 3 | use strict; | |
| 4 | ||
| 5 | # Get list of links to class src packages | |
| 6 | system("curl http://static.springframework.org/spring-security/site/xref/allclasses-frame.html > allclasses-frame.html"); | |
| 7 | my @all_classes = `cat allclasses-frame.html`; | |
| 8 | ||
| 9 | $#all_classes > 0 || die "No lines in xref"; | |
| 10 | ||
| 11 | #<a href="org/springframework/security/vote/AbstractAccessDecisionManager.html" target="classFrame">AbstractAccessDecisionManager</a> | |
| 12 | ||
| 13 | my %classnames_to_src; | |
| 14 | ||
| 15 | while ($_ = pop @all_classes) { | |
| 16 | next unless $_ =~ /<a href="(.*)" target="classFrame">(([a-zA-Z0-9_]+?))<\/a>/; | |
| 17 | $classnames_to_src{$2} = $1; | |
| 18 | } | |
| 19 | ||
| 20 | #my @docbook = glob("*.xml"); | |
| 21 | my @docbook; | |
| 22 | ||
| 23 | # Read the includes rather than using globbing to get the ordering right for the index. | |
| 24 | open MAINDOC, "<springsecurity.xml"; | |
| 25 | while(<MAINDOC>) { | |
| 26 | if (/href="(.*\.xml)"/) { | |
| 27 | push @docbook, $1; | |
| 28 | } | |
| 29 | } | |
| 30 | ||
| 31 | # Hash of xml:id (i.e. anchor) to filename.html#anchor | |
| 32 | my %id_to_html; | |
| 33 | my %class_index; | |
| 34 | ||
| 35 | # Build map of html pages links | |
| 36 | while (my $file = pop @docbook) { | |
| 37 | open FILE, $file or die "$!"; | |
| 38 | print "\nProcessing: $file\n\n"; | |
| 39 | my $file_id; | |
| 40 | while(<FILE>) { | |
| 41 | if (/.* xml:id="([a-z0-9-]+?)"/) { | |
| 42 | $file_id = $1; | |
| 43 | last; | |
| 44 | } | |
| 45 | } | |
| 46 | ||
| 47 | $id_to_html{$file_id} = "$file_id.html#$file_id"; | |
| 48 | ||
| 49 | while (<FILE>) { | |
| 50 | next unless /.* xml:id="([a-z0-9-]+?)"/; | |
| 51 | print "$1\n"; | |
| 52 | $id_to_html{$1} = "$file_id.html#$1"; | |
| 53 | } | |
| 54 | close FILE; | |
| 55 | } | |
| 56 | ||
| 57 | # Get the list of class/interface names and their section ids/titles | |
| 58 | my @class_references = split /;/,`xsltproc --xinclude index-classes.xsl springsecurity.xml`; | |
| 59 | # Get unique values | |
| 60 | my %seen = (); | |
| 61 | @class_references = grep { !$seen{$_}++} @class_references; | |
| 62 | print "\nThere are $#class_references references to classes and interfaces.\n"; | |
| 63 | ||
| 64 | my %id_to_title; | |
| 65 | my %classnames_to_ids = (); | |
| 66 | ||
| 67 | foreach my $class_id_title (@class_references) { | |
| 68 | (my $class, my $id, my $title) = split /:/, $class_id_title; | |
| 69 | $title =~ s/</</; | |
| 70 | $title =~ s/>/>/; | |
| 71 | $id_to_title{$id} = $title; | |
| 72 | push( @{$classnames_to_ids{$class}}, $id ); | |
| 73 | } | |
| 74 | open INDEX, ">classindex.xml" || die "Couldn't open output file\n"; | |
| 75 | print INDEX "<index>\n"; | |
| 76 | foreach my $class (sort keys %classnames_to_ids) { | |
| 77 | print INDEX "<class name='$class'"; | |
| 78 | if (exists $classnames_to_src{$class}) { | |
| 79 | print INDEX " src-xref='$classnames_to_src{$class}'"; | |
| 80 | } | |
| 81 | print INDEX ">\n"; | |
| 82 | foreach my $id (@{$classnames_to_ids{$class}}) { | |
| 83 | print INDEX " <link href='$id_to_html{$id}' title='$id_to_title{$id}'/>\n"; | |
| 84 | } | |
| 85 | print INDEX "</class>\n" | |
| 86 | ||
| 87 | ||
| 88 | } | |
| 89 | print INDEX "</index>\n"; | |
| 90 | close INDEX; |
| ... | ...@@ -0,0 +1,19 @@ | |
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | ||
| 3 | <xsl:stylesheet | |
| 4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:db="http://docbook.org/ns/docbook"> | |
| 5 | <xsl:output method="text"/> | |
| 6 | ||
| 7 | <xsl:template match="db:interfacename|db:classname"> | |
| 8 | <xsl:variable name="classname" select="."/> | |
| 9 | <xsl:for-each select="ancestor::*[@xml:id][1]"> | |
| 10 | <xsl:variable name="title" select="db:info/db:title|db:title"/> | |
| 11 | <xsl:value-of select="concat($classname, ':', @xml:id, ':', $title,';')"/> | |
| 12 | </xsl:for-each> | |
| 13 | </xsl:template> | |
| 14 | ||
| 15 | <xsl:template match="text()|@*|*"> | |
| 16 | <xsl:apply-templates/> | |
| 17 | </xsl:template> | |
| 18 | ||
| 19 | </xsl:stylesheet> | |
| 0 | 20 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,27 @@ | |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
| 3 | <xsl:variable name="src-xref-base">http://static.springframework.org/spring-security/site/xref/</xsl:variable> | |
| 4 | <xsl:variable name="ref-man-base">http://static.springframework.org/spring-security/site/reference/html/</xsl:variable> | |
| 5 | ||
| 6 | <xsl:template match="index"> | |
| 7 | <html> | |
| 8 | <body> | |
| 9 | <h1>Class and Interface Index</h1> | |
| 10 | <xsl:apply-templates /> | |
| 11 | </body> | |
| 12 | </html> | |
| 13 | </xsl:template> | |
| 14 | ||
| 15 | <xsl:template match="class"> | |
| 16 | <h3><xsl:value-of select="@name"/></h3> | |
| 17 | <xsl:if test="@src-xref"> | |
| 18 | <p><xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="concat($src-xref-base, @src-xref)"/></xsl:attribute>Source</xsl:element></p> | |
| 19 | </xsl:if> | |
| 20 | <xsl:for-each select="link"> | |
| 21 | <p><xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="concat($ref-man-base, @href)"/></xsl:attribute><xsl:value-of select="@title"/></xsl:element></p> | |
| 22 | </xsl:for-each> | |
| 23 | </xsl:template> | |
| 24 | ||
| 25 | ||
| 26 | ||
| 27 | </xsl:stylesheet> |