Skip to content

Commit 1176948

Browse files
committed
reformat with ruff
1 parent 6a5b427 commit 1176948

17 files changed

+431
-319
lines changed

doc/conf.py

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@
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 = ['sphinx.ext.viewcode']
29+
extensions = ["sphinx.ext.viewcode"]
3030

3131
# Add any paths that contain templates here, relative to this directory.
32-
templates_path = ['_templates']
32+
templates_path = ["_templates"]
3333

3434
# The suffix of source filenames.
35-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3636

3737
# The encoding of source files.
38-
#source_encoding = 'utf-8-sig'
38+
# source_encoding = 'utf-8-sig'
3939

4040
# The master toctree document.
41-
master_doc = 'index'
41+
master_doc = "index"
4242

4343
# General information about the project.
44-
project = u'python-mpd2'
45-
copyright = u'2013, Jörg Thalheim'
44+
project = "python-mpd2"
45+
copyright = "2013, Jörg Thalheim"
4646

4747
# The version info for the project you're documenting, acts as replacement for
4848
# |version| and |release|, also used in various other places throughout the
@@ -55,174 +55,176 @@
5555

5656
# The language for content autogenerated by Sphinx. Refer to documentation
5757
# for a list of supported languages.
58-
#language = None
58+
# language = None
5959

6060
# There are two options for replacing |today|: either, you set today to some
6161
# non-false value, then it is used:
62-
#today = ''
62+
# today = ''
6363
# Else, today_fmt is used as the format for a strftime call.
64-
#today_fmt = '%B %d, %Y'
64+
# today_fmt = '%B %d, %Y'
6565

6666
# List of patterns, relative to source directory, that match files and
6767
# directories to ignore when looking for source files.
68-
exclude_patterns = ['_build']
68+
exclude_patterns = ["_build"]
6969

7070
# The reST default role (used for this markup: `text`) to use for all documents.
71-
#default_role = None
71+
# default_role = None
7272

7373
# If true, '()' will be appended to :func: etc. cross-reference text.
74-
#add_function_parentheses = True
74+
# add_function_parentheses = True
7575

7676
# If true, the current module name will be prepended to all description
7777
# unit titles (such as .. function::).
78-
#add_module_names = True
78+
# add_module_names = True
7979

8080
# If true, sectionauthor and moduleauthor directives will be shown in the
8181
# output. They are ignored by default.
82-
#show_authors = False
82+
# show_authors = False
8383

8484
# The name of the Pygments (syntax highlighting) style to use.
85-
pygments_style = 'sphinx'
85+
pygments_style = "sphinx"
8686

8787
# A list of ignored prefixes for module index sorting.
88-
#modindex_common_prefix = []
88+
# modindex_common_prefix = []
8989

9090
# If true, keep warnings as "system message" paragraphs in the built documents.
91-
#keep_warnings = False
91+
# keep_warnings = False
9292

9393

9494
# -- Options for HTML output ---------------------------------------------------
9595

9696
# The theme to use for HTML and HTML Help pages. See the documentation for
9797
# a list of builtin themes.
98-
html_theme = 'default'
98+
html_theme = "default"
9999

100100
# Theme options are theme-specific and customize the look and feel of a theme
101101
# further. For a list of options available for each theme, see the
102102
# documentation.
103-
#html_theme_options = {}
103+
# html_theme_options = {}
104104

105105
# Add any paths that contain custom themes here, relative to this directory.
106-
#html_theme_path = []
106+
# html_theme_path = []
107107

108108
# The name for this set of Sphinx documents. If None, it defaults to
109109
# "<project> v<release> documentation".
110-
#html_title = None
110+
# html_title = None
111111

112112
# A shorter title for the navigation bar. Default is the same as html_title.
113-
#html_short_title = None
113+
# html_short_title = None
114114

115115
# The name of an image file (relative to this directory) to place at the top
116116
# of the sidebar.
117-
#html_logo = None
117+
# html_logo = None
118118

119119
# The name of an image file (within the static path) to use as favicon of the
120120
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
121121
# pixels large.
122-
#html_favicon = None
122+
# html_favicon = None
123123

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

129129
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
130130
# using the given strftime format.
131-
#html_last_updated_fmt = '%b %d, %Y'
131+
# html_last_updated_fmt = '%b %d, %Y'
132132

133133
# If true, SmartyPants will be used to convert quotes and dashes to
134134
# typographically correct entities.
135-
#html_use_smartypants = True
135+
# html_use_smartypants = True
136136

137137
# Custom sidebar templates, maps document names to template names.
138-
#html_sidebars = {}
138+
# html_sidebars = {}
139139

140140
# Additional templates that should be rendered to pages, maps page names to
141141
# template names.
142-
#html_additional_pages = {}
142+
# html_additional_pages = {}
143143

144144
# If false, no module index is generated.
145-
#html_domain_indices = True
145+
# html_domain_indices = True
146146

147147
# If false, no index is generated.
148-
#html_use_index = True
148+
# html_use_index = True
149149

150150
# If true, the index is split into individual pages for each letter.
151-
#html_split_index = False
151+
# html_split_index = False
152152

153153
# If true, links to the reST sources are added to the pages.
154-
#html_show_sourcelink = True
154+
# html_show_sourcelink = True
155155

156156
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
157-
#html_show_sphinx = True
157+
# html_show_sphinx = True
158158

159159
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
160-
#html_show_copyright = True
160+
# html_show_copyright = True
161161

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

167167
# This is the file name suffix for HTML files (e.g. ".xhtml").
168-
#html_file_suffix = None
168+
# html_file_suffix = None
169169

170170
# Output file base name for HTML help builder.
171-
htmlhelp_basename = 'python-mpd2doc'
171+
htmlhelp_basename = "python-mpd2doc"
172172

173173

174174
# -- Options for LaTeX output --------------------------------------------------
175175

176176
latex_elements = {
177-
# The paper size ('letterpaper' or 'a4paper').
178-
#'papersize': 'letterpaper',
179-
180-
# The font size ('10pt', '11pt' or '12pt').
181-
#'pointsize': '10pt',
182-
183-
# Additional stuff for the LaTeX preamble.
184-
#'preamble': '',
177+
# The paper size ('letterpaper' or 'a4paper').
178+
#'papersize': 'letterpaper',
179+
# The font size ('10pt', '11pt' or '12pt').
180+
#'pointsize': '10pt',
181+
# Additional stuff for the LaTeX preamble.
182+
#'preamble': '',
185183
}
186184

187185
# Grouping the document tree into LaTeX files. List of tuples
188186
# (source start file, target name, title, author, documentclass [howto/manual]).
189187
latex_documents = [
190-
('index', 'python-mpd2.tex', u'python-mpd2 Documentation',
191-
u'Jörg Thalheim', 'manual'),
188+
(
189+
"index",
190+
"python-mpd2.tex",
191+
"python-mpd2 Documentation",
192+
"Jörg Thalheim",
193+
"manual",
194+
),
192195
]
193196

194197
# The name of an image file (relative to this directory) to place at the top of
195198
# the title page.
196-
#latex_logo = None
199+
# latex_logo = None
197200

198201
# For "manual" documents, if this is true, then toplevel headings are parts,
199202
# not chapters.
200-
#latex_use_parts = False
203+
# latex_use_parts = False
201204

202205
# If true, show page references after internal links.
203-
#latex_show_pagerefs = False
206+
# latex_show_pagerefs = False
204207

205208
# If true, show URL addresses after external links.
206-
#latex_show_urls = False
209+
# latex_show_urls = False
207210

208211
# Documents to append as an appendix to all manuals.
209-
#latex_appendices = []
212+
# latex_appendices = []
210213

211214
# If false, no module index is generated.
212-
#latex_domain_indices = True
215+
# latex_domain_indices = True
213216

214217

215218
# -- Options for manual page output --------------------------------------------
216219

217220
# One entry per manual page. List of tuples
218221
# (source start file, name, description, authors, manual section).
219222
man_pages = [
220-
('index', 'python-mpd2', u'python-mpd2 Documentation',
221-
[u'Jörg Thalheim'], 1)
223+
("index", "python-mpd2", "python-mpd2 Documentation", ["Jörg Thalheim"], 1)
222224
]
223225

224226
# If true, show URL addresses after external links.
225-
#man_show_urls = False
227+
# man_show_urls = False
226228

227229

228230
# -- Options for Texinfo output ------------------------------------------------
@@ -231,19 +233,25 @@
231233
# (source start file, target name, title, author,
232234
# dir menu entry, description, category)
233235
texinfo_documents = [
234-
('index', 'python-mpd2', u'python-mpd2 Documentation',
235-
u'Jörg Thalheim', 'python-mpd2', 'One line description of project.',
236-
'Miscellaneous'),
236+
(
237+
"index",
238+
"python-mpd2",
239+
"python-mpd2 Documentation",
240+
"Jörg Thalheim",
241+
"python-mpd2",
242+
"One line description of project.",
243+
"Miscellaneous",
244+
),
237245
]
238246

239247
# Documents to append as an appendix to all manuals.
240-
#texinfo_appendices = []
248+
# texinfo_appendices = []
241249

242250
# If false, no module index is generated.
243-
#texinfo_domain_indices = True
251+
# texinfo_domain_indices = True
244252

245253
# How to display URL addresses: 'footnote', 'no', or 'inline'.
246-
#texinfo_show_urls = 'footnote'
254+
# texinfo_show_urls = 'footnote'
247255

248256
# If true, do not generate a @detailmenu in the "Top" node's menu.
249-
#texinfo_no_detailmenu = False
257+
# texinfo_no_detailmenu = False

doc/generate_command_reference.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os.path
66
from textwrap import TextWrapper
77
import urllib.request
8+
89
try:
910
from lxml import etree
1011
except ImportError:
@@ -17,15 +18,15 @@
1718

1819
def get_text(elements, itemize=False):
1920
paragraphs = []
20-
highlight_elements = ['varname', 'parameter']
21+
highlight_elements = ["varname", "parameter"]
2122
strip_elements = [
22-
'returnvalue',
23-
'command',
24-
'link',
25-
'footnote',
26-
'simpara',
27-
'footnoteref',
28-
'function'
23+
"returnvalue",
24+
"command",
25+
"link",
26+
"footnote",
27+
"simpara",
28+
"footnoteref",
29+
"function",
2930
] + highlight_elements
3031
for element in elements:
3132
# put "Since MPD version..." in parenthese
@@ -42,17 +43,18 @@ def get_text(elements, itemize=False):
4243
else:
4344
initial_indent = " "
4445
subsequent_indent = " "
45-
wrapper = TextWrapper(subsequent_indent=subsequent_indent,
46-
initial_indent=initial_indent)
46+
wrapper = TextWrapper(
47+
subsequent_indent=subsequent_indent, initial_indent=initial_indent
48+
)
4749
text = element.text.replace("\n", " ").strip()
48-
text = re.subn(r'\s+', ' ', text)[0]
50+
text = re.subn(r"\s+", " ", text)[0]
4951
paragraphs.append(wrapper.fill(text))
5052
return "\n\n".join(paragraphs)
5153

5254

5355
def main(url):
5456
header_file = os.path.join(SCRIPT_PATH, "commands_header.txt")
55-
with open(header_file, 'r') as f:
57+
with open(header_file, "r") as f:
5658
print(f.read())
5759

5860
r = urllib.request.urlopen(url)
@@ -97,7 +99,7 @@ def main(url):
9799
cmd += "_" + subcommand
98100
print(".. function:: MPDClient." + cmd + "(" + args + ")")
99101
description = get_text(entry.xpath("listitem/para"))
100-
description = re.sub(r':$', r'::', description, flags=re.MULTILINE)
102+
description = re.sub(r":$", r"::", description, flags=re.MULTILINE)
101103

102104
print("\n")
103105
print(description)
@@ -110,6 +112,7 @@ def main(url):
110112
print(get_text(item.xpath("para"), itemize=True))
111113
print("\n")
112114

115+
113116
if __name__ == "__main__":
114117
url = "https://raw.githubusercontent.com/MusicPlayerDaemon/MPD/master/doc/protocol.xml"
115118
if len(sys.argv) > 1:

0 commit comments

Comments
 (0)