Format conf.py with isort and black

main
Jan Dittberner 2 years ago
parent abfb40fa8f
commit 6d0972ebbc

@ -8,45 +8,49 @@
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from datetime import datetime
import os
import certifi
import requests
import sys
sys.path.insert(0, os.path.abspath('.'))
from datetime import datetime
from git import repo
import certifi
import requests
from docutils import nodes, utils
from git import repo
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("."))
try:
print('Checking connection to infradocs.cacert.org')
requests.head('https://infradocs.cacert.org/')
print('Connection to infradocs.cacert.org OK')
print("Checking connection to infradocs.cacert.org")
requests.head("https://infradocs.cacert.org/")
print("Connection to infradocs.cacert.org OK")
except requests.exceptions.SSLError as err:
print('SSL Error. Adding CAcert certificates to Certifi store...')
print("SSL Error. Adding CAcert certificates to Certifi store...")
cafile = certifi.where()
with open(os.path.join(
os.path.dirname(__file__), '..', 'cacert.pem'), 'rb') as infile:
with open(
os.path.join(os.path.dirname(__file__), "..", "cacert.pem"), "rb"
) as infile:
cacertca = infile.read()
with open(cafile, 'ab') as outfile:
with open(cafile, "ab") as outfile:
outfile.write(cacertca)
# -- Project information -----------------------------------------------------
project = 'CAcert code documentation'
copyright = '2018-2020 CAcert development team'
author = 'CAcert development team'
project = "CAcert code documentation"
copyright = "2018-2020 CAcert development team"
author = "CAcert development team"
# The short X.Y version
version = '0.1'
version = "0.1"
# The full version, including alpha/beta/rc tags
release = "{}-git:{} built:{}".format(
version, repo.Repo('..').git.describe('--always', '--dirty'),
datetime.utcnow().replace(microsecond=0))
version,
repo.Repo("..").git.describe("--always", "--dirty"),
datetime.utcnow().replace(microsecond=0),
)
# -- General configuration ---------------------------------------------------
@ -58,27 +62,27 @@ release = "{}-git:{} built:{}".format(
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.extlinks',
'sphinx.ext.todo',
'sphinx.ext.ifconfig',
'sphinxcontrib.phpdomain',
'sphinxcontrib.blockdiag',
'sphinxcontrib.seqdiag',
'sphinxext.cacert',
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx.ext.todo",
"sphinx.ext.ifconfig",
"sphinxcontrib.phpdomain",
"sphinxcontrib.blockdiag",
"sphinxcontrib.seqdiag",
"sphinxext.cacert",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -93,7 +97,7 @@ language = None
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# -- Options for HTML output -------------------------------------------------
@ -101,28 +105,28 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'classic'
html_theme = "classic"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'sidebarbgcolor': '#f5f7f7',
'sidebartextcolor': '#334d55',
'sidebarlinkcolor': '#005fa9',
"sidebarbgcolor": "#f5f7f7",
"sidebartextcolor": "#334d55",
"sidebarlinkcolor": "#005fa9",
}
html_title = project + " v" + release
html_logo = os.path.join('images', 'CAcert-logo-colour.svg')
html_logo = os.path.join("images", "CAcert-logo-colour.svg")
html_favicon = os.path.join('images', 'favicon.ico')
html_favicon = os.path.join("images", "favicon.ico")
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
@ -138,7 +142,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'CAcertcodedocumentationdoc'
htmlhelp_basename = "CAcertcodedocumentationdoc"
# -- Options for LaTeX output ------------------------------------------------
@ -147,15 +151,12 @@ 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',
@ -165,8 +166,13 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'CAcertcodedocumentation.tex', 'CAcert code documentation',
'CAcert development team', 'manual'),
(
master_doc,
"CAcertcodedocumentation.tex",
"CAcert code documentation",
"CAcert development team",
"manual",
),
]
@ -175,8 +181,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'cacertcodedocumentation', 'CAcert code documentation',
[author], 1)
(master_doc, "cacertcodedocumentation", "CAcert code documentation", [author], 1)
]
@ -186,9 +191,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'CAcertcodedocumentation', 'CAcert code documentation',
author, 'CAcertcodedocumentation', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"CAcertcodedocumentation",
"CAcert code documentation",
author,
"CAcertcodedocumentation",
"One line description of project.",
"Miscellaneous",
),
]
@ -207,7 +218,7 @@ epub_title = project
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]
# -- Extension configuration -------------------------------------------------
@ -215,7 +226,7 @@ epub_exclude_files = ['search.html']
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'infradocs': ('https://infradocs.cacert.org', None)}
intersphinx_mapping = {"infradocs": ("https://infradocs.cacert.org", None)}
# -- Options for todo extension ----------------------------------------------
@ -223,11 +234,12 @@ intersphinx_mapping = {'infradocs': ('https://infradocs.cacert.org', None)}
todo_include_todos = True
extlinks = {
'wiki': ('https://wiki.cacert.org/%s', 'Wiki '),
'cacertgit': ('https://git.cacert.org/%s.git/', 'CAcert Git repository '),
'github': ('https://github.com/CAcertOrg/%s', 'Github repository '),
"wiki": ("https://wiki.cacert.org/%s", "Wiki "),
"cacertgit": ("https://git.cacert.org/%s.git/", "CAcert Git repository "),
"github": ("https://github.com/CAcertOrg/%s", "Github repository "),
}
def cacert_bug(name, rawtext, text, lineno, inliner, options={}, content=[]):
try:
bugnum = int(text)
@ -235,15 +247,16 @@ def cacert_bug(name, rawtext, text, lineno, inliner, options={}, content=[]):
raise ValueError
except ValueError:
msg = inliner.reporter.error(
'Bug number must be a number greater than or equal to 1; '
'"%s" is invalid.' % text, line=lineno)
"Bug number must be a number greater than or equal to 1; "
'"%s" is invalid.' % text,
line=lineno,
)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
ref = 'https://bugs.cacert.org/view.php?id=%d' % bugnum
node = nodes.reference(rawtext, '#' + utils.unescape(text), refuri=ref,
**options)
ref = "https://bugs.cacert.org/view.php?id=%d" % bugnum
node = nodes.reference(rawtext, "#" + utils.unescape(text), refuri=ref, **options)
return [node], []
def setup(app):
app.add_role('bug', cacert_bug)
app.add_role("bug", cacert_bug)

Loading…
Cancel
Save