Re: Doing bit of gtk-doc work



just changed it myself. sorry for not sending a diff. don't have CVS here right
now. It's just 4 or 5 lines anyway.

Stefan

Stefan Kost wrote:
> hi again,
> 
> Opps, just tried what I posted below. The path are resolved corrently in the
> makefiles and one can see them in the build output. However the resulting docs
> has broken links. Somehow the path are not resolved properly in
> gtkdoc-fixxref::MakeXRef(). Shouldn't that function check for absolute paths?
> 
> Stefan
> 
> Stefan Kost wrote:
> 
>>Hi Damon,
>>
>>I would like to recall the mail I sent on the 29.Sep.2004 that was about
>>gtkdoc-fixxref and different install locations.
>>
>>As an intermediate solution my configure.ac now contains lines like
>>
>>glib_prefix="`pkg-config --variable=prefix glib-2.0`"
>>AC_SUBST(glib-prefix)
>>
>>in the Makefile.am for gtk-doc I then do
>>
>>FIXXREF_OPTIONS=--extra-dir=$(glib_prefix)/share/gtk-doc/html/glib
>>
>>This took me a while to figure. Can we either add this as a HowTo to the docs or
>>has anyone an easier way.
>>
>>Ciao
>>  Stefan
>>
>>
>>Damon Chaplin wrote:
>>
>>
>>>Hi all,
>>>
>>>I'm spending a few days on gtk-doc, basically going through the bugs and
>>>trying to fix as many as possible. We're now down to 15 bugs! (from 27
>>>the other day).
>>>
>>>So now is the time to bring up anything that needs fixing (and add a
>>>bug!). I'll probably get fed up with it in 2 or 3 more days so be quick!
>>>
>>>I'm not doing major new features though, before anyone asks!
>>>
>>>Damon
>>>
>>>
>>>_______________________________________________
>>>gtk-doc-list mailing list
>>>gtk-doc-list gnome org
>>>http://mail.gnome.org/mailman/listinfo/gtk-doc-list
>>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>gtk-doc-list mailing list
>>gtk-doc-list gnome org
>>http://mail.gnome.org/mailman/listinfo/gtk-doc-list
> 
> 

-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -
#!/usr/bin/perl -w
# -*- cperl -*-
#
# gtk-doc - GTK DocBook documentation generator.
# Copyright (C) 1998  Damon Chaplin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

#############################################################################
# Script      : gtkdoc-fixxref
# Description : This fixes cross-references in the HTML documentation.
#############################################################################

use strict;
use bytes;
use Getopt::Long;

# Options

# name of documentation module
my $MODULE;
my $MODULE_DIR;
my $HTML_DIR = "";
my @EXTRA_DIRS;
my $PRINT_VERSION;
my $PRINT_HELP;

my %optctl = (module => \$MODULE,
	      'module-dir' => \$MODULE_DIR,
	      'html-dir' => \$HTML_DIR,
	      'extra-dir' => \ EXTRA_DIRS,
	      'version' => \$PRINT_VERSION,
	      'help' => \$PRINT_HELP);
GetOptions(\%optctl, "module=s", "module-dir=s", "html-dir=s", "extra-dir=s@",
	"version", "help");

if ($PRINT_VERSION) {
    print "1.2\n";
    exit 0;
}

if ($PRINT_HELP) {
    print "gtkdoc-fixxref version 1.2\n";
    print "\n--module=MODULE_NAME    Name of the doc module being parsed";
    print "\n--module-dir=MODULE_DIR The directory which contains the generated HTML";
    print "\n--html-dir=HTML_DIR     The directory where gtk-doc generated documentation is installed";
    print "\n--extra-dir=EXTRA_DIR   Directories to scan for indices in addition to HTML_DIR";
    print "\n                        May be used more than once for multiple directories";
    print "\n--version               Print the version of this program";
    print "\n--help                  Print this help\n";
    exit 0;
}

# This contains all the entities and their relative URLs.
my %Links;

&ScanIndices ($HTML_DIR);
foreach my $dir (@EXTRA_DIRS) {
  &ScanIndices ($dir);
}

&FixCrossReferences (defined $MODULE_DIR ? $MODULE_DIR : "$HTML_DIR/$MODULE");

sub ScanIndices {
    my ($scan_dir) = @_;
#    print "Scanning source directory: $scan_dir\n";

    # This array holds any subdirectories found.
    my (@subdirs) = ();
    
    opendir (HTMLDIR, $scan_dir) || return;
    my $file;
    foreach $file (readdir (HTMLDIR)) {
	if ($file eq '.' || $file eq '..') {
	    next;
	} elsif (-d "$scan_dir/$file") {
	    push (@subdirs, $file);
	} elsif ($file eq "index.sgml") {
	    &ScanIndex ("$scan_dir/$file");
	}
    }
    closedir (HTMLDIR);

    # Now recursively scan the subdirectories.
    my $dir;
    foreach $dir (@subdirs) {
	&ScanIndices ("$scan_dir/$dir");
    }
}

sub ScanIndex {
    my ($file) = @_;
#    print "Scanning index file: $file\n";

    my $dir;
    $file =~ /(.*)\/(.*?)\/index\.sgml/;
    $dir = $1;

    open (INDEXFILE, $file)
	|| die "Can't open $file: $!";
    while (<INDEXFILE>) {
	if (m/^<ANCHOR\s+id\s*=\s*"([^"]*)"\s+href\s*=\s*"([^"]*)"\s*>/) {
#	    print "Found id: $1 href: $2\n";
	    $Links{$1} = "$dir/$2";
	}
    }	
    close (INDEXFILE);
}


sub FixCrossReferences {
    my ($scan_dir) = @_;

    opendir (HTMLDIR, $scan_dir)
	|| die "Can't open HTML directory $scan_dir: $!";
    my $file;
    foreach $file (readdir (HTMLDIR)) {
	if ($file eq '.' || $file eq '..') {
	    next;
	} elsif ($file =~ m/.html?$/) {
	    &FixHTMLFile ("$scan_dir/$file");
	}
    }
    closedir (HTMLDIR);
}


sub FixHTMLFile {
    my ($file) = @_;
#    print "Fixing file: $file\n";

    open (HTMLFILE, $file)
	|| die "Can't open $file: $!";
    undef $/;
    my $entire_file = <HTMLFILE>;
    close (HTMLFILE);

    $entire_file =~ s%<GTKDOCLINK\s+HREF="([^"]*)"\s*>(.*?)</GTKDOCLINK\s*>% &MakeXRef($1, $2); %ge;

    open (NEWFILE, ">$file.new")
	|| die "Can't open $file: $!";
    print NEWFILE $entire_file;
    close (NEWFILE);

    unlink ($file)
	|| die "Can't delete $file: $!";
    rename ("$file.new", $file)
	|| die "Can't rename $file.new: $!";
}


sub MakeXRef {
    my ($id, $text) = @_;

    my $href = $Links{$id};
    if ($href) {
        if($href=~"^/") {
	    return "<a\nhref=\"$href\"\n>$text</a>";
        }
	else {
	    return "<a\nhref=\"../$href\"\n>$text</a>";
        }
    } else {
	return $text;
    }
}
begin:vcard
fn:Stefan Kost
n:Kost;Stefan
org:HTWK Leipzig;FB. IMN
adr:;;Postfach 301166;Leipzig;;04251;Germany
email;internet:kost imn htwk-leipzig de
title:Dipl. Informatiker
tel;work:+49341 30766440
tel;home:+49341 2253538
tel;cell:+49178 3183742
x-mozilla-html:FALSE
url:http://www.imn.htwk-leipzig.de/~kost/about.html
version:2.1
end:vcard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]