-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandsdoc.py
80 lines (70 loc) · 2.5 KB
/
commandsdoc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Requires Python 3.6 or later
from __future__ import with_statement
import os, sys
scintillaDirectory = os.path.join("..", "..", "scintilla")
scintillaScriptsDirectory = os.path.join(scintillaDirectory, "scripts")
sys.path.append(scintillaScriptsDirectory)
import Face
def head(s):
return "<th>%s</th>" % s
def cell(s):
return "<td>%s</td>" % s
def faceFeatures(out):
out.write("<h2>Scintilla key commands</h2>\n")
out.write("<table>\n")
out.write("<thead><tr>%s%s%s</tr></thead>\n" % (head("Command"), head("Name"), head("Explanation")))
face = Face.Face()
face.ReadFromFile(os.path.join(scintillaDirectory, "include", "Scintilla.iface"))
texts = []
for name in face.features:
#~ print name
f = face.features[name]
if f["FeatureType"] == "fun" and \
f["ReturnType"] == "void" and \
not (f["Param1Type"] or f["Param2Type"]):
texts.append([name, f["Value"], " ".join(f["Comment"])])
texts.sort()
for t in texts:
out.write("<tr>%s%s%s</tr>\n" % (cell(t[1]), cell(t[0]), cell(t[2])))
out.write("</table>\n")
def menuFeatures(out):
out.write("<h2>SciTE menu commands</h2>\n")
out.write("<table>\n")
out.write("<thead><tr>%s%s</tr></thead>\n" % (head("Command"), head("Menu text")))
with open(os.path.join("..", "win32", "SciTERes.rc"), "rt") as f:
for l in f:
l = l.strip()
if l.startswith("MENUITEM") and "SEPARATOR" not in l:
l = l.replace("MENUITEM", "").strip()
text, symbol = l.split('",', 1)
symbol = symbol.strip()
text = text[1:].replace("&", "").replace("...", "")
if "\\t" in text:
text = text.split("\\t",1)[0]
if text:
out.write("<tr><td>%s</td><td>%s</td></tr>\n" % (symbol, text))
out.write("</table>\n")
startFile = """
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--Generated by scite/scripts/commandsdoc.py -->
<style type="text/css">
table { border: 1px solid #1F1F1F; border-collapse: collapse; }
td { border: 1px solid; border-color: #E0E0E0 #000000; padding: 1px 5px 1px 5px; }
th { border: 1px solid #1F1F1F; padding: 1px 5px 1px 5px; }
thead { background-color: #000000; color: #FFFFFF; }
</style>
<body>
"""
def RegenerateAll():
with open(os.path.join("..", "doc", "CommandValues.html"), "w") as out:
out.write(startFile)
menuFeatures(out)
faceFeatures(out)
out.write("</body>\n</html>\n")
if __name__ == "__main__":
RegenerateAll()