|
Packit |
0f19cf |
import os
|
|
Packit |
0f19cf |
import glob
|
|
Packit |
0f19cf |
import re
|
|
Packit |
0f19cf |
from subprocess import Popen, PIPE
|
|
Packit |
0f19cf |
from xml.dom.minidom import parseString
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
def strip_list(lst, patterns):
|
|
Packit |
0f19cf |
striped = []
|
|
Packit |
0f19cf |
for p in lst:
|
|
Packit |
0f19cf |
strip = 0
|
|
Packit |
0f19cf |
for pat in patterns:
|
|
Packit |
0f19cf |
if pat in p:
|
|
Packit |
0f19cf |
strip = 1
|
|
Packit |
0f19cf |
break
|
|
Packit |
0f19cf |
if not(strip):
|
|
Packit |
0f19cf |
striped.append(p)
|
|
Packit |
0f19cf |
return striped
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
def get_doc_params(docparam):
|
|
Packit |
0f19cf |
xsl_params_get = \
|
|
Packit |
0f19cf |
"""
|
|
Packit |
0f19cf |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:output method="text" indent="yes"/>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template match="programlisting">
|
|
Packit |
0f19cf |
<xsl:copy-of select="."/>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
<xsl:template match="/">
|
|
Packit |
0f19cf |
<xsl:apply-templates select="//programlisting"/>
|
|
Packit |
0f19cf |
</xsl:template>
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
</xsl:stylesheet>
|
|
Packit |
0f19cf |
"""
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
xsltmp = "/tmp/getparam.xsl"
|
|
Packit |
0f19cf |
xsl = open("/tmp/getparam.xsl", "w")
|
|
Packit |
0f19cf |
xsl.write(xsl_params_get)
|
|
Packit |
0f19cf |
xsl.close()
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
p = Popen("xsltproc --xinclude %s %s" % (xsltmp, docparam), shell=True,
|
|
Packit |
0f19cf |
stdout=PIPE, )#stderr=open("/dev/null", "w"))
|
|
Packit |
0f19cf |
data = p.communicate()[0].split("\n")
|
|
Packit |
0f19cf |
params = []
|
|
Packit |
0f19cf |
for line in data:
|
|
Packit |
0f19cf |
m = re.search("
|
|
Packit |
0f19cf |
if m:
|
|
Packit |
0f19cf |
params.append(m.group(1)+".xml")
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
return params
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
def get_xsl_params(xslextract, xsltarget):
|
|
Packit |
0f19cf |
# Get the list of all the parameters
|
|
Packit |
0f19cf |
p = Popen("xsltproc %s %s" % (xslextract, xsltarget), shell=True,
|
|
Packit |
0f19cf |
stdout=PIPE, stderr=open("/dev/null", "w"))
|
|
Packit |
0f19cf |
dom = parseString(p.communicate()[0])
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
params = []
|
|
Packit |
0f19cf |
for e in dom.getElementsByTagName("xsl:param"):
|
|
Packit |
0f19cf |
params.append(str(e.getAttribute("name"))+".xml")
|
|
Packit |
0f19cf |
return params
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
def main():
|
|
Packit |
0f19cf |
tooldir = os.path.dirname(__file__)
|
|
Packit |
0f19cf |
topdir = os.path.abspath(os.path.join(tooldir, ".."))
|
|
Packit |
0f19cf |
xslextract = os.path.join(topdir, "tools", "paramextract.xsl")
|
|
Packit |
0f19cf |
xsltarget = os.path.join(topdir, "xsl", "docbook.xsl")
|
|
Packit |
0f19cf |
synopdir = os.path.join(topdir, "docs", "params", "syn")
|
|
Packit |
0f19cf |
refentdir = os.path.join(topdir, "docs", "params")
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# d1 = get_doc_params(os.path.join(refentdir, "param.xml"))
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# parfiles
|
|
Packit |
0f19cf |
parfiles = get_xsl_params(xslextract, xsltarget)
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# Get the list of parameter synopsis
|
|
Packit |
0f19cf |
synfiles = [os.path.basename(f) for f in glob.glob("%s/*.xml" % synopdir)]
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# Get the list of parameter refentries
|
|
Packit |
0f19cf |
reffiles = [os.path.basename(f) for f in glob.glob("%s/*.xml" % refentdir)]
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# Strip parameters we know are not documented
|
|
Packit |
0f19cf |
tostrip = ("l10n", "olink", "chunker", "autolabel",
|
|
Packit |
0f19cf |
"target.database.document", "targets.filename",
|
|
Packit |
0f19cf |
"current.docid")
|
|
Packit |
0f19cf |
parfiles = strip_list(parfiles, tostrip)
|
|
Packit |
0f19cf |
synfiles = strip_list(synfiles, tostrip)
|
|
Packit |
0f19cf |
reffiles = strip_list(reffiles, tostrip)
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
parfiles.sort()
|
|
Packit |
0f19cf |
synfiles.sort()
|
|
Packit |
0f19cf |
reffiles.sort()
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# Strip files that are not parameter refentries
|
|
Packit |
0f19cf |
for p in ("param", "template"):
|
|
Packit |
0f19cf |
reffiles.remove(p+".xml")
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
# Check if there's some missed parameters
|
|
Packit |
0f19cf |
sp = set(parfiles)
|
|
Packit |
0f19cf |
ss = set(synfiles)
|
|
Packit |
0f19cf |
sr = set(reffiles)
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
torem_from_syn = ss - sp
|
|
Packit |
0f19cf |
print "==========="
|
|
Packit |
0f19cf |
print "In param list, missing in %s:\n" % (synopdir), sp - ss
|
|
Packit |
0f19cf |
print "\nIn param list, missing in refentries:\n", sp - sr
|
|
Packit |
0f19cf |
print "\nIn synopsis, not in param list:\n", torem_from_syn
|
|
Packit |
0f19cf |
print "\nIn synopsis, missing in refentries:\n", ss - sr - torem_from_syn
|
|
Packit |
0f19cf |
print "\nIn refentries, missing in %s:\n" % (synopdir), sr - ss
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
|
|
Packit |
0f19cf |
if __name__ == "__main__":
|
|
Packit |
0f19cf |
main()
|