summaryrefslogtreecommitdiff
path: root/helpcontent2/help-to-wiki.py
blob: 3ceb7f8c16f7b95a3d24a54bb05be3fd4645eba1 (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
#!/usr/bin/env python

import sys, os

header_template = "\n\
// This file is generated using the Wiki Converter \n\
// Please exercise caution while modifying this file directly \n\
#ifndef __BOOKMARKS_H__\n\
#define __BOOKMARKS_H__\n\
\n\
typedef struct WIKI_LINKS_MAP {\n\
    ULONG           id;         // HELP ID\n\
    const char      *link;      // Mapped Wiki Link\n\
} WikiLinksMap;\n\
\n\
static WikiLinksMap aWikiMaps[] = {\n\
"

footer_template = "\
    { 0, \"\" }\n\
};\n\
\n\
#endif\n\
"

# FIXME do proper modules from getalltitles & wikiconv2
# [so far this is in fact just a shell thing]

def create_wiki_dirs():
    dirs = [
            "All",
            "Basic",
            "Calc",
            "Chart",
            "Draw",
            "Impress",
            "Math",
            "Writer"
           ]

    try:
        os.mkdir( "wiki" )
    except:
        sys.stdout.write( "wiki already generated - the wiki/ subdir exists\n" )
        sys.exit( 1 )

    for i in dirs:
        try:
            os.mkdir( "wiki/" + i )
        except:
            pass

def create_wiki_header():
    file = open( "bookmarks.h", "w" )
    file.write( header_template )
    file.close()

def create_wiki_footer():
    file = open( "bookmarks.h", "a" )
    file.write( footer_template )
    file.close()

# do the work
create_wiki_dirs()

# create bookmarks.h template
create_wiki_header()

print "Generating the titles..."
os.system( "python to-wiki/getalltitles.py source/text > alltitles.csv" )

print "Generating the wiki itself..."
localization = ""
if len(sys.argv) > 1:
    localization = sys.argv[1]
os.system( "python to-wiki/wikiconv2.py "+localization )

# close the bookmarks.h template
create_wiki_footer()

# vim:set shiftwidth=4 softtabstop=4 expandtab: