summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDirk Baechle <dl9obn@darc.de>2020-06-20 00:45:37 +0200
committerDirk Baechle <dl9obn@darc.de>2020-06-20 13:32:31 +0200
commit869005cb094d9b643da9d326471559f9a13981c1 (patch)
tree6bbb23f39a8c0cb87772fec413e6806659729b21 /bin
parent84c69dfe2d56f87d6cfdaf9c8b7e5e3a9b3d2619 (diff)
downloadscons-git-869005cb094d9b643da9d326471559f9a13981c1.tar.gz
Fixed Sets/Uses links in generated doc files.
Diffstat (limited to 'bin')
-rw-r--r--bin/SConsDoc.py17
-rw-r--r--bin/SConsExamples.py1
-rw-r--r--bin/docs-create-example-outputs.py1
-rw-r--r--bin/docs-update-generated.py1
-rw-r--r--bin/docs-validate.py1
-rw-r--r--bin/scons-proc.py21
6 files changed, 18 insertions, 24 deletions
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index 63aa6102f..d0c79aef4 100644
--- a/bin/SConsDoc.py
+++ b/bin/SConsDoc.py
@@ -24,7 +24,6 @@
#
# Module for handling SCons documentation processing.
#
-# TODO DB Check file encoding for unicode/utf-8
__doc__ = r"""
This module parses home-brew XML files that document various things
@@ -281,6 +280,12 @@ class TreeFactory:
@staticmethod
def getText(root):
return root.text
+
+ @staticmethod
+ def appendCvLink(root, key, lntail):
+ linknode = etree.Entity('cv-link-' + key)
+ linknode.tail = lntail
+ root.append(linknode)
@staticmethod
def setText(root, txt):
@@ -297,25 +302,20 @@ class TreeFactory:
@staticmethod
def writeGenTree(root, fp):
dt = DoctypeDeclaration()
-# TODO DB Check file encoding for unicode/utf-8
fp.write(etree.tostring(root, encoding="utf-8",
pretty_print=True,
- doctype=dt.createDoctype()))
+ doctype=dt.createDoctype()).decode('utf-8'))
@staticmethod
def writeTree(root, fpath):
-# TODO DB Check file encoding for unicode/utf-8
with open(fpath, 'wb') as fp:
-# TODO DB Check file encoding for unicode/utf-8
fp.write(etree.tostring(root, encoding="utf-8",
pretty_print=True))
@staticmethod
def prettyPrintFile(fpath):
-# TODO DB Check file encoding for unicode/utf-8
with open(fpath,'rb') as fin:
tree = etree.parse(fin)
-# TODO DB Check file encoding for unicode/utf-8
pretty_content = etree.tostring(tree, encoding="utf-8",
pretty_print=True)
@@ -403,7 +403,8 @@ class SConsDocTree:
def parseXmlFile(self, fpath):
# Create domtree from file
- domtree = etree.parse(fpath)
+ parser = etree.XMLParser(load_dtd=True, resolve_entities=False)
+ domtree = etree.parse(fpath, parser)
self.root = domtree.getroot()
def __del__(self):
diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py
index bfc900278..46df10333 100644
--- a/bin/SConsExamples.py
+++ b/bin/SConsExamples.py
@@ -85,7 +85,6 @@
# Error output gets passed through to your error output so you
# can see if there are any problems executing the command.
#
-# TODO DB Check file encoding for unicode/utf-8
import os
import re
diff --git a/bin/docs-create-example-outputs.py b/bin/docs-create-example-outputs.py
index e74c547a6..012443533 100644
--- a/bin/docs-create-example-outputs.py
+++ b/bin/docs-create-example-outputs.py
@@ -3,7 +3,6 @@
# Searches through the whole doc/user tree and creates
# all output files for the single examples.
#
-# TODO DB Check file encoding for unicode/utf-8
import os
import sys
import SConsExamples
diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py
index 42264731d..36878965e 100644
--- a/bin/docs-update-generated.py
+++ b/bin/docs-update-generated.py
@@ -6,7 +6,6 @@
# as well as the entity declarations for them.
# Uses scons-proc.py under the hood...
#
-# TODO DB Check file encoding for unicode/utf-8
import os
import sys
import subprocess
diff --git a/bin/docs-validate.py b/bin/docs-validate.py
index 53b6f8626..c4dd3b7f3 100644
--- a/bin/docs-validate.py
+++ b/bin/docs-validate.py
@@ -3,7 +3,6 @@
# Searches through the whole source tree and validates all
# documentation files against our own XSD in docs/xsd.
#
-# TODO DB Check file encoding for unicode/utf-8
import sys,os
import SConsDoc
diff --git a/bin/scons-proc.py b/bin/scons-proc.py
index e1a2d192b..fb9e6df3c 100644
--- a/bin/scons-proc.py
+++ b/bin/scons-proc.py
@@ -9,7 +9,6 @@
# DocBook-formatted generated XML files containing the summary text
# and/or .mod files containing the ENTITY definitions for each item.
#
-# TODO DB Check file encoding for unicode/utf-8
import getopt
import os
import sys
@@ -67,7 +66,6 @@ def parse_docs(args, include_entities=True):
raise
else:
# mode we read (text/bytes) has to match handling in SConsDoc
- # TODO DB Check file encoding for unicode/utf-8
with open(f, 'r') as fp:
content = fp.read()
if content:
@@ -78,14 +76,12 @@ def parse_docs(args, include_entities=True):
raise
return h
-# TODO DB Check file encoding for unicode/utf-8
Warning = """\
<!--
THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
-->
"""
-# TODO DB Check file encoding for unicode/utf-8
Regular_Entities_Header = """\
<!--
@@ -111,7 +107,6 @@ class SCons_XML:
def fopen(self, name, mode='w'):
if name == '-':
return sys.stdout
-# TODO DB Check file encoding for unicode/utf-8
return open(name, mode)
def write(self, files):
@@ -146,16 +141,20 @@ class SCons_XML:
if v.sets:
added = True
vp = stf.newNode("para")
- s = ['&cv-link-%s;' % x for x in v.sets]
- stf.setText(vp, 'Sets: ' + ', '.join(s) + '.')
+ stf.setText(vp, 'Sets: ')
+ for x in v.sets[:-1]:
+ stf.appendCvLink(vp, x, ', ')
+ stf.appendCvLink(vp, v.sets[-1], '.')
stf.appendNode(vl, vp)
if v.uses:
added = True
vp = stf.newNode("para")
- u = ['&cv-link-%s;' % x for x in v.uses]
- stf.setText(vp, 'Uses: ' + ', '.join(u) + '.')
- stf.appendNode(vl, vp)
+ stf.setText(vp, 'Uses: ')
+ for x in v.uses[:-1]:
+ stf.appendCvLink(vp, x, ', ')
+ stf.appendCvLink(vp, v.uses[-1], '.')
+ stf.appendNode(vl, vp)
# Still nothing added to this list item?
if not added:
@@ -167,7 +166,6 @@ class SCons_XML:
stf.appendNode(root, ve)
# Write file
-# TODO DB Check file encoding for unicode/utf-8
f = self.fopen(filename)
stf.writeGenTree(root, f)
f.close()
@@ -188,7 +186,6 @@ class SCons_XML:
f.write('\n')
f.write(Regular_Entities_Header % description)
f.write('\n')
-# TODO DB Check file encoding for unicode/utf-8
for v in self.values:
f.write('<!ENTITY %s%s "<%s xmlns=\'%s\'>%s</%s>">\n' %
(v.prefix, v.idfunc(),