diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8b13789..e69de29 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1 +0,0 @@ - diff --git a/doc/source/conf.py b/doc/source/conf.py index d8fda09..ae98f81 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -19,7 +19,8 @@ # import os import sys -sys.path.insert(0, os.path.abspath('vendor')) + +sys.path.insert(0, os.path.abspath("vendor")) # -- General configuration ------------------------------------------------ @@ -32,18 +33,18 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.githubpages', - 'sphinx.ext.intersphinx', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode', - 'youtube', - 'IPython.sphinxext.ipython_directive', - 'IPython.sphinxext.ipython_console_highlighting', - 'matplotlib.sphinxext.plot_directive', - 'numpydoc', - 'sphinx_copybutton', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.githubpages", + "sphinx.ext.intersphinx", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode", + "youtube", + "IPython.sphinxext.ipython_directive", + "IPython.sphinxext.ipython_console_highlighting", + "matplotlib.sphinxext.plot_directive", + "numpydoc", + "sphinx_copybutton", ] # Configuration options for plot_directive. See: @@ -56,37 +57,37 @@ numpydoc_show_class_members = False # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'Scientific Python Cookiecutter' -copyright = '2018, Contributors' -author = 'Contributors' +project = "Scientific Python Cookiecutter" +copyright = "2018, Contributors" +author = "Contributors" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.1' +version = "0.1" # The full version, including alpha/beta/rc tags. -release = '0.1' +release = "0.1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -94,7 +95,7 @@ exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -105,8 +106,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" import sphinx_rtd_theme + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme @@ -118,7 +120,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -126,9 +128,9 @@ # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { - '**': [ - 'relations.html', # needs 'show_related': True theme option to display - 'searchbox.html', + "**": [ + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", ] } @@ -136,7 +138,7 @@ # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'ScientificPythonCookiecutterdoc' +htmlhelp_basename = "ScientificPythonCookiecutterdoc" # -- Options for LaTeX output --------------------------------------------- @@ -145,15 +147,12 @@ # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -163,8 +162,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'ScientificPythonCookiecutter.tex', 'Scientific Python Cookiecutter Documentation', - 'Contributors', 'manual'), + ( + master_doc, + "ScientificPythonCookiecutter.tex", + "Scientific Python Cookiecutter Documentation", + "Contributors", + "manual", + ), ] @@ -173,8 +177,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'scientificpythoncookiecutter', 'Scientific Python Cookiecutter Documentation', - [author], 1) + ( + master_doc, + "scientificpythoncookiecutter", + "Scientific Python Cookiecutter Documentation", + [author], + 1, + ) ] @@ -184,19 +193,23 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'ScientificPythonCookiecutter', 'Scientific Python Cookiecutter Documentation', - author, 'ScientificPythonCookiecutter', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "ScientificPythonCookiecutter", + "Scientific Python Cookiecutter Documentation", + author, + "ScientificPythonCookiecutter", + "One line description of project.", + "Miscellaneous", + ), ] - - # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'python': ('https://docs.python.org/3/', None), - 'numpy': ('https://docs.scipy.org/doc/numpy/', None), - 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None), - 'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None), - 'matplotlib': ('https://matplotlib.org', None), + "python": ("https://docs.python.org/3/", None), + "numpy": ("https://docs.scipy.org/doc/numpy/", None), + "scipy": ("https://docs.scipy.org/doc/scipy/reference/", None), + "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None), + "matplotlib": ("https://matplotlib.org", None), } diff --git a/doc/source/test_examples.py b/doc/source/test_examples.py index 7c92510..8f78209 100644 --- a/doc/source/test_examples.py +++ b/doc/source/test_examples.py @@ -1,7 +1,9 @@ # example/tests/test_examples.py import numpy as np + from ..refraction import snell + # (The above is equivalent to `from example.refraction import snell`. # Read on for why.) @@ -21,6 +23,6 @@ def test_perpendicular(): def test_air_water(): n_air, n_water = 1.00, 1.33 - actual = snell(np.pi/4, n_air, n_water) + actual = snell(np.pi / 4, n_air, n_water) expected = 0.5605584137424605 assert np.allclose(actual, expected) diff --git a/doc/source/vendor/youtube.py b/doc/source/vendor/youtube.py index a42a47d..10bbc8f 100644 --- a/doc/source/vendor/youtube.py +++ b/doc/source/vendor/youtube.py @@ -7,11 +7,13 @@ from __future__ import division import re + from docutils import nodes -from docutils.parsers.rst import directives, Directive +from docutils.parsers.rst import Directive, directives CONTROL_HEIGHT = 30 + def get_size(d, key): if key not in d: return None @@ -20,10 +22,14 @@ def get_size(d, key): raise ValueError("invalid size %r" % d[key]) return int(m.group(1)), m.group(2) or "px" + def css(d): return "; ".join(sorted("%s: %s" % kv for kv in d.items())) -class youtube(nodes.General, nodes.Element): pass + +class youtube(nodes.General, nodes.Element): + pass + def visit_youtube_node(self, node): aspect = node["aspect"] @@ -75,11 +81,16 @@ def visit_youtube_node(self, node): self.body.append(self.starttag(node, "iframe", **attrs)) self.body.append("") + def depart_youtube_node(self, node): pass -def visit_youtube_node_latex(self,node): - self.body.append(r'\begin{quote}\begin{center}\fbox{\url{https://www.youtu.be/%s}}\end{center}\end{quote}'%node['id']) + +def visit_youtube_node_latex(self, node): + self.body.append( + r"\begin{quote}\begin{center}\fbox{\url{https://www.youtu.be/%s}}\end{center}\end{quote}" + % node["id"] + ) class YouTube(Directive): @@ -104,20 +115,22 @@ def run(self): aspect = None width = get_size(self.options, "width") height = get_size(self.options, "height") - return [youtube(id=self.arguments[0], aspect=aspect, width=width, height=height)] + return [ + youtube(id=self.arguments[0], aspect=aspect, width=width, height=height) + ] def unsupported_visit_youtube(self, node): - self.builder.warn('youtube: unsupported output format (node skipped)') + self.builder.warn("youtube: unsupported output format (node skipped)") raise nodes.SkipNode _NODE_VISITORS = { - 'html': (visit_youtube_node, depart_youtube_node), - 'latex': (visit_youtube_node_latex, depart_youtube_node), - 'man': (unsupported_visit_youtube, None), - 'texinfo': (unsupported_visit_youtube, None), - 'text': (unsupported_visit_youtube, None) + "html": (visit_youtube_node, depart_youtube_node), + "latex": (visit_youtube_node_latex, depart_youtube_node), + "man": (unsupported_visit_youtube, None), + "texinfo": (unsupported_visit_youtube, None), + "text": (unsupported_visit_youtube, None), } diff --git a/run_cookiecutter_example.py b/run_cookiecutter_example.py index b991e83..37816c6 100644 --- a/run_cookiecutter_example.py +++ b/run_cookiecutter_example.py @@ -1,34 +1,34 @@ #!/usr/bin/env python3 import pexpect -p = pexpect.spawn('cookiecutter .') +p = pexpect.spawn("cookiecutter .") -p.expect('full_name .*') -p.sendline('Brookhaven National Lab') +p.expect("full_name .*") +p.sendline("Brookhaven National Lab") -p.expect('email .*') -p.sendline('dallan@bnl.gov') +p.expect("email .*") +p.sendline("dallan@bnl.gov") -p.expect('github_username .*') -p.sendline('danielballan') +p.expect("github_username .*") +p.sendline("danielballan") -p.expect('project_name .*') -p.sendline('Example') +p.expect("project_name .*") +p.sendline("Example") -p.expect('package_dist_name .*') -p.sendline('') +p.expect("package_dist_name .*") +p.sendline("") -p.expect('package_dir_name .*') -p.sendline('') +p.expect("package_dir_name .*") +p.sendline("") -p.expect('repo_name .*') -p.sendline('') +p.expect("repo_name .*") +p.sendline("") -p.expect('project_short_description .*') -p.sendline('') +p.expect("project_short_description .*") +p.sendline("") -p.expect('Select minimum_supported_python_version.*') -p.sendline('') +p.expect("Select minimum_supported_python_version.*") +p.sendline("") # Runs until the cookiecutter is done; then exits. p.interact() diff --git a/{{ cookiecutter.repo_name }}/setup.py b/{{ cookiecutter.repo_name }}/setup.py index 00d4663..e7cf5af 100644 --- a/{{ cookiecutter.repo_name }}/setup.py +++ b/{{ cookiecutter.repo_name }}/setup.py @@ -1,16 +1,15 @@ import sys from os import path -from setuptools import find_packages, setup - import versioneer +from setuptools import find_packages, setup # NOTE: This file must remain Python 2 compatible for the foreseeable future, # to ensure that we error out properly for people with outdated setuptools # and/or pip. min_version = ( - {{ cookiecutter.minimum_supported_python_version[0] }}, - {{ cookiecutter.minimum_supported_python_version[2] }}, + {{cookiecutter.minimum_supported_python_version[0]}}, + {{cookiecutter.minimum_supported_python_version[2]}}, ) if sys.version_info < min_version: error = """ @@ -35,7 +34,11 @@ with open(path.join(here, "requirements.txt")) as requirements_file: # Parse requirements.txt, ignoring any commented-out lines. - requirements = [line for line in requirements_file.read().splitlines() if not line.startswith("#")] + requirements = [ + line + for line in requirements_file.read().splitlines() + if not line.startswith("#") + ] setup( diff --git a/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py b/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py index 15488a1..29026d6 100644 --- a/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py +++ b/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py @@ -131,7 +131,10 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): root = os.path.dirname(root) # up a level if verbose: - print("Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix)) + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) raise NotThisMethod("rootdir doesn't start with parentdir_prefix") @@ -319,7 +322,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): pieces["distance"] = int(count_out) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ + 0 + ].strip() pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces