Skip to content

Commit

Permalink
style with black
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Nov 11, 2019
1 parent 69bd58b commit 750bc0d
Show file tree
Hide file tree
Showing 13 changed files with 571 additions and 360 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ install:
script:
- cd Rmagic; R CMD build .
- R CMD check *tar.gz
- cd ../python; pip install --user -q .[test]
- cd ../python; if [ "$TRAVIS_PYTHON_VERSION" != "3.5" ]; then black . --check --diff; fi
- pip install --user -q .[test]
- python setup.py test
- pip install --user -q .[doc]
- cd doc; make html
- cd ..
- cd doc; make html; cd ..

deploy:
provider: pypi
Expand Down
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Contributing to MAGIC
============================

There are many ways to contribute to `MAGIC`, with the most common ones
being contribution of code or documentation to the project. Improving the
documentation is no less important than improving the library itself. If you
find a typo in the documentation, or have made improvements, do not hesitate to
submit a GitHub pull request.

But there are many other ways to help. In particular answering queries on the
[issue tracker](https://github.com/KrishnaswamyLab/MAGIC/issues),
investigating bugs, and [reviewing other developers' pull
requests](https://github.com/KrishnaswamyLab/MAGIC/pulls)
are very valuable contributions that decrease the burden on the project
maintainers.

Another way to contribute is to report issues you're facing, and give a "thumbs
up" on issues that others reported and that are relevant to you. It also helps
us if you spread the word: reference the project from your blog and articles,
link to it from your website, or simply star it in GitHub to say "I use it".

Code Style and Testing
----------------------

Contributors are encouraged to write tests for their code, but if you do not know how to do so, please do not feel discouraged from contributing code! Others can always help you test your contribution.

Python code style is dictated by [`black`](https://pypi.org/project/black/#installation-and-usage). To automatically reformat your code when you run `git commit`, you can run `./autoblack.sh` in the root directory of this project to add a hook to your `git` repository.

Code of Conduct
---------------

We abide by the principles of openness, respect, and consideration of others
of the Python Software Foundation: https://www.python.org/psf/codeofconduct/.

Attribution
---------------

This `CONTRIBUTING.md` was adapted from [scikit-learn](https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md).
14 changes: 14 additions & 0 deletions autoblack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cat <<EOF >> .git/hooks/pre-commit
#!/bin/sh
set -e
files=\$(git diff --staged --name-only --diff-filter=d -- "*.py")
for file in \$files; do
black -q \$file
git add \$file
done
EOF
chmod +x .git/hooks/pre-commit

74 changes: 40 additions & 34 deletions python/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#
import os
import sys
root_dir = os.path.abspath(os.path.join(os.path.dirname(
__file__), '..', '..'))

root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, root_dir)
# print(sys.path)

Expand All @@ -33,39 +33,40 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.viewcode']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['ytemplates']
templates_path = ["ytemplates"]

# 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 = 'MAGIC'
copyright = '2017 Krishnaswamy Lab, Yale University'
author = 'Scott Gigante and Daniel Dager, Krishnaswamy Lab, Yale University'
project = "MAGIC"
copyright = "2017 Krishnaswamy Lab, Yale University"
author = "Scott Gigante and Daniel Dager, Krishnaswamy Lab, Yale University"

# 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.
version_py = os.path.join(root_dir, 'magic', 'version.py')
version_py = os.path.join(root_dir, "magic", "version.py")
# The full version, including alpha/beta/rc tags.
release = open(version_py).read().strip().split(
'=')[-1].replace('"', '').strip()
release = open(version_py).read().strip().split("=")[-1].replace('"', "").strip()
# The short X.Y version.
version = release.split('-')[0]
version = release.split("-")[0]

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -80,7 +81,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
Expand All @@ -91,7 +92,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
html_theme = "default"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -102,13 +103,13 @@
# 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 = ['ystatic']
html_static_path = ["ystatic"]


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

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


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -117,15 +118,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 @@ -135,19 +133,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'MAGIC.tex', 'MAGIC Documentation',
'Scott Gigante and Daniel Dager, Krishnaswamy Lab, Yale University', 'manual'),
(
master_doc,
"MAGIC.tex",
"MAGIC Documentation",
"Scott Gigante and Daniel Dager, Krishnaswamy Lab, Yale University",
"manual",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'magic', 'MAGIC Documentation',
[author], 1)
]
man_pages = [(master_doc, "magic", "MAGIC Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -156,7 +156,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'MAGIC', 'MAGIC Documentation',
author, 'MAGIC', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"MAGIC",
"MAGIC Documentation",
author,
"MAGIC",
"One line description of project.",
"Miscellaneous",
),
]

0 comments on commit 750bc0d

Please sign in to comment.