Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3b46f2

Browse files
committed
Clean up doc configuration slightly
1 parent 3b7b3a5 commit d3b46f2

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ per-file-ignores =
8585
lib/mpl_toolkits/tests/conftest.py: F401
8686
lib/pylab.py: F401, F403
8787

88-
doc/conf.py: E402, E501
88+
doc/conf.py: E402
8989
tutorials/advanced/path_tutorial.py: E402
9090
tutorials/advanced/patheffects_guide.py: E402
9191
tutorials/advanced/transforms_tutorial.py: E402, E501

doc/conf.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Matplotlib documentation build configuration file, created by
22
# sphinx-quickstart on Fri May 2 12:33:25 2008.
33
#
4-
# This file is execfile()d with the current directory set to its containing dir.
4+
# This file is execfile()d with the current directory set to its containing
5+
# dir.
56
#
67
# The contents of this file are pickled, so don't put values in the namespace
7-
# that aren't pickleable (module imports are okay, they're removed automatically).
8+
# that aren't pickleable (module imports are okay, they're removed
9+
# automatically).
810
#
911
# All configuration values have a default value; values that are commented out
1012
# serve to show the default value.
@@ -30,7 +32,8 @@
3032

3133
# Parse year using SOURCE_DATE_EPOCH, falling back to current time.
3234
# https://reproducible-builds.org/specs/source-date-epoch/
33-
sourceyear = datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))).year
35+
sourceyear = datetime.utcfromtimestamp(
36+
int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))).year
3437

3538
# If your extensions are in another directory, add it here. If the directory
3639
# is relative to the documentation root, use os.path.abspath to make it
@@ -226,9 +229,11 @@ def _check_dependencies():
226229
}
227230

228231
project = 'Matplotlib'
229-
copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, '
230-
'Michael Droettboom and the Matplotlib development '
231-
f'team; 2012 - {sourceyear} The Matplotlib development team')
232+
copyright = (
233+
'2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom '
234+
'and the Matplotlib development team; '
235+
f'2012 - {sourceyear} The Matplotlib development team'
236+
)
232237

233238

234239
# The default replacements for |version| and |release|, also used in various
@@ -389,8 +394,10 @@ def _check_dependencies():
389394
# The paper size ('letter' or 'a4').
390395
latex_paper_size = 'letter'
391396

392-
# Grouping the document tree into LaTeX files. List of tuples
393-
# (source start file, target name, title, author, document class [howto/manual]).
397+
# Grouping the document tree into LaTeX files.
398+
# List of tuples:
399+
# (source start file, target name, title, author,
400+
# document class [howto/manual])
394401

395402
latex_documents = [
396403
('contents', 'Matplotlib.tex', 'Matplotlib',
@@ -618,23 +625,19 @@ def linkcode_resolve(domain, info):
618625
except (OSError, TypeError):
619626
lineno = None
620627

621-
if lineno:
622-
linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
623-
else:
624-
linespec = ""
628+
linespec = (f"#L{lineno:d}-L{lineno + len(source) - 1:d}"
629+
if lineno else "")
625630

626631
startdir = Path(matplotlib.__file__).parent.parent
627632
fn = os.path.relpath(fn, start=startdir).replace(os.path.sep, '/')
628633

629634
if not fn.startswith(('matplotlib/', 'mpl_toolkits/')):
630635
return None
631636

632-
m = re.match(r'^.*post[0-9]+\+\w([a-z0-9]+).\w+$', matplotlib.__version__)
633-
if m:
634-
return "https://github.com/matplotlib/matplotlib/blob/%s/lib/%s%s" % (
635-
m.group(1), fn, linespec)
636-
else:
637-
return "https://github.com/matplotlib/matplotlib/blob/v%s/lib/%s%s" % (
638-
matplotlib.__version__, fn, linespec)
637+
m = re.match(r'^.*post[0-9]+\+\w([a-z0-9]+).\w+$',
638+
matplotlib.__version__)
639+
version = m.group(1) if m else f'v{matplotlib.__version__}'
640+
return ("https://github.com/matplotlib/matplotlib/blob"
641+
f"/{version}/lib/{fn}{linespec}")
639642
else:
640643
extensions.append('sphinx.ext.viewcode')

0 commit comments

Comments
 (0)