mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-14 21:24:59 +00:00
Black format
This commit is contained in:
parent
3d49dd9246
commit
6c3fe56acf
8 changed files with 119 additions and 118 deletions
33
docs/conf.py
33
docs/conf.py
|
@ -45,7 +45,7 @@ extlinks = {
|
|||
intersphinx_mapping = {
|
||||
'py': ('https://docs.python.org/3', None),
|
||||
'aio': ('https://docs.aiohttp.org/en/stable/', None),
|
||||
'req': ('https://docs.python-requests.org/en/latest/', None)
|
||||
'req': ('https://docs.python-requests.org/en/latest/', None),
|
||||
}
|
||||
|
||||
rst_prolog = """
|
||||
|
@ -258,12 +258,7 @@ html_static_path = ['_static']
|
|||
# implements a search results scorer. If empty, the default will be used.
|
||||
html_search_scorer = '_static/scorer.js'
|
||||
|
||||
html_js_files = [
|
||||
'custom.js',
|
||||
'settings.js',
|
||||
'copy.js',
|
||||
'sidebar.js'
|
||||
]
|
||||
html_js_files = ['custom.js', 'settings.js', 'copy.js', 'sidebar.js']
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Github-API-Wrapper.doc'
|
||||
|
@ -273,13 +268,10 @@ htmlhelp_basename = 'Github-API-Wrapper.doc'
|
|||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
@ -288,8 +280,7 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'Github-API-Wrapper.tex', 'Github-API-Wrapper Documentation',
|
||||
'VarMonke & sudosnok', 'manual'),
|
||||
('index', 'Github-API-Wrapper.tex', 'Github-API-Wrapper Documentation', 'VarMonke & sudosnok', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -317,10 +308,7 @@ latex_documents = [
|
|||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'Github-API-Wrapper', 'Github-API-Wrapper Documentation',
|
||||
['VarMonke & sudosnok'], 1)
|
||||
]
|
||||
man_pages = [('index', 'Github-API-Wrapper', 'Github-API-Wrapper Documentation', ['VarMonke & sudosnok'], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
# man_show_urls = False
|
||||
|
@ -332,9 +320,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Github-API-Wrapper', 'Github-API-Wrapper Documentation',
|
||||
'VarMonke & sudosnok', 'Github-API-Wrapper', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
'index',
|
||||
'Github-API-Wrapper',
|
||||
'Github-API-Wrapper Documentation',
|
||||
'VarMonke & sudosnok',
|
||||
'Github-API-Wrapper',
|
||||
'One line description of project.',
|
||||
'Miscellaneous',
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
@ -349,6 +343,7 @@ texinfo_documents = [
|
|||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
|
||||
def setup(app):
|
||||
if app.config.language == 'ja':
|
||||
app.config.intersphinx_mapping['py'] = ('https://docs.python.org/ja/3', None)
|
||||
|
|
|
@ -2,11 +2,11 @@ from sphinx.builders.html import StandaloneHTMLBuilder
|
|||
from sphinx.environment.adapters.indexentries import IndexEntries
|
||||
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
|
||||
|
@ -20,6 +20,7 @@ class DPYHTML5Translator(HTML5Translator):
|
|||
super().depart_table(node)
|
||||
self.body.append('</div>')
|
||||
|
||||
|
||||
class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
||||
# This is mostly copy pasted from Sphinx.
|
||||
def write_genindex(self) -> None:
|
||||
|
@ -28,8 +29,7 @@ class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
|||
genindex = IndexEntries(self.env).create_index(self, group_entries=False) # type: ignore
|
||||
indexcounts = []
|
||||
for _k, entries in genindex:
|
||||
indexcounts.append(sum(1 + len(subitems)
|
||||
for _, (_, subitems, _) in entries))
|
||||
indexcounts.append(sum(1 + len(subitems) for _, (_, subitems, _) in entries))
|
||||
|
||||
genindexcontext = {
|
||||
'genindexentries': genindex,
|
||||
|
@ -38,15 +38,11 @@ class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
|||
}
|
||||
|
||||
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('genindex-' + key, ctx,
|
||||
'genindex-single.html')
|
||||
ctx = {'key': key, 'entries': entries, 'count': count, 'genindexentries': genindex}
|
||||
self.handle_page('genindex-' + key, ctx, 'genindex-single.html')
|
||||
else:
|
||||
self.handle_page('genindex', genindexcontext, 'genindex.html')
|
||||
|
||||
|
@ -56,6 +52,7 @@ def add_custom_jinja2(app):
|
|||
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)
|
||||
|
@ -66,12 +63,14 @@ def add_builders(app):
|
|||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
injected_mro = tuple(base if base is not StandaloneHTMLBuilder else DPYStandaloneHTMLBuilder
|
||||
for base in original.mro()[1:])
|
||||
injected_mro = tuple(
|
||||
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)
|
||||
app.add_builder(new_builder, override=True)
|
||||
|
||||
|
||||
def setup(app):
|
||||
add_builders(app)
|
||||
app.connect('builder-inited', add_custom_jinja2)
|
||||
|
|
|
@ -3,25 +3,32 @@ from docutils.parsers.rst import states, directives #type: ignore
|
|||
from docutils.parsers.rst.roles import set_classes
|
||||
from docutils import nodes
|
||||
|
||||
|
||||
class details(nodes.General, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
class summary(nodes.General, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
def visit_details_node(self, node):
|
||||
self.body.append(self.starttag(node, 'details', CLASS=node.attributes.get('class', '')))
|
||||
|
||||
|
||||
def visit_summary_node(self, node):
|
||||
self.body.append(self.starttag(node, 'summary', CLASS=node.attributes.get('summary-class', '')))
|
||||
self.body.append(node.rawsource)
|
||||
|
||||
|
||||
def depart_details_node(self, node):
|
||||
self.body.append('</details>\n')
|
||||
|
||||
|
||||
def depart_summary_node(self, node):
|
||||
self.body.append('</summary>')
|
||||
|
||||
|
||||
class DetailsDirective(Directive):
|
||||
final_argument_whitespace = True
|
||||
optional_arguments = 1
|
||||
|
@ -48,8 +55,8 @@ class DetailsDirective(Directive):
|
|||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
return [node]
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_node(details, html=(visit_details_node, depart_details_node))
|
||||
app.add_node(summary, html=(visit_summary_node, depart_summary_node))
|
||||
app.add_directive('details', DetailsDirective)
|
||||
|
||||
|
|
|
@ -4,15 +4,19 @@ from docutils.parsers.rst.roles import set_classes
|
|||
from docutils import nodes
|
||||
from sphinx.locale import _
|
||||
|
||||
|
||||
class exception_hierarchy(nodes.General, nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
def visit_exception_hierarchy_node(self, node):
|
||||
self.body.append(self.starttag(node, 'div', CLASS='exception-hierarchy-content'))
|
||||
|
||||
|
||||
def depart_exception_hierarchy_node(self, node):
|
||||
self.body.append('</div>\n')
|
||||
|
||||
|
||||
class ExceptionHierarchyDirective(Directive):
|
||||
has_content = True
|
||||
|
||||
|
@ -22,6 +26,7 @@ class ExceptionHierarchyDirective(Directive):
|
|||
self.state.nested_parse(self.content, self.content_offset, node)
|
||||
return [node]
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_node(exception_hierarchy, html=(visit_exception_hierarchy_node, depart_exception_hierarchy_node))
|
||||
app.add_directive('exception_hierarchy', ExceptionHierarchyDirective)
|
||||
|
|
|
@ -5,7 +5,6 @@ from sphinx.util import logging as sphinx_logging
|
|||
|
||||
|
||||
class NitpickFileIgnorer(logging.Filter):
|
||||
|
||||
def __init__(self, app: Sphinx) -> None:
|
||||
self.app = app
|
||||
super().__init__()
|
||||
|
|
|
@ -16,13 +16,7 @@ from sphinx.util.typing import RoleFunction
|
|||
|
||||
def make_link_role(resource_links: Dict[str, str]) -> RoleFunction:
|
||||
def role(
|
||||
typ: str,
|
||||
rawtext: str,
|
||||
text: str,
|
||||
lineno: int,
|
||||
inliner: Inliner,
|
||||
options: Dict = {},
|
||||
content: List[str] = []
|
||||
typ: str, rawtext: str, text: str, lineno: int, inliner: Inliner, options: Dict = {}, content: List[str] = []
|
||||
) -> Tuple[List[Node], List[system_message]]:
|
||||
|
||||
text = utils.unescape(text)
|
||||
|
@ -32,12 +26,14 @@ def make_link_role(resource_links: Dict[str, str]) -> RoleFunction:
|
|||
title = full_url
|
||||
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
|
||||
return [pnode], []
|
||||
|
||||
return role
|
||||
|
||||
|
||||
def add_link_role(app: Sphinx) -> None:
|
||||
app.add_role('resource', make_link_role(app.config.resource_links))
|
||||
|
||||
|
||||
def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
app.add_config_value('resource_links', {}, 'env')
|
||||
app.connect('builder-inited', add_link_role)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue