Improve string formatting v5 (#33697)

* Improve string formatting v5

* Address review comments
This commit is contained in:
springstan 2020-04-05 17:48:55 +02:00 committed by GitHub
parent 39336d3ea3
commit fca90a8ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 221 additions and 252 deletions

View file

@ -22,25 +22,26 @@ import sys
from homeassistant.const import __short_version__, __version__
PROJECT_NAME = 'Home Assistant'
PROJECT_PACKAGE_NAME = 'homeassistant'
PROJECT_AUTHOR = 'The Home Assistant Authors'
PROJECT_COPYRIGHT = f' 2013-2020, {PROJECT_AUTHOR}'
PROJECT_LONG_DESCRIPTION = ('Home Assistant is an open-source '
'home automation platform running on Python 3. '
'Track and control all devices at home and '
'automate control. '
'Installation in less than a minute.')
PROJECT_GITHUB_USERNAME = 'home-assistant'
PROJECT_GITHUB_REPOSITORY = 'home-assistant'
PROJECT_NAME = "Home Assistant"
PROJECT_PACKAGE_NAME = "homeassistant"
PROJECT_AUTHOR = "The Home Assistant Authors"
PROJECT_COPYRIGHT = f" 2013-2020, {PROJECT_AUTHOR}"
PROJECT_LONG_DESCRIPTION = (
"Home Assistant is an open-source "
"home automation platform running on Python 3. "
"Track and control all devices at home and "
"automate control. "
"Installation in less than a minute."
)
PROJECT_GITHUB_USERNAME = "home-assistant"
PROJECT_GITHUB_REPOSITORY = "home-assistant"
GITHUB_PATH = '{}/{}'.format(
PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY)
GITHUB_URL = f'https://github.com/{GITHUB_PATH}'
GITHUB_PATH = f"{PROJECT_GITHUB_USERNAME}/{PROJECT_GITHUB_REPOSITORY}"
GITHUB_URL = f"https://github.com/{GITHUB_PATH}"
sys.path.insert(0, os.path.abspath('_ext'))
sys.path.insert(0, os.path.abspath('../homeassistant'))
sys.path.insert(0, os.path.abspath("_ext"))
sys.path.insert(0, os.path.abspath("../homeassistant"))
# -- General configuration ------------------------------------------------
@ -52,27 +53,27 @@ sys.path.insert(0, os.path.abspath('../homeassistant'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.linkcode',
'sphinx_autodoc_annotation',
'edit_on_github'
"sphinx.ext.autodoc",
"sphinx.ext.linkcode",
"sphinx_autodoc_annotation",
"edit_on_github",
]
# 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 encoding of source files.
#
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = PROJECT_NAME
@ -88,25 +89,25 @@ version = __short_version__
# The full version, including alpha/beta/rc tags.
release = __version__
code_branch = 'dev' if 'dev' in __version__ else 'master'
code_branch = "dev" if "dev" in __version__ else "master"
# Edit on Github config
edit_on_github_project = GITHUB_PATH
edit_on_github_branch = code_branch
edit_on_github_src_path = 'docs/source/'
edit_on_github_src_path = "docs/source/"
def linkcode_resolve(domain, info):
"""Determine the URL corresponding to Python object."""
if domain != 'py':
if domain != "py":
return None
modname = info['module']
fullname = info['fullname']
modname = info["module"]
fullname = info["fullname"]
submod = sys.modules.get(modname)
if submod is None:
return None
obj = submod
for part in fullname.split('.'):
for part in fullname.split("."):
try:
obj = getattr(obj, part)
except:
@ -131,7 +132,8 @@ def linkcode_resolve(domain, info):
fn = fn[index:]
return f'{GITHUB_URL}/blob/{code_branch}/{fn}{linespec}'
return f"{GITHUB_URL}/blob/{code_branch}/{fn}{linespec}"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -174,7 +176,7 @@ exclude_patterns = []
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
@ -191,22 +193,22 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"
# 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 = {
'logo': 'logo.png',
'logo_name': PROJECT_NAME,
'description': PROJECT_LONG_DESCRIPTION,
'github_user': PROJECT_GITHUB_USERNAME,
'github_repo': PROJECT_GITHUB_REPOSITORY,
'github_type': 'star',
'github_banner': True,
'travis_button': True,
'touch_icon': 'logo-apple.png',
"logo": "logo.png",
"logo_name": PROJECT_NAME,
"description": PROJECT_LONG_DESCRIPTION,
"github_user": PROJECT_GITHUB_USERNAME,
"github_repo": PROJECT_GITHUB_REPOSITORY,
"github_type": "star",
"github_banner": True,
"travis_button": True,
"touch_icon": "logo-apple.png",
# 'fixed_sidebar': True, # Re-enable when we have more content
}
@ -232,12 +234,12 @@ html_theme_options = {
# This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'
html_favicon = "_static/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"]
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@ -249,7 +251,7 @@ html_static_path = ['_static']
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
#
html_last_updated_fmt = '%b %d, %Y'
html_last_updated_fmt = "%b %d, %Y"
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
@ -259,13 +261,13 @@ html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#
html_sidebars = {
'**': [
'about.html',
'links.html',
'searchbox.html',
'sourcelink.html',
'navigation.html',
'relations.html'
"**": [
"about.html",
"links.html",
"searchbox.html",
"sourcelink.html",
"navigation.html",
"relations.html",
]
}
@ -326,34 +328,36 @@ html_sidebars = {
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'Home-Assistantdoc'
htmlhelp_basename = "Home-Assistantdoc"
# -- Options for LaTeX output ---------------------------------------------
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',
# 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',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'home-assistant.tex', 'Home Assistant Documentation',
'Home Assistant Team', 'manual'),
(
master_doc,
"home-assistant.tex",
"Home Assistant Documentation",
"Home Assistant Team",
"manual",
)
]
# The name of an image file (relative to this directory) to place at the top of
@ -394,8 +398,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'home-assistant', 'Home Assistant Documentation',
[author], 1)
(master_doc, "home-assistant", "Home Assistant Documentation", [author], 1)
]
# If true, show URL addresses after external links.
@ -409,9 +412,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Home-Assistant', 'Home Assistant Documentation',
author, 'Home Assistant', 'Open-source home automation platform.',
'Miscellaneous'),
(
master_doc,
"Home-Assistant",
"Home Assistant Documentation",
author,
"Home Assistant",
"Open-source home automation platform.",
"Miscellaneous",
)
]
# Documents to append as an appendix to all manuals.