tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / odk / docs / idl / wikilinks.py
blob742d874eafa7f434bf0998bd46b652e33eb966e9
1 #!/usr/bin/env python3
2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # wikilinks.py:
12 # This throwaway program can be used to convert idl_chapter_refs.txt to a
13 # "fake" IDL file that can be fed to doxygen to get the DevGuide Wiki links.
15 # Usage:
17 # In core, generate a file letting us know what kinds of entities to declare:
18 # cat <(make -s cmd cmd='$(INSTDIR)/sdk/bin/unoidl-read --summary $(INSTDIR)/program/types.rdb') <(make -s cmd cmd='$(INSTDIR)/sdk/bin/unoidl-read --summary $(INSTDIR)/program/types.rdb $(INSTDIR)/program/types/offapi.rdb') | LC_ALL=C sort | LC_ALL=C uniq > /tmp/kinds
20 # Run the script while feeding it the chapter references and output the fake IDL:
21 # python wikilinks.py < idl_chapter_refs.txt > generated_idl_chapter_refs.idl
23 import sys
25 devguidewww = "https://wiki.documentfoundation.org/"
26 in_topic = False
27 link = None
28 description = None
29 allthings = {}
30 allkinds = {}
32 for line in open("/tmp/kinds") :
33 (kind,_,name) = line.strip().partition(" ")
34 allkinds[name] = kind
36 for line in sys.stdin :
37 sline = line.strip()
38 if sline.startswith("LINK:") :
39 link = sline.partition('LINK:')[2]
40 elif sline.startswith("DESCR:") :
41 description = sline.partition('DESCR:')[2]
42 elif sline == "TOPIC:" :
43 in_topic = True
44 elif in_topic :
45 if sline == "" :
46 in_topic = False
47 elif sline in allthings :
48 allthings[sline].append((link, description))
49 else:
50 allthings[sline] = [(link, description)]
52 print("""/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
53 /* this file was generated from idl_chapter_refs.txt by wikilinks.py */""")
55 for key in allthings:
56 kind = allkinds[key]
57 parts = key.split(".")
58 print("\n")
59 for p in parts[0:-1] :
60 print("module", p, "{")
61 # for enums the "{}" trick results in broken/duplicate output
62 if kind == "enum" :
63 print("/// @" + kind, parts[-1])
64 print("/// @par Developers Guide")
65 for item in allthings[key] :
66 print("/// <a href=\"" + devguidewww + item[0] + "\">"
67 + item[1] + "</a><br>")
68 # doxygen does not have tags for e.g. @service but empty definition works
69 if kind != "enum" :
70 print(kind, parts[-1], "{}")
71 for p in parts[0:-1] :
72 print("};")
74 # vim:set shiftwidth=4 softtabstop=4 expandtab: