Fixed: doc generation crash due to bad UTF.

Not clear what's causing the problem, but the ± in CPDate.j get prefixed with some garbage bytes in the Doxygen output even that the input encoding looks fine.

The work-around for now is to just discard the bad bytes in the Python step. The output comes out correct (with the ± preserved).
This commit is contained in:
Alexander Ljungberg
2018-09-10 12:14:35 +01:00
parent 181fb9edb6
commit 9744aa79b3
2 changed files with 13 additions and 5 deletions
@@ -5,6 +5,9 @@
# $1 Cappuccino documentation directory
Encoding.default_external = 'UTF-8'
ACCESSOR_GET_TEMPLATE = <<EOS
/*!
Synthesized accessor method.
@@ -39,7 +42,7 @@ DUMMY_IVAR = " id __doxygen__;"
def makeHeaderFileFrom(fileName)
# Grab the entire file (text)
sourceFile = File.new(fileName, "r")
sourceFile = File.new(fileName, "r", :encoding => 'UTF-8')
source = sourceFile.read
sourceFile.close()
@@ -51,7 +54,7 @@ def makeHeaderFileFrom(fileName)
source.gsub!(/^\s*(@implementation \s*\w+(?:\s*:\s*\w+)?)\n(\s*[^{])/, "\\1\n{\n#{DUMMY_IVAR}\n}\n\\2")
source.gsub!(/^\s*(@implementation \s*\w+(?:\s*:\s*\w+)?)\n\s*\{\s*\}/, "\\1\n{\n#{DUMMY_IVAR}\n}")
sourceFile = File.new(fileName, "w")
sourceFile = File.new(fileName, "w", :encoding => 'UTF-8')
# Remove @accessor declarations from ivars before writing the source file
sourceFile.write(source.gsub(/(\s*\w+\s+\w+)\s+@accessors(\(.+?\))?;/m, "\\1;"))
+8 -3
View File
@@ -28,10 +28,15 @@ transforms = [
html = glob.glob(os.path.join(sys.argv[1], "*.html"))
for count, filename in enumerate(html):
f = open(filename, "r+")
text = f.read()
try:
# For some reason we get some UTF errors in the output HTML. Ignoring them should be fine.
f = open(filename, "r+", encoding='UTF-8', errors='ignore')
text = f.read()
except:
print("Failed to read %s." % filename)
raise
i = 0
while i < len(transforms):
text = transforms[i].sub(transforms[i + 1], text)
i += 2