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