Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / odk / docs / idl / wikilinks.py
blob7854f645063e7b52d61f87648c3c5c881f73627c
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # wikilinks.py:
11 # This throwaway program can be used to convert idl_chapter_refs.txt to a
12 # "fake" IDL file that can be fed to doxygen to get the DevGuide Wiki links.
14 import sys
16 devguidewww = "http://wiki.openoffice.org/wiki/"
17 in_topic = False
18 link = None
19 description = None
20 allthings = {}
21 allkinds = {}
23 # unfortunately we need to know what kind of entity to declare...
24 # generate this file like so:
25 # solver/unxlngx6/bin/regview solver/unxlngx6/bin/types.rdb | grep -A1 "type class:" | awk '/type class:/ { class = $NF } /type name:/ { gsub("/", ".", $NF); gsub("\"", "", $NF); print class, $NF }' > /tmp/kinds
26 for line in open("/tmp/kinds") :
27 (kind,_,name) = line.strip().partition(" ")
28 allkinds[name] = kind
30 for line in sys.stdin :
31 sline = line.strip()
32 if sline.startswith("LINK:") :
33 link = sline.partition('LINK:')[2]
34 elif sline.startswith("DESCR:") :
35 description = sline.partition('DESCR:')[2]
36 elif sline == "TOPIC:" :
37 in_topic = True
38 elif in_topic :
39 if sline == "" :
40 in_topic = False
41 elif sline in allthings :
42 allthings[sline].append((link, description))
43 else:
44 allthings[sline] = [(link, description)]
46 print("/* this file was generated from idl_chapter_refs.txt by wikilinks.py */")
48 for key in allthings:
49 kind = allkinds[key]
50 parts = key.split(".")
51 print("\n")
52 for p in parts[0:-1] :
53 print("module", p, "{")
54 # for enums the "{}" trick results in broken/duplicate output
55 if kind == "enum" :
56 print("/// @" + kind, parts[-1])
57 print("/// @par Developers Guide")
58 for item in allthings[key] :
59 print("/// <a href=\"" + devguidewww + item[0] + "\">"
60 + item[1] + "</a><br>")
61 # doxygen does not have tags for e.g. @service but empty definition works
62 if kind != "enum" :
63 print(kind, parts[-1], "{}")
64 for p in parts[0:-1] :
65 print("};")
67 # vim:set shiftwidth=4 softtabstop=4 expandtab: