Skip to content

Commit 6d3902c

Browse files
authored
Merge pull request #96 from hugovk/update-versions
Add support for Python 3.10-3.11, drop EOL 3.6
2 parents c3e92fc + 8ad970c commit 6d3902c

6 files changed

Lines changed: 21 additions & 26 deletions

File tree

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# Sphinxcontrib-mesmaid demo documentation build configuration file, created by
54
# sphinx-quickstart on Sun Apr 23 13:10:20 2017.

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# -*- coding: utf-8 -*-
2-
31
import io
42
from setuptools import setup, find_packages
53

6-
readme = io.open('README.rst', encoding="utf-8").read()
7-
changes = io.open('CHANGELOG.rst', encoding="utf-8").read()
4+
readme = open('README.rst', encoding="utf-8").read()
5+
changes = open('CHANGELOG.rst', encoding="utf-8").read()
86
version = '0.7.1'
97

108

@@ -26,7 +24,7 @@ def remove_block(text, token, margin=0):
2624
readme_ = remove_block(readme_, ".. autoclasstree::")
2725
readme_ = remove_block(readme_, ".. autoclasstree::")
2826
readme_ = remove_block(readme_, ".. versionchanged::")
29-
return "{}\n\n{}".format(readme_, changes)
27+
return f"{readme_}\n\n{changes}"
3028

3129

3230
setup(
@@ -35,10 +33,11 @@ def remove_block(text, token, margin=0):
3533
url='https://github.com/mgaitan/sphinxcontrib-mermaid',
3634
download_url='https://pypi.python.org/pypi/sphinxcontrib-mermaid',
3735
license='BSD',
38-
author=u'Martín Gaitán',
36+
author='Martín Gaitán',
3937
author_email='gaitan@gmail.com',
4038
description='Mermaid diagrams in yours Sphinx powered docs',
4139
long_description=long_description(),
40+
python_requires='>=3.7',
4241
classifiers=[
4342
'Development Status :: 4 - Beta',
4443
'Environment :: Console',
@@ -48,10 +47,11 @@ def remove_block(text, token, margin=0):
4847
'Operating System :: OS Independent',
4948
'Programming Language :: Python',
5049
'Programming Language :: Python :: 3',
51-
'Programming Language :: Python :: 3.6',
5250
'Programming Language :: Python :: 3.7',
5351
'Programming Language :: Python :: 3.8',
5452
'Programming Language :: Python :: 3.9',
53+
'Programming Language :: Python :: 3.10',
54+
'Programming Language :: Python :: 3.11',
5555
'Programming Language :: Python :: Implementation :: CPython',
5656
'Programming Language :: Python :: Implementation :: PyPy',
5757
'Topic :: Documentation',

sphinxcontrib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinxcontrib
43
~~~~~~~~~~~~~

sphinxcontrib/autoclassdiag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_classes(*cls_or_modules, strict=False):
2424
if inspect.isclass(obj_) and (not strict or obj_.__module__.startswith(obj.__name__)):
2525
yield obj_
2626
else:
27-
raise MermaidError("%s is not a class nor a module" % cls_or_module)
27+
raise MermaidError(f"{cls_or_module} is not a class nor a module")
2828

2929

3030
def class_diagram(*cls_or_modules, full=False, strict=False, namespace=None):
@@ -45,7 +45,7 @@ def get_tree(cls):
4545
get_tree(cls)
4646

4747
return "classDiagram\n" + "\n".join(
48-
" %s <|-- %s" % (a, b)
48+
f" {a} <|-- {b}"
4949
for a, b in sorted(inheritances)
5050
)
5151

sphinxcontrib/mermaid.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinx-mermaid
43
~~~~~~~~~~~~~~~
@@ -88,7 +87,7 @@ def get_mm_code(self):
8887
try:
8988
with codecs.open(filename, 'r', 'utf-8') as fp:
9089
mmcode = fp.read()
91-
except (IOError, OSError):
90+
except OSError:
9291
return [document.reporter.warning(
9392
'External Mermaid file %r not found or reading '
9493
'it failed' % filename, line=self.lineno)]
@@ -151,8 +150,8 @@ def render_mm(self, code, options, _fmt, prefix='mermaid'):
151150
mermaid_cmd_shell = self.builder.config.mermaid_cmd_shell in {True, 'True', 'true'}
152151
hashkey = (code + str(options) + str(self.builder.config.mermaid_sequence_config)).encode('utf-8')
153152

154-
basename = '%s-%s' % (prefix, sha1(hashkey).hexdigest())
155-
fname = '%s.%s' % (basename, _fmt)
153+
basename = f'{prefix}-{sha1(hashkey).hexdigest()}'
154+
fname = f'{basename}.{_fmt}'
156155
relfn = posixpath.join(self.builder.imgpath, fname)
157156
outdir = os.path.join(self.builder.outdir, self.builder.imagedir)
158157
outfn = os.path.join(outdir, fname)
@@ -222,26 +221,26 @@ def render_mm_html(self, node, code, options, prefix='mermaid',
222221

223222
fname, outfn = render_mm(self, code, options, _fmt, prefix)
224223
except MermaidError as exc:
225-
logger.warning('mermaid code %r: ' % code + str(exc))
224+
logger.warning(f'mermaid code {code!r}: ' + str(exc))
226225
raise nodes.SkipNode
227226

228227
if fname is None:
229228
self.body.append(self.encode(code))
230229
else:
231230
if alt is None:
232231
alt = node.get('alt', self.encode(code).strip())
233-
imgcss = imgcls and 'class="%s"' % imgcls or ''
232+
imgcss = imgcls and f'class="{imgcls}"' or ''
234233
if _fmt == 'svg':
235-
svgtag = '''<object data="%s" type="image/svg+xml">
236-
<p class="warning">%s</p></object>\n''' % (fname, alt)
234+
svgtag = f'''<object data="{fname}" type="image/svg+xml">
235+
<p class="warning">{alt}</p></object>
236+
'''
237237
self.body.append(svgtag)
238238
else:
239239
if 'align' in node:
240240
self.body.append('<div align="%s" class="align-%s">' %
241241
(node['align'], node['align']))
242242

243-
self.body.append('<img src="%s" alt="%s" %s/>\n' %
244-
(fname, alt, imgcss))
243+
self.body.append(f'<img src="{fname}" alt="{alt}" {imgcss}/>\n')
245244
if 'align' in node:
246245
self.body.append('</div>\n')
247246

@@ -256,7 +255,7 @@ def render_mm_latex(self, node, code, options, prefix='mermaid'):
256255
try:
257256
fname, outfn = render_mm(self, code, options, 'pdf', prefix)
258257
except MermaidError as exc:
259-
logger.warning('mm code %r: ' % code + str(exc))
258+
logger.warning(f'mm code {code!r}: ' + str(exc))
260259
raise nodes.SkipNode
261260

262261
if self.builder.config.mermaid_pdfcrop != '':
@@ -266,7 +265,7 @@ def render_mm_latex(self, node, code, options, prefix='mermaid'):
266265
except OSError as err:
267266
if err.errno != ENOENT: # No such file or directory
268267
raise
269-
logger.warning('command %r cannot be run (needed to crop pdf), check the mermaid_cmd setting' % self.builder.config.mermaid_pdfcrop)
268+
logger.warning(f'command {self.builder.config.mermaid_pdfcrop!r} cannot be run (needed to crop pdf), check the mermaid_cmd setting')
270269
return None, None
271270

272271
stdout, stderr = p.communicate()
@@ -313,7 +312,7 @@ def render_mm_texinfo(self, node, code, options, prefix='mermaid'):
313312
try:
314313
fname, outfn = render_mm(self, code, options, 'png', prefix)
315314
except MermaidError as exc:
316-
logger.warning('mm code %r: ' % code + str(exc))
315+
logger.warning(f'mm code {code!r}: ' + str(exc))
317316
raise nodes.SkipNode
318317
if fname is not None:
319318
self.body.append('@image{%s,,,[mermaid],png}\n' % fname[:-4])

0 commit comments

Comments
 (0)