Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit 54f9ba1

Browse files
committed
Reformat python code with 'ruff format'
1 parent 9227079 commit 54f9ba1

File tree

4 files changed

+469
-346
lines changed

4 files changed

+469
-346
lines changed

conf.py

Lines changed: 81 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,39 @@
1717
# If extensions (or modules to document with autodoc) are in another directory,
1818
# add these directories to sys.path here. If the directory is relative to the
1919
# documentation root, use os.path.abspath to make it absolute, like shown here.
20-
sys.path.insert(0, os.path.abspath('ext'))
20+
sys.path.insert(0, os.path.abspath("ext"))
2121

2222
# -- General configuration -----------------------------------------------------
2323

2424
# If your documentation needs a minimal Sphinx version, state it here.
25-
#needs_sphinx = '1.0'
25+
# needs_sphinx = '1.0'
2626

2727
# Add any Sphinx extension module names here, as strings. They can be extensions
2828
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
29-
extensions += ['zeek', 'sphinx.ext.todo', 'zeek_pygments', 'spicy-pygments', 'literal-emph']
30-
extensions += ['sphinx.ext.extlinks']
29+
extensions += [
30+
"zeek",
31+
"sphinx.ext.todo",
32+
"zeek_pygments",
33+
"spicy-pygments",
34+
"literal-emph",
35+
]
36+
extensions += ["sphinx.ext.extlinks"]
3137

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

3541
# The suffix of source filenames.
36-
source_suffix = '.rst'
42+
source_suffix = ".rst"
3743

3844
# The encoding of source files.
39-
#source_encoding = 'utf-8-sig'
45+
# source_encoding = 'utf-8-sig'
4046

4147
# The master toctree document.
42-
master_doc = 'index'
48+
master_doc = "index"
4349

4450
# General information about the project.
45-
project = 'Zeek'
46-
copyright = '2019-2023, The Zeek Project'
51+
project = "Zeek"
52+
copyright = "2019-2023, The Zeek Project"
4753

4854
# The version info for the project you're documenting, acts as replacement for
4955
# |version| and |release|, also used in various other places throughout the
@@ -56,22 +62,23 @@
5662

5763
try:
5864
# Use the actual Zeek version if available
59-
with open('../VERSION') as f:
65+
with open("../VERSION") as f:
6066
version = f.readline().strip()
6167
except:
6268
try:
6369
import re
6470

6571
import git
6672

67-
repo = git.Repo(os.path.abspath('.'))
73+
repo = git.Repo(os.path.abspath("."))
6874
version = "git/master"
6975

70-
version_tag_re = r'v\d+\.\d+(\.\d+)?'
71-
version_tags = [t for t in repo.tags if
72-
t.commit == repo.head.commit and
73-
re.match(version_tag_re, str(t))
74-
]
76+
version_tag_re = r"v\d+\.\d+(\.\d+)?"
77+
version_tags = [
78+
t
79+
for t in repo.tags
80+
if t.commit == repo.head.commit and re.match(version_tag_re, str(t))
81+
]
7582
# Note: sorting by tag date doesn't necessarily give correct
7683
# order in terms of version numbers, but doubtful that will ever be
7784
# a problem (if we ever do re-tag an old version number on a given
@@ -100,49 +107,49 @@
100107
# `release/.*`, and the tip of those branches will always be in sync with
101108
# auto-generated content by simply having `zeek/ci/update-zeekygen-docs.sh`
102109
# change this to `release/.*` when needed.
103-
zeek_code_version = 'master'
104-
zeek_code_url = f'https://github.com/zeek/zeek/blob/{zeek_code_version}'
110+
zeek_code_version = "master"
111+
zeek_code_url = f"https://github.com/zeek/zeek/blob/{zeek_code_version}"
105112

106113
# The language for content autogenerated by Sphinx. Refer to documentation
107114
# for a list of supported languages.
108-
#language = None
115+
# language = None
109116

110117
# There are two options for replacing |today|: either, you set today to some
111118
# non-false value, then it is used:
112-
#today = ''
119+
# today = ''
113120
# Else, today_fmt is used as the format for a strftime call.
114-
today_fmt = '%B %d, %Y'
121+
today_fmt = "%B %d, %Y"
115122

116123
# List of patterns, relative to source directory, that match files and
117124
# directories to ignore when looking for source files.
118-
exclude_patterns = [".#*", 'script-reference/autogenerated-*']
125+
exclude_patterns = [".#*", "script-reference/autogenerated-*"]
119126

120127
# The reST default role (used for this markup: `text`) to use for all documents.
121-
#default_role = None
128+
# default_role = None
122129

123130
# If true, '()' will be appended to :func: etc. cross-reference text.
124-
#add_function_parentheses = True
131+
# add_function_parentheses = True
125132

126133
# If true, the current module name will be prepended to all description
127134
# unit titles (such as .. function::).
128-
#add_module_names = True
135+
# add_module_names = True
129136

130137
# If true, sectionauthor and moduleauthor directives will be shown in the
131138
# output. They are ignored by default.
132139
show_authors = True
133140

134141
# The name of the Pygments (syntax highlighting) style to use.
135-
pygments_style = 'sphinx'
142+
pygments_style = "sphinx"
136143

137-
highlight_language = 'none'
144+
highlight_language = "none"
138145

139146
# A list of ignored prefixes for module index sorting.
140-
#modindex_common_prefix = []
147+
# modindex_common_prefix = []
141148

142149

143150
# -- Options for HTML output ---------------------------------------------------
144151

145-
html_theme = 'sphinx_rtd_theme'
152+
html_theme = "sphinx_rtd_theme"
146153

147154
# Set canonical URL from the Read the Docs Domain
148155
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
@@ -153,148 +160,147 @@
153160
html_context = {}
154161
html_context["READTHEDOCS"] = True
155162

156-
html_last_updated_fmt = '%B %d, %Y'
163+
html_last_updated_fmt = "%B %d, %Y"
157164

158165
# Theme options are theme-specific and customize the look and feel of a theme
159166
# further. For a list of options available for each theme, see the
160167
# documentation.
161168
html_theme_options = {
162-
'analytics_id': 'UA-144186885-1',
163-
'collapse_navigation': False,
164-
'display_version': True,
169+
"analytics_id": "UA-144186885-1",
170+
"collapse_navigation": False,
171+
"display_version": True,
165172
"style_external_links": True,
166173
}
167174

168175
# Add any paths that contain custom themes here, relative to this directory.
169-
#html_theme_path = []
176+
# html_theme_path = []
170177

171178
# The name for this set of Sphinx documents. If None, it defaults to
172179
# "<project> v<release> Documentation".
173-
html_title = f'Book of Zeek ({release})'
180+
html_title = f"Book of Zeek ({release})"
174181

175182
# A shorter title for the navigation bar. Default is the same as html_title.
176-
#html_short_title = None
183+
# html_short_title = None
177184

178185
# The name of an image file (relative to this directory) to place at the top
179186
# of the sidebar.
180-
html_logo = 'images/zeek-logo-sidebar.png'
187+
html_logo = "images/zeek-logo-sidebar.png"
181188

182189
# The name of an image file (within the static path) to use as favicon of the
183190
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
184191
# pixels large.
185-
html_favicon = 'images/zeek-favicon.ico'
192+
html_favicon = "images/zeek-favicon.ico"
186193

187194
# Add any paths that contain custom static files (such as style sheets) here,
188195
# relative to this directory. They are copied after the builtin static files,
189196
# so a file named "default.css" will overwrite the builtin "default.css".
190-
html_static_path = ['_static']
197+
html_static_path = ["_static"]
198+
191199

192200
def setup(app):
193201
app.add_css_file("theme_overrides.css")
194202
from sphinx.highlighting import lexers
195203
from zeek_pygments import ZeekLexer
196-
lexers['zeek'] = ZeekLexer()
197-
app.add_config_value('zeek-code-url', zeek_code_url, 'env')
204+
205+
lexers["zeek"] = ZeekLexer()
206+
app.add_config_value("zeek-code-url", zeek_code_url, "env")
207+
198208

199209
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
200210
# using the given strftime format.
201-
#html_last_updated_fmt = '%b %d, %Y'
211+
# html_last_updated_fmt = '%b %d, %Y'
202212

203213
# If true, SmartyPants will be used to convert quotes and dashes to
204214
# typographically correct entities.
205-
#html_use_smartypants = True
215+
# html_use_smartypants = True
206216

207217
# Custom sidebar templates, maps document names to template names.
208-
#html_sidebars = {
218+
# html_sidebars = {
209219
#'**': ['localtoc.html', 'sourcelink.html', 'searchbox.html'],
210-
#}
220+
# }
211221

212222
# Additional templates that should be rendered to pages, maps page names to
213223
# template names.
214-
#html_additional_pages = {}
224+
# html_additional_pages = {}
215225

216226
# If false, no module index is generated.
217-
#html_domain_indices = True
227+
# html_domain_indices = True
218228

219229
# If false, no index is generated.
220-
#html_use_index = True
230+
# html_use_index = True
221231

222232
# If true, the index is split into individual pages for each letter.
223-
#html_split_index = False
233+
# html_split_index = False
224234

225235
# If true, links to the reST sources are added to the pages.
226-
#html_show_sourcelink = True
236+
# html_show_sourcelink = True
227237

228238
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
229-
#html_show_sphinx = True
239+
# html_show_sphinx = True
230240

231241
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
232-
#html_show_copyright = True
242+
# html_show_copyright = True
233243

234244
# If true, an OpenSearch description file will be output, and all pages will
235245
# contain a <link> tag referring to it. The value of this option must be the
236246
# base URL from which the finished HTML is served.
237-
#html_use_opensearch = ''
247+
# html_use_opensearch = ''
238248

239249
# This is the file name suffix for HTML files (e.g. ".xhtml").
240-
#html_file_suffix = None
250+
# html_file_suffix = None
241251

242252
# Output file base name for HTML help builder.
243-
htmlhelp_basename = 'zeek-docs'
253+
htmlhelp_basename = "zeek-docs"
244254

245255
# -- Options for LaTeX output --------------------------------------------------
246256

247257
# The paper size ('letter' or 'a4').
248-
#latex_paper_size = 'letter'
258+
# latex_paper_size = 'letter'
249259

250260
# The font size ('10pt', '11pt' or '12pt').
251-
#latex_font_size = '10pt'
261+
# latex_font_size = '10pt'
252262

253263
# Grouping the document tree into LaTeX files. List of tuples
254264
# (source start file, target name, title, author, documentclass [howto/manual]).
255265
latex_documents = [
256-
('index', 'Zeek.tex', 'Zeek Documentation',
257-
'The Zeek Project', 'manual'),
266+
("index", "Zeek.tex", "Zeek Documentation", "The Zeek Project", "manual"),
258267
]
259268

260269
# The name of an image file (relative to this directory) to place at the top of
261270
# the title page.
262-
#latex_logo = None
271+
# latex_logo = None
263272

264273
# For "manual" documents, if this is true, then toplevel headings are parts,
265274
# not chapters.
266-
#latex_use_parts = False
275+
# latex_use_parts = False
267276

268277
# If true, show page references after internal links.
269-
#latex_show_pagerefs = False
278+
# latex_show_pagerefs = False
270279

271280
# If true, show URL addresses after external links.
272-
#latex_show_urls = False
281+
# latex_show_urls = False
273282

274283
# Additional stuff for the LaTeX preamble.
275-
#latex_preamble = ''
284+
# latex_preamble = ''
276285

277286
# Documents to append as an appendix to all manuals.
278-
#latex_appendices = []
287+
# latex_appendices = []
279288

280289
# If false, no module index is generated.
281-
#latex_domain_indices = True
290+
# latex_domain_indices = True
282291

283292
# -- Options for manual page output --------------------------------------------
284293

285294
# One entry per manual page. List of tuples
286295
# (source start file, name, description, authors, manual section).
287-
man_pages = [
288-
('index', 'zeek', 'Zeek Documentation',
289-
['The Zeek Project'], 1)
290-
]
296+
man_pages = [("index", "zeek", "Zeek Documentation", ["The Zeek Project"], 1)]
291297

292298
# -- Options for todo plugin --------------------------------------------
293-
todo_include_todos=True
299+
todo_include_todos = True
294300

295301
extlinks = {
296-
'slacklink': ('https://zeek.org/slack%s', None),
297-
'discourselink': ('https://community.zeek.org/%s', None),
298-
'spicylink': ('https://docs.zeek.org/projects/spicy/en/latest/%s', None),
302+
"slacklink": ("https://zeek.org/slack%s", None),
303+
"discourselink": ("https://community.zeek.org/%s", None),
304+
"spicylink": ("https://docs.zeek.org/projects/spicy/en/latest/%s", None),
299305
}
300306
extlinks_detect_hardcoded_links = True

ext/literal-emph.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,32 @@
1010
# Adding " (no-emph)" to the end of a line within the 'literal-emph' content
1111
# disables substitutions for that line.
1212

13+
1314
class LiteralEmphNode(nodes.General, nodes.Element):
1415
pass
1516

17+
1618
class LiteralEmph(sphinx.directives.code.CodeBlock):
1719
def run(self):
1820
node = LiteralEmphNode()
1921
node += super().run()
2022
return [node]
2123

24+
2225
def visit_litemph_node(self, node):
2326
pass
2427

28+
2529
def depart_litemph_node(self, node):
2630
text = self.body[-1]
27-
text = re.sub(r'\*\*(.*?)\*\*(?!.* \(no-emph\)\n)',
28-
r'<strong>\1</strong>',
29-
text)
30-
text = re.sub(r'(.*) \(no-emph\)\n', r'\1\n', text)
31+
text = re.sub(r"\*\*(.*?)\*\*(?!.* \(no-emph\)\n)", r"<strong>\1</strong>", text)
32+
text = re.sub(r"(.*) \(no-emph\)\n", r"\1\n", text)
3133
self.body[-1] = text
3234

35+
3336
def setup(app):
3437
app.add_directive("literal-emph", LiteralEmph)
35-
app.add_node(LiteralEmphNode,
36-
html=(visit_litemph_node, depart_litemph_node))
38+
app.add_node(LiteralEmphNode, html=(visit_litemph_node, depart_litemph_node))
3739
return {
38-
'parallel_read_safe': True,
40+
"parallel_read_safe": True,
3941
}

0 commit comments

Comments
 (0)