CMake/Utilities/Sphinx/create_identifiers.py
Stephen Kelly b5002631c0 Help: Create proper identifiers for keywords in QtHelp.
This is necessary in order for the QHelpEngineCore::linksForIdentifier API
to work.

 http://doc-snapshot.qt-project.org/qt5-5.3/qhelpenginecore.html#linksForIdentifier

That API is used by QtCreator to enable contextual links to help files.
2014-06-17 11:06:48 +02:00

33 lines
633 B
Python
Executable File

#!/usr/bin/env python
import sys, os
if len(sys.argv) != 2:
sys.exit(-1)
name = sys.argv[1] + "/CMake.qhp"
f = open(name)
if not f:
sys.exit(-1)
lines = f.read().splitlines()
if not lines:
sys.exit(-1)
newlines = []
for line in lines:
if "<keyword name=\"command\"" in line:
if not "id=\"" in line:
prefix = "<keyword name=\"command\" "
part1, part2 = line.split(prefix)
head, tail = part2.split("#command:")
cmdname, rest = tail.split("\"")
line = part1 + prefix + "id=\"command/" + cmdname + "\" " + part2
newlines.append(line + "\n")
f = open(name, "w")
f.writelines(newlines)