]> mj.ucw.cz Git - libucw.git/blob - build/doc-defs
a39cda40f626983c2150e26e5fc61bdb871d9791
[libucw.git] / build / doc-defs
1 #!/usr/bin/perl
2 # Script for formatting documentation from definition lists
3 # (they get out of extract-doc.pl as a side-product).
4 # (c) 2008 Michal Vaner <vorner@ucw.cz>
5 use strict;
6 use warnings;
7
8 my $head = shift;
9 my $out = shift;
10
11 open OUT, ">$out" or die "Could not write output $out ($!)\n";
12 open HEAD, $head or die "Could not open head $head ($!)\n";
13 print OUT foreach( <HEAD> );
14 close HEAD;
15
16 my $dir = $out;
17 $dir =~ s/\/[^\/]+$//;
18
19 while( defined( my $line = <> ) ) {
20         chomp $line;
21         my( $file, $num, $text ) = split /,/, $line, 3;
22         my $dircp = $dir;
23         while( shift @{[ $dircp =~ /([^\/]+)/, "//" ]} eq shift @{[ $file =~ /([^\/]+)/, "///" ]} ) {
24                 $dircp =~ s/[^\/]+\/?//;
25                 $file =~ s/[^\/]+\/?//;
26         }
27         $dircp =~ s/[^\/]+/../g;
28         $file = $dircp."/".$file;
29         $file =~ s/^\///;
30         $file =~ s/\.[^.]+$//;
31         $text =~ s/\(/!!PARENT_OPEN!!/g;
32         print OUT "- <<$file:auto_$num,`$text`>>\n";
33 }
34
35 close OUT;