mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-14 21:24:59 +00:00
Cleaned up docs/
- Linted - Changed Github-Api-Wrapper to GitHub-API-Wrapper
This commit is contained in:
parent
a33985c69b
commit
f6b9852167
10 changed files with 219 additions and 174 deletions
|
@ -6,11 +6,11 @@ from sphinx.writers.html5 import HTML5Translator
|
|||
class DPYHTML5Translator(HTML5Translator):
|
||||
def visit_section(self, node):
|
||||
self.section_level += 1
|
||||
self.body.append(self.starttag(node, 'section'))
|
||||
self.body.append(self.starttag(node, "section"))
|
||||
|
||||
def depart_section(self, node):
|
||||
self.section_level -= 1
|
||||
self.body.append('</section>\n')
|
||||
self.body.append("</section>\n")
|
||||
|
||||
def visit_table(self, node):
|
||||
self.body.append('<div class="table-wrapper">')
|
||||
|
@ -18,7 +18,7 @@ class DPYHTML5Translator(HTML5Translator):
|
|||
|
||||
def depart_table(self, node):
|
||||
super().depart_table(node)
|
||||
self.body.append('</div>')
|
||||
self.body.append("</div>")
|
||||
|
||||
|
||||
class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
||||
|
@ -32,45 +32,46 @@ class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
|||
indexcounts.append(sum(1 + len(subitems) for _, (_, subitems, _) in entries))
|
||||
|
||||
genindexcontext = {
|
||||
'genindexentries': genindex,
|
||||
'genindexcounts': indexcounts,
|
||||
'split_index': self.config.html_split_index,
|
||||
"genindexentries": genindex,
|
||||
"genindexcounts": indexcounts,
|
||||
"split_index": self.config.html_split_index,
|
||||
}
|
||||
|
||||
if self.config.html_split_index:
|
||||
self.handle_page('genindex', genindexcontext, 'genindex-split.html')
|
||||
self.handle_page('genindex-all', genindexcontext, 'genindex.html')
|
||||
self.handle_page("genindex", genindexcontext, "genindex-split.html")
|
||||
self.handle_page("genindex-all", genindexcontext, "genindex.html")
|
||||
for (key, entries), count in zip(genindex, indexcounts):
|
||||
ctx = {'key': key, 'entries': entries, 'count': count, 'genindexentries': genindex}
|
||||
self.handle_page(f"genindex-{key}", ctx, 'genindex-single.html')
|
||||
ctx = {"key": key, "entries": entries, "count": count, "genindexentries": genindex}
|
||||
self.handle_page(f"genindex-{key}", ctx, "genindex-single.html")
|
||||
else:
|
||||
self.handle_page('genindex', genindexcontext, 'genindex.html')
|
||||
self.handle_page("genindex", genindexcontext, "genindex.html")
|
||||
|
||||
|
||||
def add_custom_jinja2(app):
|
||||
env = app.builder.templates.environment
|
||||
env.tests['prefixedwith'] = str.startswith
|
||||
env.tests['suffixedwith'] = str.endswith
|
||||
env.tests["prefixedwith"] = str.startswith
|
||||
env.tests["suffixedwith"] = str.endswith
|
||||
|
||||
|
||||
def add_builders(app):
|
||||
"""This is necessary because RTD injects their own for some reason."""
|
||||
app.set_translator('html', DPYHTML5Translator, override=True)
|
||||
app.set_translator("html", DPYHTML5Translator, override=True)
|
||||
app.add_builder(DPYStandaloneHTMLBuilder, override=True)
|
||||
|
||||
try:
|
||||
original = app.registry.builders['readthedocs']
|
||||
original = app.registry.builders["readthedocs"]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
injected_mro = tuple(
|
||||
base if base is not StandaloneHTMLBuilder else DPYStandaloneHTMLBuilder for base in original.mro()[1:]
|
||||
base if base is not StandaloneHTMLBuilder else DPYStandaloneHTMLBuilder
|
||||
for base in original.mro()[1:]
|
||||
)
|
||||
new_builder = type(original.__name__, injected_mro, {'name': 'readthedocs'})
|
||||
app.set_translator('readthedocs', DPYHTML5Translator, override=True)
|
||||
new_builder = type(original.__name__, injected_mro, {"name": "readthedocs"})
|
||||
app.set_translator("readthedocs", DPYHTML5Translator, override=True)
|
||||
app.add_builder(new_builder, override=True)
|
||||
|
||||
|
||||
def setup(app):
|
||||
add_builders(app)
|
||||
app.connect('builder-inited', add_custom_jinja2)
|
||||
app.connect("builder-inited", add_custom_jinja2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue