Debian Codegraph @

doc/refman/refman2wiki.pl

raw
1 #!/usr/bin/perl
2 #
3 # Copyright (c) 2014, 2017, Norbert Preining. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials
15 # provided with the distribution.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
18 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29
30 $^W=1;
31 use strict;
32
33 open IDX, ">wiki/index.md" || die "Cannot create file wiki/index.md: $!";
34
35 while (<>) {
36 chomp;
37
38 if (m/^## (.*) ## \{#(.*)\}$/) {
39 #print "found header $1 with target $2\n";
40 close FOO;
41 open FOO, ">wiki/$2.md" || die "Cannot create file wiki/$2: $!";
42 print FOO "## $1 ##\n";
43 print IDX "- [$1](/CafeOBJ/cafeobj/wiki/$2)\n";
44 } else {
45 # we need to convert in-document links to urls
46 print FOO necch($_), "\n";
47 }
48 }
49 close IDX;
50
51 sub necch {
52 my $a = shift;
53 $a =~ s!\[([^]]*)\]\(#([^)]*)\)![$1](/CafeOBJ/cafeobj/wiki/$2)!g;
54 $a;
55 }
56