summaryrefslogtreecommitdiff
path: root/main/misc/genFAQ.py
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2015-05-08 10:39:43 +0200
committerArne Schwabe <arne@rfc2549.org>2015-06-15 09:09:20 +0200
commit15941530f484ec49038642b660102d512893a737 (patch)
tree701b122df0b1fda8ee6d5bc5b21906a2b7f91999 /main/misc/genFAQ.py
parent519e2d26b74b47fbe19da4ad632d1f9d56648aac (diff)
generate FAQ for github, not good yet but better than nothing.
Diffstat (limited to 'main/misc/genFAQ.py')
-rwxr-xr-xmain/misc/genFAQ.py56
1 files changed, 37 insertions, 19 deletions
diff --git a/main/misc/genFAQ.py b/main/misc/genFAQ.py
index d4ddf032..d69a5e6b 100755
--- a/main/misc/genFAQ.py
+++ b/main/misc/genFAQ.py
@@ -5,16 +5,12 @@ import codecs
import xml.dom.minidom as dom
import os.path
import re
+import HTMLParser
-faqpath = "/Users/arne/oss/ics-openvpn.wiki"
+faqpath = "/Users/arne/software/icsopenvpn.ghpages"
-header="""
-<wiki:comment>
-This page is autogenerated. Do not edit
-</wiki:comment>
-= Frequently aksed questions =
-"""
+template = open("misc/header.html").read()
def getString(strid,lang):
ostr=""
@@ -28,6 +24,7 @@ def getString(strid,lang):
ostr = ostr.replace("\\\"","\"")
ostr = ostr.replace("\\'","'")
ostr = ostr.replace("\\n","<p>")
+ ostr= HTMLParser.HTMLParser().unescape(ostr)
return ostr
def genPage(javafile, lang):
@@ -46,19 +43,40 @@ def genPage(javafile, lang):
(ver1, ver2, title, body) = m.groups()
verHeader = getVerHeader(ver1.strip(), ver2.strip(), lang)
- out += "== %s ==\n" % getString(title,lang)
+ section = """<h2>
+ <a name="%(titleid)s"></a>
+ %(title)s
+ <a href="#%(titleid)s" class="section_anchor"> </a>
+ </h2>
+ %(verinfo)s
+ %(content)s
+ """
+
+
if verHeader:
- out += "_%s_\n" % verHeader
-
- out += "%s\n" % getString(body,lang)
+ verinfo += "<small><i>%s</i></small> <br/>\n" % verHeader
+ else:
+ verinfo =""
+
+ content = "%s\n" % getString(body,lang)
if body == "faq_system_dialogs_title":
- out += "%s\n" % getString("faq_system_dialog_xposed",lang)
+ content += "%s\n" % getString("faq_system_dialog_xposed",lang)
+
- elif header:
+ c = {'titleid': title,
+ 'title': getString(title,lang),
+ 'verinfo': verinfo,
+ 'content': content
+ }
+
+ out+=section % c
+
+
+ else:
notmatched = l
- return header + out
+ return out
def getVerHeader(startVersion, endVersion, lang):
if startVersion == "Build.VERSION_CODES.ICE_CREAM_SANDWICH":
@@ -144,7 +162,7 @@ def main():
faqdom = open("src/main/java/de/blinkt/openvpn/fragments/FaqFragment.java").readlines()
faq= genPage(faqdom,"default")
- open(faqpath + "/FAQ.wiki","w").write(faq)
+ open(faqpath + "/FAQ.html","w").write(template % {'content': faq})
for directory in os.listdir("src/main/res"):
if directory.startswith("values-") and directory.find("-sw")==-1 and not directory.startswith("values-v"):
@@ -152,18 +170,18 @@ def main():
print lang
loadstrres("src/main/res/values-%s/strings.xml" % lang,lang)
- langdir= "%s/%s" %(faqpath,lang)
+ langdir= "%s/FAQ-%s" %(faqpath,lang)
if lang=="zh-rCN":
- langdir= "%s/%s" %(faqpath,"zh-Hans")
+ langdir= "%s/FAQ-%s" %(faqpath,"zh-Hans")
elif lang=="zh-rTW":
- langdir= "%s/%s" %(faqpath,"zh-Hant")
+ langdir= "%s/FAQ-%s" %(faqpath,"zh-Hant")
if not os.path.exists(langdir):
os.mkdir(langdir)
faq= genPage(faqdom,lang)
- open("%s/FAQ.wiki" % langdir,"w").write(faq.encode("utf-8"))
+ open("%s.html" % langdir,"w").write(faq.encode("utf-8"))
checkFormatString(lang)