From 869005cb094d9b643da9d326471559f9a13981c1 Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Sat, 20 Jun 2020 00:45:37 +0200 Subject: Fixed Sets/Uses links in generated doc files. --- bin/SConsDoc.py | 17 +++++++++-------- bin/SConsExamples.py | 1 - bin/docs-create-example-outputs.py | 1 - bin/docs-update-generated.py | 1 - bin/docs-validate.py | 1 - bin/scons-proc.py | 21 +++++++++------------ 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 63aa610..d0c79ae 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 bfc9002..46df103 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 e74c547..0124435 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 4226473..3687896 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 53b6f86..c4dd3b7 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 e1a2d19..fb9e6df 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 = """\ """ -# TODO DB Check file encoding for unicode/utf-8 Regular_Entities_Header = """\