Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF,ENH] Makes phys2bids a Python package #20

Merged
merged 23 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
phys2bids/_version.py export-subst
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ dmypy.json
# Pyre type checker
.pyre/

.vscode/
79 changes: 79 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
language: python
sudo: false
dist: xenial
services:
- xvfb
notifications:
email: change

python:
- 3.6
- 3.7

env:
matrix:
- CHECK_TYPE=linting
- CHECK_TYPE=docdoctest
- CHECK_TYPE=test
global:
- INSTALL_TYPE=setup

matrix:
include:
- python: 3.6
env:
- INSTALL_TYPE=sdist
- CHECK_TYPE=test
- python: 3.6
env:
- INSTALL_TYPE=wheel
- CHECK_TYPE=test

before_install:
- python -m pip install --upgrade pip
- if [ "${CHECK_TYPE}" == "linting" ]; then
pip install flake8;
fi
- if [ "${CHECK_TYPE}" == "test" ]; then
pip install "pytest>=3.6" pytest-cov coverage coveralls codecov;
fi
- if [ "${CHECK_TYPE}" == "docdoctest" ]; then
pip install "sphinx>2.0" sphinx_rtd_theme pandas sphinx-argparse;
fi

install:
- |
if [ "${INSTALL_TYPE}" == "setup" ]; then
python setup.py install;
elif [ "${INSTALL_TYPE}" == "sdist" ]; then
python setup.py sdist;
pip install dist/*.tar.gz;
elif [ "${INSTALL_TYPE}" == "wheel" ]; then
python setup.py bdist_wheel;
pip install dist/*.whl;
else
false;
fi

script:
- |
if [ "${CHECK_TYPE}" == "linting" ]; then
flake8 phys2bids;
elif [ "${CHECK_TYPE}" == "docdoctest" ]; then
cd docs;
pip install -r ./requirements.txt;
make html;
make doctest;
elif [ "${CHECK_TYPE}" == "test" ]; then
mkdir for_testing && cd for_testing;
cp ../setup.cfg ./;
args="--doctest-modules --cov-report term-missing --cov=phys2bids --pyargs"
python -m pytest ${args} phys2bids;
else
false;
fi

after_success:
- if [ "${CHECK_TYPE}" == "test" ]; then
coveralls; codecov;
fi
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include README.* LICENSE setup* MANIFEST.in requirements.txt
recursive-include phys2bids/data *
recursive-include phys2bids/heuristics *
recursive-include phys2bids/tests/data *

include versioneer.py
include phys2bids/_version.py
26 changes: 26 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = phys2bids
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# For getting rid of generated docs before re-building
clean:
rm -rf $(BUILDDIR)/* auto_examples/ generated/

.PHONY: clean

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 changes: 17 additions & 0 deletions docs/_static/theme_overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* override table width restrictions */
@media screen and (min-width: 767px) {

.wy-table-responsive table td {
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}

.wy-table-responsive {
overflow: visible !important;
}
}

.headerlink::after {
font-size: 0px;
}
12 changes: 12 additions & 0 deletions docs/_templates/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ fullname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:no-members:
:no-inherited-members:

.. raw:: html

<div style='clear:both'></div>
12 changes: 12 additions & 0 deletions docs/_templates/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ fullname }}
{{ underline }}

.. currentmodule:: {{ module }}

.. autofunction:: {{ objname }}

.. .. include:: modules/{{ module }}.{{ objname }}.examples

.. raw:: html

<div style='clear:both'></div>
18 changes: 18 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _cli:

------------------
Command-line usage
------------------

You can uinvoke the primary workflow of ``phys2bids`` from the command line.
rmarkello marked this conversation as resolved.
Show resolved Hide resolved

.. _cli_phys2bids:

The ``phys2bids`` command
=========================

.. argparse::
:ref: phys2bids.cli.run._get_parser
:prog: phys2bids
:nodefault:
rmarkello marked this conversation as resolved.
Show resolved Hide resolved
:nodefaultconst:
rmarkello marked this conversation as resolved.
Show resolved Hide resolved
114 changes: 114 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
from datetime import datetime
import os
import sys


# -- Project information -----------------------------------------------------

# Add project name, copyright holder, and author(s)
project = 'phys2bids'
author = '{} developers'.format(project)
copyright = '2019-{}, {}'.format(datetime.now().year, author)

# Import project to get version info
sys.path.insert(0, os.path.abspath(os.path.pardir))
import phys2bids # noqa
# The short X.Y version
version = phys2bids.__version__
# The full version, including alpha/beta/rc tags
release = phys2bids.__version__


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'matplotlib.sphinxext.plot_directive',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinxarg.ext',
]

# Generate the API documentation when building
autosummary_generate = True
autodoc_default_options = {'members': True, 'inherited-members': True}
numpydoc_show_class_members = False
autoclass_content = "class"

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

# The suffix(es) of source filenames.
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# 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 = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
import sphinx_rtd_theme # noqa
html_theme = 'sphinx_rtd_theme'
html_show_sourcelink = False

# 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
# documentation.
html_theme_options = {}

# 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']

# https://github.com/rtfd/sphinx_rtd_theme/issues/117
def setup(app): # noqa
app.add_stylesheet('theme_overrides.css')


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

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


# -- Extension configuration -------------------------------------------------
intersphinx_mapping = {
'python': ('https://docs.python.org/3.6', None),
'matplotlib': ('https://matplotlib.org', None),
'numpy': ('https://docs.scipy.org/doc/numpy', None),
'pandas': ('https://pandas-docs.github.io/pandas-docs-travis/', None),
}
11 changes: 11 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=========
phys2bids
=========

Contents
--------

.. toctree::
:maxdepth: 1

cli
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r ../requirements.txt
sphinx>=2.0
sphinx-argparse
sphinx_rtd_theme
4 changes: 4 additions & 0 deletions phys2bids/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
Loading