Skip to content

Commit 7866cde

Browse files
author
LegrandNico
committed
[docs] : First step for autogenerated documentation.
[CI] : Add flake8 linting.
1 parent 64256d7 commit 7866cde

22 files changed

+9359
-16
lines changed

.github/workflows/docs.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- master
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout 🛎️
18+
uses: actions/checkout@v3
19+
20+
- name: Set up Python 3.9
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: 3.9
24+
25+
- name: Build
26+
run: |
27+
pip install .
28+
pip install -r requirements-docs.txt
29+
sphinx-build -b html docs docs/build/html
30+
31+
- name: Deploy 🚀
32+
uses: JamesIves/github-pages-deploy-action@v4
33+
with:
34+
folder: source/build/html
35+
BRANCH: gh-pages

.github/workflows/linting.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ jobs:
3030
mypy ./cardioception/ --ignore-missing-imports
3131
black ./cardioception/
3232
isort ./cardioception/
33+
flake8 ./cardioception/

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[settings]
2-
known_third_party = numpy,pandas,papermill,pkg_resources,psychopy,serial,systole
2+
known_third_party = numpy,pandas,papermill,pkg_resources,psychopy,serial,sphinx_bootstrap_theme,systole
33
multi_line_output = 3
44
include_trailing_comma = True
55
force_grid_wrap = 0

.pre-commit-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
repos:
2-
- repo: https://github.com/asottile/seed-isort-config
3-
rev: v2.2.0
4-
hooks:
5-
- id: seed-isort-config
62
- repo: https://github.com/pre-commit/mirrors-isort
73
rev: v5.10.1
84
hooks:
95
- id: isort
10-
exclude: tests/
6+
files: ^cardioception/
117
- repo: https://github.com/ambv/black
128
rev: 22.6.0
139
hooks:
1410
- id: black
1511
language_version: python3
12+
files: ^cardioception/
13+
- repo: https://github.com/pycqa/flake8
14+
rev: 5.0.4
15+
hooks:
16+
- id: flake8
17+
files: ^cardioception/
18+
args: [--extend-ignore=E501]
1619
- repo: https://github.com/pre-commit/mirrors-mypy
1720
rev: 'v0.971'
1821
hooks:
19-
- id: mypy
22+
- id: mypy
23+
files: ^cardioception/
2024
args: [--ignore-missing-imports, --follow-imports=skip]

cardioception/HBC/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
from .parameters import *
2-
from .task import *
1+
from .parameters import getParameters
2+
from .task import rest, run, trial, tutorial
3+
4+
__all__ = ["getParameters", "run", "trial", "tutorial", "rest"]

cardioception/HBC/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66
import pandas as pd
7-
from psychopy import core, event, sound, visual
7+
from psychopy import core, event, visual
88

99

1010
def run(

cardioception/HRD/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
from .parameters import *
2-
from .task import *
1+
from .parameters import getParameters
2+
from .task import (
3+
confidenceRatingTask,
4+
responseDecision,
5+
run,
6+
trial,
7+
tutorial,
8+
waitInput,
9+
)
10+
11+
__all__ = [
12+
"getParameters",
13+
"confidenceRatingTask",
14+
"responseDecision",
15+
"run",
16+
"trial",
17+
"tutorial",
18+
"waitInput",
19+
]

cardioception/HRD/task.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pkg_resources # type: ignore
1010
from psychopy import core, event, sound, visual
1111
from systole.detection import ppg_peaks
12-
from systole.recording import BrainVisionExG
1312

1413

1514
def run(
@@ -435,7 +434,9 @@ def trial(
435434
# You can adapt these line to work with a different setup provided that
436435
# it can measure and create the new variable `bpm` (the average beats per
437436
# minute over the 5 seconds of recording).
438-
signal = parameters["oxiTask"].read(duration=5.0).recording[-75 * 6 :]
437+
signal = (
438+
parameters["oxiTask"].read(duration=5.0).recording[-75 * 6 :] # noqa
439+
)
439440
signal, peaks = ppg_peaks(signal, sfreq=75, new_sfreq=1000, clipping=True)
440441

441442
# Get actual heart Rate

cardioception/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import TYPE_CHECKING
22

33
if not TYPE_CHECKING:
4-
from .HBC import *
5-
from .HRD import *
4+
from .HBC import * # noqa
5+
from .HRD import * # noqa

docs/conf.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# http://www.sphinx-doc.org/en/master/config
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import time
14+
15+
import sphinx_bootstrap_theme
16+
17+
import cardioception
18+
19+
# -- Project information -----------------------------------------------------
20+
21+
project = "cardioception"
22+
copyright = "2022-{}, Nicolas Legrand".format(time.strftime("%Y"))
23+
author = "Nicolas Legrand"
24+
release = cardioception.__version__
25+
26+
27+
image_scrapers = ("matplotlib",)
28+
29+
sphinx_gallery_conf = {
30+
"examples_dirs": "../examples/",
31+
"backreferences_dir": "api",
32+
"image_scrapers": image_scrapers,
33+
}
34+
35+
# -- General configuration ---------------------------------------------------
36+
37+
# Add any Sphinx extension module names here, as strings. They can be
38+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39+
# ones.
40+
extensions = [
41+
"sphinx.ext.mathjax",
42+
"sphinx.ext.doctest",
43+
"sphinx.ext.viewcode",
44+
"sphinx.ext.githubpages",
45+
"sphinx.ext.autosummary",
46+
"sphinx.ext.autodoc",
47+
"sphinx.ext.intersphinx",
48+
"sphinx_gallery.gen_gallery",
49+
"matplotlib.sphinxext.plot_directive",
50+
"numpydoc",
51+
"jupyter_sphinx",
52+
"sphinx_panels",
53+
"myst_nb",
54+
"sphinx_gallery.load_style",
55+
]
56+
57+
panels_add_bootstrap_css = False
58+
59+
# Generate the API documentation when building
60+
autosummary_generate = True
61+
numpydoc_show_class_members = False
62+
63+
# Include the example source for plots in API docs
64+
plot_include_source = True
65+
plot_formats = [("png", 90)]
66+
plot_html_show_formats = False
67+
plot_html_show_source_link = False
68+
69+
source_suffix = [".rst", ".md"]
70+
71+
# The master toctree document.
72+
master_doc = "index"
73+
74+
# Add any paths that contain templates here, relative to this directory.
75+
templates_path = ["_templates"]
76+
77+
# List of patterns, relative to source directory, that match files and
78+
# directories to ignore when looking for source files.
79+
# This pattern also affects html_static_path and html_extra_path.
80+
exclude_patterns = []
81+
82+
# -- Options for HTML output -------------------------------------------------
83+
84+
# The theme to use for HTML and HTML Help pages. See the documentation for
85+
# a list of builtin themes.
86+
87+
html_theme = "pydata_sphinx_theme"
88+
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
89+
html_theme_options = {
90+
"icon_links": [
91+
dict(
92+
name="GitHub",
93+
url="https://github.com/embodied-computation-group/Cardioception",
94+
icon="fab fa-github-square",
95+
),
96+
dict(
97+
name="Twitter",
98+
url="https://twitter.com/visceral_mind",
99+
icon="fab fa-twitter-square",
100+
),
101+
dict(
102+
name="Pypi",
103+
url="https://pypi.org/project/Cardioception/",
104+
icon="fas fa-box",
105+
),
106+
],
107+
"logo_link": "https://embodied-computation-group.github.io/Carcioception/#",
108+
}
109+
110+
html_sidebars = {"api": [], "changelog": [], "notebooks/*": []}
111+
112+
# Add any paths that contain custom static files (such as style sheets) here,
113+
# relative to this directory. They are copied after the builtin static files,
114+
# so a file named "default.css" will overwrite the builtin "default.css".
115+
html_static_path = ["_static"]
116+
html_css_files = [
117+
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
118+
]
119+
html_logo = "images/logo.png"
120+
121+
122+
def setup(app):
123+
app.add_css_file("style.css")
124+
125+
126+
# -- Intersphinx ------------------------------------------------
127+
128+
intersphinx_mapping = {
129+
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
130+
"scipy": ("http://docs.scipy.org/doc/scipy/reference/", None),
131+
"matplotlib": ("http://matplotlib.org/", None),
132+
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
133+
"seaborn": ("https://seaborn.pydata.org/", None),
134+
"psychopy": ("https://psychopy.org/index.html", None),
135+
}

docs/images/AU.png

95.1 KB
Loading

docs/images/HeartBeatCounting.png

211 KB
Loading

0 commit comments

Comments
 (0)