Simplify postprocessing, remove changes no longer needed, or edit them for Sphinx 2.2.0.

This commit is contained in:
Robin Dunn
2019-10-03 14:52:40 -07:00
parent 04e5f9ebe2
commit 09404e63f5
4 changed files with 29 additions and 25 deletions

View File

@@ -56,6 +56,9 @@ def makeHeadings():
rel_path = os.path.normpath(rel_path).replace('\\', '/')
text += templates.TEMPLATE_HEADINGS % (name, rel_path, width)
# Add custom roles
text += "\n.. role:: html(raw)\n :format: html\n\n"
writeIfChanged(heading_file, text)
# ----------------------------------------------------------------------- #
@@ -68,7 +71,7 @@ def genIndexes(sphinxDir):
main class index and some clean-up/maintenance of the generated ReST
files.
"""
print("Generating indexes...")
pklfiles = glob.glob(sphinxDir + '/*.pkl')
for file in pklfiles:
@@ -519,6 +522,7 @@ def makeModuleIndex(sphinxDir, file):
# ----------------------------------------------------------------------- #
def genGallery():
print("Generating gallery...")
link = '<div class="gallery_class">'
@@ -677,7 +681,6 @@ def postProcess(folder, options):
enum_dict['(<em>%s</em>)'%enum] = new
for files in fileNames:
if "genindex" in files or "modindex" in files:
continue
@@ -694,42 +697,32 @@ def postProcess(folder, options):
else:
text = text.replace('class="headerimage"', 'class="headerimage-noshow"')
text = text.replace('&#8211; <p>', '&#8211; ')
text = text.replace('<p><img alt="overload"', '<br><p><img alt="overload"')
text = text.replace('<strong>Overloaded Implementations</strong>', '<em><strong>Overloaded Implementations</strong></em>')
text = text.replace('<strong>~~~</strong></p>', '<hr style="color:#0000FF;background-color:#0000FF;height:1px;border:none;width:50%;float:left" /></p><br>')
text = text.replace('<p><img alt="contributed"', '<br><p><img alt="contributed"')
text = text.replace(' <p>', ' ')
text = text.replace('Overloaded Implementations:', '<strong>Overloaded Implementations:</strong>')
for item in HTML_REPLACE:
text = text.replace('<dl class="%s">'%item, '<br><hr />\n<dl class="%s">'%item)
if item != 'class':
text = text.replace('<dl class="%s">'%item, '\n<br><hr />\n<dl class="%s">'%item)
newtext = ''
splitted_text = text.splitlines()
len_split = len(splitted_text)
for index, line in enumerate(splitted_text):
if '<div class="admonition-availability admonition' in line:
line = '<div class="admonition-availability admonition availability">'
if index < len_split - 1:
if line.strip() == '<br><hr />' or line.strip() == '<dd><br><hr />':
next_line = splitted_text[index+1]
stripline = next_line.strip()
# repalce the <hr> with a new headline for the first method or first property
if (stripline == '<dl class="staticmethod">' or stripline == '<dl class="method">' \
or stripline == '<dl class="classmethod">') and not methods_done:
line = '<br><h3>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h3>' + '\n' + line
line = '\n<br><h3>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h3>\n'
methods_done = True
elif stripline == '<dl class="attribute">' and not properties_done:
line = '<br><h3>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h3>' + '\n' + line
line = '\n<br><h3>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h3>\n'
properties_done = True
if '<em> ' in line and '&#8211;' in line:
line = line.replace('<em> ', '<em>')
newtext += line + '\n'
for old, new in list(enum_dict.items()):