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

2
.gitignore vendored
View File

@@ -27,7 +27,7 @@ mydbstub.py*
/bin/waf3-*
/bin/doxygen-*
/docs/html
/docs/*
/docs/sphinx/*.txt
/docs/sphinx/*.rst
/docs/sphinx/*.pkl

View File

@@ -29,6 +29,11 @@ td.field-body > blockquote {
margin-bottom: 0.5em;
}
table.docutils.align-default tbody tr td p {
margin: 0;
padding: 5px 0 05px;
}
/* spacing around example code */
div.highlight > pre {
padding: 2px 5px 2px 5px;
@@ -744,3 +749,11 @@ table.contentstable p.mybiglink {
line-height: 150%;
}
hr.overloadsep {
color: #0000FF;
background-color: #0000FF;
height: 1px;
border: none;
width: 50%;
float: left;
}

View File

@@ -1985,7 +1985,7 @@ class XMLDocString(object):
if hasattr(xml_item, 'deprecated') and xml_item.deprecated and isinstance(xml_item.deprecated, string_base):
element = et.Element('deprecated', kind='deprecated')
element.text = xml_item.deprecated
deprecated_section = Section(element, None, self.kind, self.is_overload, self.share_docstrings)
self.root.AddSection(deprecated_section)
@@ -2869,15 +2869,13 @@ class XMLDocString(object):
pickleItem(desc, self.current_module, self.class_name, 'class')
if self.overloads:
docstrings += '\n\n%s|overload| Overloaded Implementations:\n\n'%spacer
docstrings += '%s**~~~**\n\n'%spacer
docstrings += '%s:html:`<hr class="overloadsep" /><br />`\n\n'%spacer
for index, over in enumerate(self.overloads):
for line in over.splitlines():
docstrings += spacer + line + '\n'
docstrings += '%s**~~~**\n\n'%spacer
docstrings += '%s:html:`<hr class="overloadsep" /><br />`\n\n'%spacer
if '**Perl Note:**' in docstrings:
index = docstrings.index('**Perl Note:**')

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()):