Skip to content

Commit 9c66563

Browse files
authored
Merge pull request #71 from sommersoft/blackify_py_templates
Blackify Python Templates
2 parents 83f81da + 44b6593 commit 9c66563

File tree

2 files changed

+94
-83
lines changed

2 files changed

+94
-83
lines changed

{{ cookiecutter.library_name }}/docs/conf.py

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
@@ -23,36 +24,38 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),
27-
{%- if cookiecutter.requires_bus_device in ["y", "yes"] -%}
28-
'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),
29-
{%- endif -%}
30-
{%- if cookiecutter.requires_register in ["y", "yes"] -%}
31-
'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),
32-
{%- endif -%}
33-
'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
{%- if cookiecutter.requires_bus_device in ["y", "yes"] -%}
30+
"BusDevice": ("https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", None),
31+
{% endif %}
32+
{%- if cookiecutter.requires_register in ["y", "yes"] -%}
33+
"Register": ("https://circuitpython.readthedocs.io/projects/register/en/latest/", None),
34+
{%- endif %}
35+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
36+
}
3437

3538
# Add any paths that contain templates here, relative to this directory.
36-
templates_path = ['_templates']
39+
templates_path = ["_templates"]
3740

38-
source_suffix = '.rst'
41+
source_suffix = ".rst"
3942

4043
# The master toctree document.
41-
master_doc = 'index'
44+
master_doc = "index"
4245

4346
# General information about the project.
44-
project = u'{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %}{{ cookiecutter.library_name }} Library'
45-
copyright = u'{% now 'utc', '%Y' %} {{ cookiecutter.author }}'
46-
author = u'{{ cookiecutter.author }}'
47+
project = "{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %}{{ cookiecutter.library_name }} Library"
48+
copyright = "{% now 'utc', '%Y' %} {{ cookiecutter.author }}"
49+
author = "{{ cookiecutter.author }}"
4750

4851
# The version info for the project you're documenting, acts as replacement for
4952
# |version| and |release|, also used in various other places throughout the
5053
# built documents.
5154
#
5255
# The short X.Y version.
53-
version = u'1.0'
56+
version = "1.0"
5457
# The full version, including alpha/beta/rc tags.
55-
release = u'1.0'
58+
release = "1.0"
5659

5760
# The language for content autogenerated by Sphinx. Refer to documentation
5861
# for a list of supported languages.
@@ -64,7 +67,13 @@
6467
# List of patterns, relative to source directory, that match files and
6568
# directories to ignore when looking for source files.
6669
# This patterns also effect to html_static_path and html_extra_path
67-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
70+
exclude_patterns = [
71+
"_build",
72+
"Thumbs.db",
73+
".DS_Store",
74+
".env",
75+
"CODE_OF_CONDUCT.md",
76+
]
6877

6978
# The reST default role (used for this markup: `text`) to use for all
7079
# documents.
@@ -76,7 +85,7 @@
7685
add_function_parentheses = True
7786

7887
# The name of the Pygments (syntax highlighting) style to use.
79-
pygments_style = 'sphinx'
88+
pygments_style = "sphinx"
8089

8190
# If true, `todo` and `todoList` produce output, else they produce nothing.
8291
todo_include_todos = False
@@ -91,68 +100,72 @@
91100
# The theme to use for HTML and HTML Help pages. See the documentation for
92101
# a list of builtin themes.
93102
#
94-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
103+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
95104

96105
if not on_rtd: # only import and set the theme if we're building docs locally
97106
try:
98107
import sphinx_rtd_theme
99-
html_theme = 'sphinx_rtd_theme'
100-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
108+
109+
html_theme = "sphinx_rtd_theme"
110+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
101111
except:
102-
html_theme = 'default'
103-
html_theme_path = ['.']
112+
html_theme = "default"
113+
html_theme_path = ["."]
104114
else:
105-
html_theme_path = ['.']
115+
html_theme_path = ["."]
106116

107117
# Add any paths that contain custom static files (such as style sheets) here,
108118
# relative to this directory. They are copied after the builtin static files,
109119
# so a file named "default.css" will overwrite the builtin "default.css".
110-
html_static_path = ['_static']
120+
html_static_path = ["_static"]
111121

112122
# The name of an image file (relative to this directory) to use as a favicon of
113123
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
114124
# pixels large.
115125
#
116-
html_favicon = '_static/favicon.ico'
126+
html_favicon = "_static/favicon.ico"
117127

118128
# Output file base name for HTML help builder.
119-
htmlhelp_basename = '{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name | capitalize }}Librarydoc'
129+
htmlhelp_basename = "{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name | capitalize }}Librarydoc"
120130

121131
# -- Options for LaTeX output ---------------------------------------------
122132

123133
latex_elements = {
124-
# The paper size ('letterpaper' or 'a4paper').
125-
#
126-
# 'papersize': 'letterpaper',
127-
128-
# The font size ('10pt', '11pt' or '12pt').
129-
#
130-
# 'pointsize': '10pt',
131-
132-
# Additional stuff for the LaTeX preamble.
133-
#
134-
# 'preamble': '',
135-
136-
# Latex figure (float) alignment
137-
#
138-
# 'figure_align': 'htbp',
134+
# The paper size ('letterpaper' or 'a4paper').
135+
# 'papersize': 'letterpaper',
136+
# The font size ('10pt', '11pt' or '12pt').
137+
# 'pointsize': '10pt',
138+
# Additional stuff for the LaTeX preamble.
139+
# 'preamble': '',
140+
# Latex figure (float) alignment
141+
# 'figure_align': 'htbp',
139142
}
140143

141144
# Grouping the document tree into LaTeX files. List of tuples
142145
# (source start file, target name, title,
143146
# author, documentclass [howto, manual, or own class]).
144147
latex_documents = [
145-
(master_doc, '{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library.tex', u'{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }} Library Documentation',
146-
author, 'manual'),
148+
(
149+
master_doc,
150+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library.tex",
151+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }} Library Documentation",
152+
author,
153+
"manual",
154+
),
147155
]
148156

149157
# -- Options for manual page output ---------------------------------------
150158

151159
# One entry per manual page. List of tuples
152160
# (source start file, name, description, authors, manual section).
153161
man_pages = [
154-
(master_doc, '{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}library', u'{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %}{{ cookiecutter.library_name }} Library Documentation',
155-
[author], 1)
162+
(
163+
master_doc,
164+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}library",
165+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }} {% endif %}{{ cookiecutter.library_name }} Library Documentation",
166+
[author],
167+
1,
168+
),
156169
]
157170

158171
# -- Options for Texinfo output -------------------------------------------
@@ -161,7 +174,13 @@
161174
# (source start file, target name, title, author,
162175
# dir menu entry, description, category)
163176
texinfo_documents = [
164-
(master_doc, '{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library', u'{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %} {{ cookiecutter.library_name }} Library Documentation',
165-
author, '{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library', 'One line description of project.',
166-
'Miscellaneous'),
177+
(
178+
master_doc,
179+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library",
180+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %} {{ cookiecutter.library_name }} Library Documentation",
181+
author,
182+
"{% if cookiecutter.library_prefix %}{{ cookiecutter.library_prefix | capitalize }}{% endif %}{{ cookiecutter.library_name }}Library",
183+
"One line description of project.",
184+
"Miscellaneous",
185+
),
167186
]

{{ cookiecutter.library_name }}/setup.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,50 @@
2525
"""
2626

2727
from setuptools import setup, find_packages
28+
2829
# To use a consistent encoding
2930
from codecs import open
3031
from os import path
3132

3233
here = path.abspath(path.dirname(__file__))
3334

3435
# Get the long description from the README file
35-
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
36+
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
3637
long_description = f.read()
3738

3839
setup(
39-
name='adafruit-circuitpython-{{ pypi_name }}',
40-
40+
name="adafruit-circuitpython-{{ pypi_name }}",
4141
use_scm_version=True,
42-
setup_requires=['setuptools_scm'],
43-
44-
description='{{ cookiecutter.library_description }}',
42+
setup_requires=["setuptools_scm"],
43+
description="{{ cookiecutter.library_description }}",
4544
long_description=long_description,
46-
long_description_content_type='text/x-rst',
47-
45+
long_description_content_type="text/x-rst",
4846
# The project's main homepage.
49-
url='https://github.com/adafruit/Adafruit_CircuitPython_{{ cookiecutter.library_name }}',
50-
47+
url="https://github.com/adafruit/Adafruit_CircuitPython_{{ cookiecutter.library_name }}",
5148
# Author details
52-
author='Adafruit Industries',
53-
author_email='[email protected]',
54-
49+
author="Adafruit Industries",
50+
author_email="[email protected]",
5551
install_requires=[
56-
'{{ req_list.items|unique|join("',\n'")|indent(width=8) }}'
52+
"{{ req_list.items|unique|join('",\n"')|indent(width=8) }}",
5753
],
58-
5954
# Choose your license
60-
license='MIT',
61-
55+
license="MIT",
6256
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
6357
classifiers=[
64-
'Development Status :: 3 - Alpha',
65-
'Intended Audience :: Developers',
66-
'Topic :: Software Development :: Libraries',
67-
'Topic :: System :: Hardware',
68-
'License :: OSI Approved :: MIT License',
69-
'Programming Language :: Python :: 3',
70-
'Programming Language :: Python :: 3.4',
71-
'Programming Language :: Python :: 3.5',
58+
"Development Status :: 3 - Alpha",
59+
"Intended Audience :: Developers",
60+
"Topic :: Software Development :: Libraries",
61+
"Topic :: System :: Hardware",
62+
"License :: OSI Approved :: MIT License",
63+
"Programming Language :: Python :: 3",
64+
"Programming Language :: Python :: 3.4",
65+
"Programming Language :: Python :: 3.5",
7266
],
73-
7467
# What does your project relate to?
75-
keywords='{{ kw_list.kw_list|join(" '\n'")|indent(width=13) }}',
76-
68+
keywords="{{ kw_list.kw_list|join(' "\n"')|indent(width=13) }}",
7769
# You can just specify the packages manually here if your project is
7870
# simple. Or you can use find_packages().
7971
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
8072
# CHANGE `py_modules=['...']` TO `packages=['...']`
81-
py_modules=['{%- if cookiecutter.library_prefix != "" -%}{{ cookiecutter.library_prefix|lower }}_{%- endif -%}{{- cookiecutter.library_name|lower -}}'],
73+
py_modules=["{%- if cookiecutter.library_prefix != '' -%}{{ cookiecutter.library_prefix|lower }}_{%- endif -%}{{- cookiecutter.library_name|lower -}}"],
8274
)

0 commit comments

Comments
 (0)