Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jun 19, 2024
1 parent 7bbbc9d commit 73e79a5
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 85 deletions.
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

105 changes: 59 additions & 46 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------
Expand All @@ -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:
Expand All @@ -56,45 +57,45 @@
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.
# This patterns also effect to html_static_path and html_extra_path
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
Expand All @@ -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
Expand All @@ -118,25 +120,25 @@
# 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.
#
# 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",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'ScientificPythonCookiecutterdoc'
htmlhelp_basename = "ScientificPythonCookiecutterdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -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',
Expand All @@ -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",
),
]


Expand All @@ -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,
)
]


Expand All @@ -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),
}
4 changes: 3 additions & 1 deletion doc/source/test_examples.py
Original file line number Diff line number Diff line change
@@ -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.)

Expand All @@ -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)
35 changes: 24 additions & 11 deletions doc/source/vendor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -75,11 +81,16 @@ def visit_youtube_node(self, node):
self.body.append(self.starttag(node, "iframe", **attrs))
self.body.append("</iframe>")


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):
Expand All @@ -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),
}


Expand Down
38 changes: 19 additions & 19 deletions run_cookiecutter_example.py
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 73e79a5

Please sign in to comment.