QtAutoUpdater  3.0.0
A Qt library to automatically check for updates and install them
doxme.py
1 #!/usr/bin/python
2 # $1 The readme to be transformed
3 # $2 brief description
4 # $pwd: dest dir
5 
6 import sys
7 import os.path
8 
9 def readFirst(line, brief, out):
10  if line[0:2] != "# ":
11  raise ValueError("Expected first line to start with '# '")
12  # skip the first line
13  if brief is not None:
14  out.write(line + "\n");
15  out.write("@brief " + brief + "\n\n")
16  out.write("[TOC]\n\n")
17 
18 readCounter = 0
19 def readMore(line, label, offset, out):
20  global readCounter
21  if line[0:2] == "##":
22  out.write(line[1:] + " {{#qtautoupdater_{}_label_{}}}\n".format(label, readCounter))
23  readCounter += 1
24  else:
25  out.write(line + "\n")
26 
27 #read args
28 readme = sys.argv[1]
29 brief = sys.argv[2] if len(sys.argv) > 2 else None
30 doxme = os.path.basename(readme)
31 label, _ = os.path.splitext(doxme)
32 
33 inFile = open(readme, "r")
34 outFile = open(doxme, "w")
35 
36 isFirst = True
37 for line in inFile:
38  if isFirst:
39  readFirst(line[:-1], brief, outFile)
40  isFirst = False
41  else:
42  readMore(line[:-1], label, 1 if brief is None else 0, outFile)
43 
44 inFile.close();
45 outFile.close();