Skip to content

Commit bbd8760

Browse files
jimmodpgeorge
authored andcommitted
all: Update Python formatting to ruff-format.
This updates a small number of files that change with ruff-format's (vs black's) rules. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
1 parent 303ccca commit bbd8760

File tree

9 files changed

+160
-131
lines changed

9 files changed

+160
-131
lines changed

docs/conf.py

Lines changed: 103 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,56 @@
1919
# If extensions (or modules to document with autodoc) are in another directory,
2020
# add these directories to sys.path here. If the directory is relative to the
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
sys.path.insert(0, os.path.abspath('.'))
22+
sys.path.insert(0, os.path.abspath("."))
2323

2424
# The MICROPY_VERSION env var should be "vX.Y.Z" (or unset).
25-
micropy_version = os.getenv('MICROPY_VERSION') or 'latest'
26-
micropy_all_versions = (os.getenv('MICROPY_ALL_VERSIONS') or 'latest').split(',')
27-
url_pattern = '%s/en/%%s' % (os.getenv('MICROPY_URL_PREFIX') or '/',)
25+
micropy_version = os.getenv("MICROPY_VERSION") or "latest"
26+
micropy_all_versions = (os.getenv("MICROPY_ALL_VERSIONS") or "latest").split(",")
27+
url_pattern = "%s/en/%%s" % (os.getenv("MICROPY_URL_PREFIX") or "/",)
2828

2929
# The members of the html_context dict are available inside topindex.html
3030
html_context = {
31-
'cur_version':micropy_version,
32-
'all_versions':[
33-
(ver, url_pattern % ver) for ver in micropy_all_versions
31+
"cur_version": micropy_version,
32+
"all_versions": [(ver, url_pattern % ver) for ver in micropy_all_versions],
33+
"downloads": [
34+
("PDF", url_pattern % micropy_version + "/micropython-docs.pdf"),
3435
],
35-
'downloads':[
36-
('PDF', url_pattern % micropy_version + '/micropython-docs.pdf'),
37-
],
38-
'is_release': micropy_version != 'latest',
36+
"is_release": micropy_version != "latest",
3937
}
4038

4139

4240
# -- General configuration ------------------------------------------------
4341

4442
# If your documentation needs a minimal Sphinx version, state it here.
45-
#needs_sphinx = '1.0'
43+
# needs_sphinx = '1.0'
4644

4745
# Add any Sphinx extension module names here, as strings. They can be
4846
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4947
# ones.
5048
extensions = [
51-
'sphinx.ext.autodoc',
52-
'sphinx.ext.doctest',
53-
'sphinx.ext.intersphinx',
54-
'sphinx.ext.todo',
55-
'sphinx.ext.coverage',
56-
'sphinxcontrib.jquery',
49+
"sphinx.ext.autodoc",
50+
"sphinx.ext.doctest",
51+
"sphinx.ext.intersphinx",
52+
"sphinx.ext.todo",
53+
"sphinx.ext.coverage",
54+
"sphinxcontrib.jquery",
5755
]
5856

5957
# Add any paths that contain templates here, relative to this directory.
60-
templates_path = ['templates']
58+
templates_path = ["templates"]
6159

6260
# The suffix of source filenames.
63-
source_suffix = '.rst'
61+
source_suffix = ".rst"
6462

6563
# The encoding of source files.
66-
#source_encoding = 'utf-8-sig'
64+
# source_encoding = 'utf-8-sig'
6765

6866
# The master toctree document.
69-
master_doc = 'index'
67+
master_doc = "index"
7068

7169
# General information about the project.
72-
project = 'MicroPython'
73-
copyright = '- The MicroPython Documentation is Copyright © 2014-2023, Damien P. George, Paul Sokolovsky, and contributors'
70+
project = "MicroPython"
71+
copyright = "- The MicroPython Documentation is Copyright © 2014-2023, Damien P. George, Paul Sokolovsky, and contributors"
7472

7573
# The version info for the project you're documenting, acts as replacement for
7674
# |version| and |release|, also used in various other places throughout the
@@ -82,41 +80,41 @@
8280

8381
# The language for content autogenerated by Sphinx. Refer to documentation
8482
# for a list of supported languages.
85-
#language = None
83+
# language = None
8684

8785
# There are two options for replacing |today|: either, you set today to some
8886
# non-false value, then it is used:
89-
#today = ''
87+
# today = ''
9088
# Else, today_fmt is used as the format for a strftime call.
91-
#today_fmt = '%B %d, %Y'
89+
# today_fmt = '%B %d, %Y'
9290

9391
# List of patterns, relative to source directory, that match files and
9492
# directories to ignore when looking for source files.
95-
exclude_patterns = ['build', '.venv']
93+
exclude_patterns = ["build", ".venv"]
9694

9795
# The reST default role (used for this markup: `text`) to use for all
9896
# documents.
99-
default_role = 'any'
97+
default_role = "any"
10098

10199
# If true, '()' will be appended to :func: etc. cross-reference text.
102-
#add_function_parentheses = True
100+
# add_function_parentheses = True
103101

104102
# If true, the current module name will be prepended to all description
105103
# unit titles (such as .. function::).
106-
#add_module_names = True
104+
# add_module_names = True
107105

108106
# If true, sectionauthor and moduleauthor directives will be shown in the
109107
# output. They are ignored by default.
110-
#show_authors = False
108+
# show_authors = False
111109

112110
# The name of the Pygments (syntax highlighting) style to use.
113-
pygments_style = 'sphinx'
111+
pygments_style = "sphinx"
114112

115113
# A list of ignored prefixes for module index sorting.
116-
#modindex_common_prefix = []
114+
# modindex_common_prefix = []
117115

118116
# If true, keep warnings as "system message" paragraphs in the built documents.
119-
#keep_warnings = False
117+
# keep_warnings = False
120118

121119
# Global include files. Sphinx docs suggest using rst_epilog in preference
122120
# of rst_prolog, so we follow. Absolute paths below mean "from the base
@@ -128,144 +126,148 @@
128126
# -- Options for HTML output ----------------------------------------------
129127

130128
# on_rtd is whether we are on readthedocs.org
131-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
129+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
132130

133131
if not on_rtd: # only import and set the theme if we're building docs locally
134132
try:
135133
import sphinx_rtd_theme
136-
html_theme = 'sphinx_rtd_theme'
137-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
134+
135+
html_theme = "sphinx_rtd_theme"
136+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
138137
except:
139-
html_theme = 'default'
140-
html_theme_path = ['.']
138+
html_theme = "default"
139+
html_theme_path = ["."]
141140
else:
142-
html_theme_path = ['.']
141+
html_theme_path = ["."]
143142

144143
# Theme options are theme-specific and customize the look and feel of a theme
145144
# further. For a list of options available for each theme, see the
146145
# documentation.
147-
#html_theme_options = {}
146+
# html_theme_options = {}
148147

149148
# Add any paths that contain custom themes here, relative to this directory.
150149
# html_theme_path = ['.']
151150

152151
# The name for this set of Sphinx documents. If None, it defaults to
153152
# "<project> v<release> documentation".
154-
#html_title = None
153+
# html_title = None
155154

156155
# A shorter title for the navigation bar. Default is the same as html_title.
157-
#html_short_title = None
156+
# html_short_title = None
158157

159158
# The name of an image file (relative to this directory) to place at the top
160159
# of the sidebar.
161-
#html_logo = '../../logo/trans-logo.png'
160+
# html_logo = '../../logo/trans-logo.png'
162161

163162
# The name of an image file (within the static path) to use as favicon of the
164163
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
165164
# pixels large.
166-
html_favicon = 'static/favicon.ico'
165+
html_favicon = "static/favicon.ico"
167166

168167
# Add any paths that contain custom static files (such as style sheets) here,
169168
# relative to this directory. They are copied after the builtin static files,
170169
# so a file named "default.css" will overwrite the builtin "default.css".
171-
html_static_path = ['static']
170+
html_static_path = ["static"]
172171

173172
# Add a custom CSS file for HTML generation
174173
html_css_files = [
175-
'custom.css',
174+
"custom.css",
176175
]
177176
# Add any extra paths that contain custom files (such as robots.txt or
178177
# .htaccess) here, relative to this directory. These files are copied
179178
# directly to the root of the documentation.
180-
#html_extra_path = []
179+
# html_extra_path = []
181180

182181
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
183182
# using the given strftime format.
184-
html_last_updated_fmt = '%d %b %Y'
183+
html_last_updated_fmt = "%d %b %Y"
185184

186185
# If true, SmartyPants will be used to convert quotes and dashes to
187186
# typographically correct entities.
188-
#html_use_smartypants = True
187+
# html_use_smartypants = True
189188

190189
# Custom sidebar templates, maps document names to template names.
191-
#html_sidebars = {}
190+
# html_sidebars = {}
192191

193192
# Additional templates that should be rendered to pages, maps page names to
194193
# template names.
195194
html_additional_pages = {"index": "topindex.html"}
196195

197196
# If false, no module index is generated.
198-
#html_domain_indices = True
197+
# html_domain_indices = True
199198

200199
# If false, no index is generated.
201-
#html_use_index = True
200+
# html_use_index = True
202201

203202
# If true, the index is split into individual pages for each letter.
204-
#html_split_index = False
203+
# html_split_index = False
205204

206205
# If true, links to the reST sources are added to the pages.
207-
#html_show_sourcelink = True
206+
# html_show_sourcelink = True
208207

209208
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
210-
#html_show_sphinx = True
209+
# html_show_sphinx = True
211210

212211
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
213-
#html_show_copyright = True
212+
# html_show_copyright = True
214213

215214
# If true, an OpenSearch description file will be output, and all pages will
216215
# contain a <link> tag referring to it. The value of this option must be the
217216
# base URL from which the finished HTML is served.
218-
#html_use_opensearch = ''
217+
# html_use_opensearch = ''
219218

220219
# This is the file name suffix for HTML files (e.g. ".xhtml").
221-
#html_file_suffix = None
220+
# html_file_suffix = None
222221

223222
# Output file base name for HTML help builder.
224-
htmlhelp_basename = 'MicroPythondoc'
223+
htmlhelp_basename = "MicroPythondoc"
225224

226225

227226
# -- Options for LaTeX output ---------------------------------------------
228227

229228
latex_elements = {
230-
# The paper size ('letterpaper' or 'a4paper').
231-
#'papersize': 'letterpaper',
232-
233-
# The font size ('10pt', '11pt' or '12pt').
234-
#'pointsize': '10pt',
235-
236-
# Additional stuff for the LaTeX preamble.
237-
#'preamble': '',
238-
# Include 3 levels of headers in PDF ToC
239-
'preamble': r'\setcounter{tocdepth}{2}',
229+
# The paper size ('letterpaper' or 'a4paper').
230+
#'papersize': 'letterpaper',
231+
# The font size ('10pt', '11pt' or '12pt').
232+
#'pointsize': '10pt',
233+
# Additional stuff for the LaTeX preamble.
234+
#'preamble': '',
235+
# Include 3 levels of headers in PDF ToC
236+
"preamble": r"\setcounter{tocdepth}{2}",
240237
}
241238

242239
# Grouping the document tree into LaTeX files. List of tuples
243240
# (source start file, target name, title,
244241
# author, documentclass [howto, manual, or own class]).
245242
latex_documents = [
246-
(master_doc, 'MicroPython.tex', 'MicroPython Documentation',
247-
'Damien P. George, Paul Sokolovsky, and contributors', 'manual'),
243+
(
244+
master_doc,
245+
"MicroPython.tex",
246+
"MicroPython Documentation",
247+
"Damien P. George, Paul Sokolovsky, and contributors",
248+
"manual",
249+
),
248250
]
249251

250252
# The name of an image file (relative to this directory) to place at the top of
251253
# the title page.
252-
#latex_logo = None
254+
# latex_logo = None
253255

254256
# For "manual" documents, if this is true, then toplevel headings are parts,
255257
# not chapters.
256-
#latex_use_parts = False
258+
# latex_use_parts = False
257259

258260
# If true, show page references after internal links.
259-
#latex_show_pagerefs = False
261+
# latex_show_pagerefs = False
260262

261263
# If true, show URL addresses after external links.
262-
#latex_show_urls = False
264+
# latex_show_urls = False
263265

264266
# Documents to append as an appendix to all manuals.
265-
#latex_appendices = []
267+
# latex_appendices = []
266268

267269
# If false, no module index is generated.
268-
#latex_domain_indices = True
270+
# latex_domain_indices = True
269271

270272
# Enable better Unicode support so that `make latexpdf` doesn't fail
271273
latex_engine = "xelatex"
@@ -275,12 +277,17 @@
275277
# One entry per manual page. List of tuples
276278
# (source start file, name, description, authors, manual section).
277279
man_pages = [
278-
('index', 'micropython', 'MicroPython Documentation',
279-
['Damien P. George, Paul Sokolovsky, and contributors'], 1),
280+
(
281+
"index",
282+
"micropython",
283+
"MicroPython Documentation",
284+
["Damien P. George, Paul Sokolovsky, and contributors"],
285+
1,
286+
),
280287
]
281288

282289
# If true, show URL addresses after external links.
283-
#man_show_urls = False
290+
# man_show_urls = False
284291

285292

286293
# -- Options for Texinfo output -------------------------------------------
@@ -289,23 +296,29 @@
289296
# (source start file, target name, title, author,
290297
# dir menu entry, description, category)
291298
texinfo_documents = [
292-
(master_doc, 'MicroPython', 'MicroPython Documentation',
293-
'Damien P. George, Paul Sokolovsky, and contributors', 'MicroPython', 'One line description of project.',
294-
'Miscellaneous'),
299+
(
300+
master_doc,
301+
"MicroPython",
302+
"MicroPython Documentation",
303+
"Damien P. George, Paul Sokolovsky, and contributors",
304+
"MicroPython",
305+
"One line description of project.",
306+
"Miscellaneous",
307+
),
295308
]
296309

297310
# Documents to append as an appendix to all manuals.
298-
#texinfo_appendices = []
311+
# texinfo_appendices = []
299312

300313
# If false, no module index is generated.
301-
#texinfo_domain_indices = True
314+
# texinfo_domain_indices = True
302315

303316
# How to display URL addresses: 'footnote', 'no', or 'inline'.
304-
#texinfo_show_urls = 'footnote'
317+
# texinfo_show_urls = 'footnote'
305318

306319
# If true, do not generate a @detailmenu in the "Top" node's menu.
307-
#texinfo_no_detailmenu = False
320+
# texinfo_no_detailmenu = False
308321

309322

310323
# Example configuration for intersphinx: refer to the Python standard library.
311-
intersphinx_mapping = {'python': ('https://docs.python.org/3.5', None)}
324+
intersphinx_mapping = {"python": ("https://docs.python.org/3.5", None)}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import os
22

33
# Directory that the project lives in, aka ../..
4-
SITE_ROOT = '/'.join(os.path.dirname(__file__).split('/')[0:-2])
4+
SITE_ROOT = "/".join(os.path.dirname(__file__).split("/")[0:-2])
55

66
TEMPLATE_DIRS = (
7-
"%s/templates/" % SITE_ROOT, # Your custom template directory, before the RTD one to override it.
8-
"%s/readthedocs/templates/" % SITE_ROOT, # Default RTD template dir
7+
"%s/templates/"
8+
% SITE_ROOT, # Your custom template directory, before the RTD one to override it.
9+
"%s/readthedocs/templates/" % SITE_ROOT, # Default RTD template dir
910
)

0 commit comments

Comments
 (0)