[docs] xmldocs - docelic modified bin/refs-autogen
docs at icdevgroup.org
docs at icdevgroup.org
Thu Oct 28 15:29:25 EDT 2004
User: docelic
Date: 2004-10-28 19:29:25 GMT
Modified: bin refs-autogen
Log:
Many fixes and improvements, both to get non-unique symbol names working
properly and otherwise.
Revision Changes Path
1.55 +36 -19 xmldocs/bin/refs-autogen
rev 1.55, prev_rev 1.54
Index: refs-autogen
===================================================================
RCS file: /var/cvs/xmldocs/bin/refs-autogen,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- refs-autogen 28 Oct 2004 18:36:40 -0000 1.54
+++ refs-autogen 28 Oct 2004 19:29:25 -0000 1.55
@@ -65,6 +65,7 @@
my $output_both; # Unconditionally override $output_spec
my $no_autodefs; # Generate autodefs.ent collection of entities by default
my $autopath = "docbook/autodefs.ent";
+my %dups; # List of symbols names that are not unique
my @page_order = (qw/purpose default structure synopsis description example notes bugs/, "symbol type", "source", "author", "copyright", "see also");
@@ -175,6 +176,7 @@
# created to uniquely identify items.
if ( $gkey !~ /tag$/ ) {
warn "$key IS BOTH $gk and $gkey!\n" if $verbose;
+ push @{ $dups{$key} }, $gk, $gkey;
goto SKIPDUPCHECK;
}
@@ -491,30 +493,31 @@
# Produce reference sets (docbook element Reference contains RefEntries)
-while (my ($k,$v) = each %symbol_lists ) {
+for my $group ( keys %symbols ) {
# Prepare reference page
my $refpage = <<ENDD;
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DocBook-Interchange XML V4.2//EN"
"../docbook/docbookxi.dtd">
-<reference id="${k}s">
- <title>Interchange Reference Pages: $longname{$k}s</title>
+<reference id="${group}s">
+ <title>Interchange Reference Pages: $longname{$group}s</title>
ENDD
## Add items
- for my $item (sort @$v) {
- $refpage .= $symbols{$k}{$item} if $symbols{$k}{$item}
+ for my $key (sort keys %{ $symbols{$group} }) {
+ $refpage .= $symbols{$group}{$key}
}
## Close up
$refpage .= "\n" . '</reference>';
# Dump page
- open OUT, "> refs/${k}s.xml" or
- die "Can't produce reference refs/$k.xml ($!)\n";
+ open OUT, "> refs/${group}s.xml" or
+ die "Can't produce reference refs/{$group}s.xml ($!)\n";
print OUT $refpage;
close OUT;
+#}
}
@@ -570,6 +573,9 @@
close ATD;
}
+# Boy, did I previously misplace this critical code...
+if ( $dumpdb ) { print STDERR Dumper \%autogenerated; exit 0; }
+
exit 0;
#################################################################
@@ -619,15 +625,29 @@
sub populate {
my ($ref, $group, $name, $file, $mode) = @_;
- my $specpath = "refs/$name.$group"; # Specific path
+ my $fgroup = $group; $fgroup =~ /tag$/ and $fgroup = 'tag';
+ my $specpath = "refs/$name.$fgroup"; # Specific path
my $genpath = "refs/$name"; # Generic path (no type visible in it)
my $refpath = -e $specpath ? $specpath : $genpath; # USE THIS FOR PATHNAME
+ # If symbol name is not unique, then explicit type must be specified.
+ # (That is, the 'value' symbols needs to have refs/value.tag and
+ # refs/value.filter);
+ # Config directives (globconfs/catconfs) can have one file (refs/<name>)
+ # to document both symbols at once.
+ if (
+ $dups{$name} and # Symbol name is non-unique
+ -e $genpath and # Generic file exists (refs/<name>)
+ !-e $specpath and # But special files don't (refs/<name>.<group>)
+ $group !~ /conf$/ ) {# And it's not a config directive for which we tolerate
+ local $" = " AND ";
+ die "Symbol '$name' is: @{ $dups{$name} }. Must have refs/<name>.<type>\n";
+ }
+
# From one specific file (control file usually)
if ( $file ) {
open IN, "< $refpath/$file" or do {
- push @{ $invalid{$name} }, "Requested file '$file' ($!)"
- unless -f "$refpath";
+ push @{ $invalid{$name} }, "Requested file '$file' ($!)";
return;
};
if ( $file eq 'control' ) {
@@ -636,9 +656,11 @@
chomp $line;
$line =~ s/^\s+//;
my ($sect,$text) = split /\s*:\s*/, $line, 2;
- update_field($mode, $name, $ref, $file, $sect, $text)
+ update_field($mode, $group, $name, $ref, $file, $sect, $text)
if ( defined $text and length $text );
}
+ } else {
+ die "TODO: Reading from non-control files not supported.\n";
}
close IN;
@@ -661,7 +683,7 @@
my $content = join "", <INF>;
close INF;
- update_field ("append", $name, $ref, $fn, $sect, $content);
+ update_field ("append", $group, $name, $ref, $fn, $sect, $content);
}
closedir INDIR;
@@ -678,7 +700,7 @@
for my $line (@c) {
if ( $line =~ /^__NAME__ (.+)\s*$/ ) { $section = $1; next }
if ( $line =~ /^__END__/ ) {
- update_field("append", $name, $ref, "$refpath", $section, $content);
+ update_field("append", $group, $name, $ref, "$refpath", $section, $content);
$section = "";
$content = "";
}
@@ -697,7 +719,7 @@
}
sub update_field {
- my ($mode, $name, $sref, $fn, $sect, $content) = @_;
+ my ($mode, $group, $name, $sref, $fn, $sect, $content) = @_;
$sect =~ s/[\-\.\+_:\d].*//;
$sect =~ s/([a-z])([A-Z])/$1 $2/g;
@@ -751,11 +773,6 @@
}
%hash = %{ $refcache{$dbpath} };
-
- if ( $dumpdb ) {
- print STDERR Dumper \%autogenerated;
- exit 0;
- }
}
sub O { print "@_\n"; print STDOUT "@_\n" if $verbose }
More information about the docs
mailing list