revert between 56095 -> 55830 in arch
[AROS.git] / workbench / locale / help / genindex.py
blob6072915dd68e8212f53e2b9298f435a001a3b639
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2013, The AROS Development Team. All rights reserved.
3 # $Id$
5 """Generate Index.guide.
7 Create index page from the help guide documents.
9 Usage: python genindex.py <helpdir>
11 <helpdir> Index.guide will be placed in that directory. Sub-directories will be scanned
12 for help guides.
13 """
15 import os
16 import sys
17 import datetime
19 def write_section(helpdir, filehandle, section):
20 files = os.listdir(os.path.join(helpdir, section))
21 files.sort()
22 filehandle.write('@NODE %s %s\n' % (section, section))
23 filehandle.write('\n\n@{B}Section "%s"@{UB}\n\n' % (section))
24 for filename in files:
25 if filename[-6:] == ".guide":
26 name = filename[:-6]
27 filehandle.write(' @{" %s " LINK "HELP:English/%s/%s/MAIN"}\n' % (name, section, filename))
28 filehandle.write('@ENDNODE\n\n')
30 ###############################################################################
32 def main():
33 helpdir = sys.argv[1]
34 print "genindex helpdir " + helpdir
36 sections = (
37 ("Commands", "C:"),
38 ("System", "SYS:System, SYS:Tools and SYS:Utilites"),
41 today = datetime.date.today()
43 filehandle = open(os.path.join(helpdir, "Index.guide"), "w")
44 filehandle.write("@DATABASE Index.guide\n\n")
45 filehandle.write("@$VER: Index.guide 1.0 (%d.%d.%d)\n" % (today.day, today.month, today.year))
46 filehandle.write("@(C) Copyright (C) %d, The AROS Development Team. All rights reserved.\n\n" % (today.year))
48 filehandle.write('@NODE MAIN "Help sections"')
49 filehandle.write('\n\n @{B}Section@{TAB}Location of Programs@{UB}\n\n')
50 for section in sections:
51 filehandle.write(' @{" %s " LINK "%s"}@{TAB}%s\n' % (section[0], section[0], section[1]))
52 filehandle.write('@ENDNODE\n\n')
54 for section in sections:
55 write_section(helpdir, filehandle, section[0])
57 filehandle.close()
60 if __name__ == "__main__":
61 main()