mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
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).
48 lines
1.6 KiB
Python
Executable File
48 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
#
|
|
# $1 Generated documentation directory
|
|
|
|
# The following transforms are performed:
|
|
# - Strip useless "[implementation]" littering the docs
|
|
# - Change "Static Public Member Functions" to "Class Methods"
|
|
# - Change "Public Member Functions" to "Instance Methods"
|
|
# - Change "Member Function Documentation" to "Method Documentation"
|
|
# - Remove empty line left at the end of multi-parameter method prototypes
|
|
|
|
import glob
|
|
import os.path
|
|
import re
|
|
import sys
|
|
|
|
transforms = [
|
|
re.compile(r"<code> \[implementation\]</code>"), " ",
|
|
re.compile(r"Static Public Member Functions"), "Class Methods",
|
|
re.compile(r"Public Member Functions"), "Instance Methods",
|
|
re.compile(r"Protected Attributes"), "Instance Variables",
|
|
re.compile(r"Member Function Documentation"), "Method Documentation",
|
|
re.compile(r"Member Data Documentation"), "Instance Variable Documentation",
|
|
re.compile(r"(AppKit|Foundation)\.doc"), r"\1",
|
|
re.compile(r"\s*<tr>\n(\s*<td></td>\n){2}\s*(<td></td>){2}<td> </td>\n\s*</tr>"), ""
|
|
]
|
|
|
|
html = glob.glob(os.path.join(sys.argv[1], "*.html"))
|
|
|
|
for count, filename in enumerate(html):
|
|
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
|
|
|
|
f.seek(0)
|
|
f.truncate()
|
|
f.write(text)
|
|
f.close()
|