summaryrefslogtreecommitdiffstats
path: root/scripts/250_docs
blob: 65f1e30bf0375d46b470e93b1072aebb640cf986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#--------------------------------------------------------------------------------------------------
# Standard modularization template
# --------------------------------
#
# The script will start execution from <QTDIR>.
#
# Available variables:
#     $qtdir    = <QTDIR> or where you started the modularize script from
#     $basepath = path for the modularize script, and basepath for the modularization repo
#     $OStype   = <n> where <n> is one of 0 = Windows, 1 = Unix, 2 = Mac
#
# To execute a command:
#     run("git mv foo bar")        # runs command, reports error possition and dies
#     runNotDie("git mv foo bar")  # runs command, reports error possition, returns error code
#                                    and continues. Use ($? >> 8) to get the real exit code.
#     ensureDir("qtbase")        # Ensures that qtbase exists and is a directory. Will create
#                                    it if it does not exist.
#--------------------------------------------------------------------------------------------------

ensureDir("qtdeclarative/doc/src");
ensureDir("qtbase/doc/src");
ensureDir("activeqt/doc/src");
ensureDir("qtscript/doc/src");
ensureDir("qt3support/doc/src");
ensureDir("qtxmlpatterns/doc/src");
ensureDir("qtxmlpatterns/doc/src/snippets");
 

run("git mv doc/src/declarative             qtdeclarative/doc/src/");
run("git mv doc/src/files-and-resources     qtbase/doc/src/");
run("git mv doc/src/frameworks-technologies/activeqt* activeqt/doc/src/");
# run("git mv doc/src/frameworks-technologies qtbase/doc/src/");
# run("git mv doc/src/internationalization    qtbase/doc/src/");
run("git mv doc/src/network-programming     qtbase/doc/src/");
run("git mv doc/src/objectmodel             qtbase/doc/src/");
run("git mv doc/src/painting-and-printing   qtbase/doc/src/");
run("git mv doc/src/porting                 qt3support/doc/src/");
run("git mv doc/src/scripting               qtscript/doc/src/");
run("git mv doc/src/widgets-and-layouts     qtbase/doc/src/");
run("git mv doc/src/windows-and-dialogs     qtbase/doc/src/");
run("git mv doc/src/xml-processing          qtxmlpatterns/doc/src/");
run("git mv doc/src/sql-programming         qtbase/doc/src/");
run("git mv doc/src/tutorials               qtbase/doc/src/");
run("git mv doc/src/snippets/patternist     qtxmlpatterns/doc/src/snippets/");

#TODO:  to be completed

run("git mv doc/src/examples/activeqt      activeqt/doc/src/examples");

my @processed;

sub processFileRecursive {
    my $module = $_[0];
    my $file = $_[1];
    my $recursive = $_[2];
    if (grep ($_ eq $file, @processed)) {
        return;
    }
    push @processed, $file;
    my $readFd;
    open($readFd, "< $file") or die("Could not open $file");
    while (<$readFd>) {
        if (/(doc\/src\/[a-zA-Z_\-0-9\.\/]+)/) {
            $candidate = $1;
            if (-e "$candidate") {
                ensureDir(dirname("$module/$candidate"));
                run("git mv $candidate $module/$candidate");
                processFileRecursive($module, "$module/$candidate", 1) if $recursive;
            } elsif (!-e "$module/$candidate"){
                print("NOT FOUND! $candidate for $module  ($file)\n")
            }
        } elsif (/\\image ([a-zA-Z_\-0-9\.\/]+.png)/) {
            $candidate = "doc/src/images/$1";
            if (-e "$candidate") {
                ensureDir(dirname("$module/$candidate"));
                run("git mv $candidate $module/$candidate");
            } elsif (!-e "$module/$candidate"){
                print("NOT FOUND! $candidate for $module  ($file)\n")
            }
        }
    }
    close($readFd);
}

sub processModule {
    my $module = $_[0];

    # 1) parse all .cpp files (and .qdoc) in the module src/ folder
    #    to find references to doc files.
    foreach my $file (findFiles("$module/src", ".*\\.(cpp|qdoc|mm)", 1)) {
        processFileRecursive($module, $file, 0);
    }

    # 2) look at the examples
    foreach my $example (findFiles("$module/examples", ".*\\.pro", 1)) {
        $fn = basename(dirname($example));
        $candidate = "doc/src/examples/$fn.qdoc";
        if (-e "$candidate") {
            ensureDir(dirname("$module/$candidate"));
            run("git mv $candidate $module/$candidate");
        }
    }

    # 3) look at the demos
    foreach my $demo (findFiles("$module/demos", ".*\\.pro", 1)) {
        $fn = basename(dirname($demo));
        $candidate = "doc/src/demos/$fn.qdoc";
        if (-e "$candidate") {
            ensureDir(dirname("$module/$candidate"));
            run("git mv $candidate $module/$candidate");
        }
    }

    # 4) look up in the docs recursively for more references
    foreach my $file (findFiles("$module/doc", ".*\\.(cpp|qdoc)", 1)) {
        processFileRecursive($module, $file, 1);
    }
}

processModule("qtbase");
processModule("qtsvg");
processModule("qtxmlpatterns");
processModule("qtscript");
processModule("qtdeclarative");
processModule("activeqt");
processModule("qt3support");
processModule("phonon");

#this one is only referenced by the test file
run("git mv doc/src/snippets/code/src_xmlpatterns_api_qsimplexmlnodemodel.cpp qtxmlpatterns/doc/src/snippets/code/");


#move the remaining
run("git mv doc qtdoc/");


#profiles
createSubdirProfile("qtdoc/tools");
open PRO, ">qtdoc/qtdoc.pro" || die "Could not open qtqdoc.pro for writing!\n";
print PRO "TEMPLATE = subdirs \n";
print PRO "SUBDIRS = tools demos\n";
print PRO "include(doc/doc.pri)\n";
close PRO;
run("git add qtdoc/qtdoc.pro");

return 1;