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

Add autogenerated docs #18

Merged
merged 13 commits into from
Oct 11, 2024
Merged
26 changes: 26 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy docs
on: [push, pull_request]
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Download source
uses: actions/checkout@v3
- name: Install Crystal
uses: oprypin/install-crystal@v1
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Python libs
run: pip install .
- name: Install Crystal libs
run: |
shards init
shards install
- name: Build site
run: mkdocs build
- name: Deploy to gh-pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Analysis of neuroelectrophysiology data in Python.

Overview
========
neuro_py is a Python package for analysis of neuroelectrophysiology data. It is built on top of the [nelpy](https://github.com/nelpy/nelpy) package, which provides core data objects. neuro_py provides a set of functions for analysis of freely moving electrophysisology, including behavior tracking utilities, neural ensemble detection, peri-event analyses, robust batch analysis tools, and more.
neuro_py is a Python package for analysis of neuroelectrophysiology data. It is built on top of the [nelpy](https://github.com/nelpy/nelpy) package, which provides core data objects. neuro_py provides a set of functions for analysis of freely moving electrophysiology, including behavior tracking utilities, neural ensemble detection, peri-event analyses, robust batch analysis tools, and more.

Tutorials are [here](https://github.com/ryanharvey1/neuro_py/tree/master/tutorials) and more will be added.

Expand Down
9 changes: 0 additions & 9 deletions docs/README.md

This file was deleted.

40 changes: 40 additions & 0 deletions docs/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Generate the code reference pages."""
from pathlib import Path

import mkdocs_gen_files


nav = mkdocs_gen_files.Nav()
mod_symbol = ''

root = Path(__file__).parent.parent
src = root

for path in sorted(src.rglob("*.py")):
if path.relative_to(src).parts[0] != "neuro_py":
continue
module_path = path.relative_to(src).with_suffix("")
doc_path = path.relative_to(src).with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = tuple(module_path.parts)

if parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")
elif parts[-1] == "__main__":
continue

nav_parts = [f"{mod_symbol} {part}" for part in parts]
print(nav_parts)
nav[tuple(nav_parts)[-2:]] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
identifier = ".".join(parts)
print(f"---\ntitle: {identifier}\n---\n\n::: {identifier}", file=fd)

mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root))

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# neuro-py
36 changes: 36 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
:root {
--md-code-font: "Roboto Mono";
--md-default-fg-color: #111;
--md-default-fg-color--light: #000000d0;
--md-default-fg-color--lighter: #00000052;
--md-default-fg-color--lightest: #00000012;
--md-accent-fg-color: #38195A;
--md-accent-fg-color--hover: #E4AF68;
--md-accent-fg-color--transparent: #38195a1a;

--md-default-bg-color: #fff;
--md-default-bg-color--light: #ffffffb3;
--md-default-bg-color--lighter: #ffffff4d;
--md-default-bg-color--lightest: #ffffff1f;
--md-accent-bg-color: #fff;
--md-accent-bg-color--light: #ffffffb3;
}

[data-md-color-scheme="slate"] {
--md-hue: 210;
}

/* Indentation for API Reference. */
.md-content div.doc-contents:not(.first) {
padding-left: 25px;
border-left: .05rem solid var(--md-typeset-table-color);
}

/* Gradient banner */
.md-header {
background: linear-gradient(145deg, rgba(229,119,39,1) 3%, rgba(144,3,12,1) 31%, rgba(133,59,96,1) 51%, rgba(31,67,103,1) 79%, rgba(31,99,120,1) 94%, rgba(32,135,139,1) 100%);
}

.md-tabs {
background: none;
}
73 changes: 73 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
site_name: "neuro_py"
repo_name: ryanharvey1/neuro_py
repo_url: https://github.com/ryanharvey1/neuro_py
edit_uri: edit/main/docs/

extra_css:
- stylesheets/extra.css

theme:
name: "material"
font:
text: Roboto
code: Roboto Mono
palette:
- media: "(prefers-color-scheme: dark)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: light
primary: custom
accent: custom
toggle:
icon: material/weather-sunny
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: blue
toggle:
icon: material/weather-night
name: Switch to system preference
features:
- announce.dismiss
- content.action.edit
- content.action.view
- content.code.annotate
- content.code.copy
- content.tooltips
- content.tabs.link
- navigation.footer
- navigation.indexes
- navigation.instant.prefetch
- navigation.instant.preview
- navigation.instant.progress
- navigation.path
- navigation.sections
- navigation.tabs
- navigation.tabs.sticky
- navigation.top
- navigation.tracking
- search.highlight
- search.suggest
- toc.follow

plugins:
- search
- gen-files:
scripts:
- docs/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
- section-index
- mkdocstrings:
handlers:
python:
options:
docstring_style: numpy


nav:
- Home: index.md
- API Reference: reference/
4 changes: 0 additions & 4 deletions neuro_py/behavior/cheeseboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ def plot_grid_with_circle_and_random_dots():
plt.gca().set_aspect("equal", adjustable="box")
plt.axis("off")
plt.show()


if __name__ == "__main__":
plot_grid_with_circle_and_random_dots()
Loading
Loading