Skip to content

Commit

Permalink
Merge pull request #57 from ModECI/development
Browse files Browse the repository at this point in the history
Mainly contribs from Outreachy May-Aug 2023
  • Loading branch information
pgleeson authored Aug 23, 2023
2 parents 40185ef + d3aa38b commit 67382cb
Show file tree
Hide file tree
Showing 49 changed files with 2,461 additions and 42 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ jobs:
extra_args: --hook-stage manual --all-files

build:

runs-on: ubuntu-latest
name: Build for Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: [ "3.7", "3.8", "3.9", "3.10"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -54,6 +55,17 @@ jobs:
cd test
python test.py
## Test NeuroML example
cd ../neuroml2
python neuroml2_spec.py
pip install pyneuroml
# Requires: pip install pyneuroml
pynml -validate hello_world_neuroml.net.nml
pynml -validate TestNeuroML.xml
- name: Run pytest
run: |
pytest tests
Expand All @@ -76,6 +88,17 @@ jobs:
cd examples/MDF
python arrays.py -run # test one example
- name: Build Documentation
run: |
pip install .[docs]
cd docs
python generate.py
python contributors.py
cd sphinx
make clean
make html
- name: Final version info
run: |
pip list
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/sphinx/source/api/_autosummary

# PyBuilder
.pybuilder/
Expand Down Expand Up @@ -161,3 +162,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
/examples/document.specification.bson
/examples/neuroml2/hello_world.v.dat
66 changes: 66 additions & 0 deletions docs/contributors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import requests
import pandas as pd
import json
import textwrap
from datetime import date


url = "https://api.github.com/repos/modeci/modelspec/contributors"

response = requests.get(url=url, auth=("<github_username>", "<github_token>"))

json_data = response.json()

df = pd.DataFrame(json_data)

per_info = list(df["url"].unique())
len_per_info = len(per_info)

empty_list = []
for i in range(len_per_info):
url = per_info[i]
print(url)
data = requests.get(url=url)
requests_status = "unknown"
while (requests_status == "unknown") or (requests_status == "unsuccessful"):
if data.status_code == 200:
requests_status = "successful"
empty_list.append(data.json())
else:
# handle failure on requests to the url for mac os
requests_status = "unsuccessful"
print(f"Failed to get data from: {url}")
# make request again to get data from the url
data = requests.get(url=url)

df1 = pd.DataFrame(empty_list)
df1["name"] = df1["name"].fillna("")
name = df1["name"]
login = df1["login"]
url_html = df1["html_url"]
url_id = df1["id"]

login_html = list(zip(name, login, url_html))
zip_dict = dict(zip(url_id, login_html))

file = "sphinx/source/api/Contributors.md"
with open(file, "w") as f:
print(
textwrap.dedent(
"""\
(Modelspec:contributors)=
# Modelspec contributors
This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
This page is generated periodically, most recently on {}.""".format(
date.today()
)
),
file=f,
)

print("", file=f)

for key, val in zip_dict.items():
print("- {} ([@{}]({}))".format(val[0], val[1], val[2]), file=f)
10 changes: 10 additions & 0 deletions docs/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import shutil
import os

shutil.copy("../README.md", "sphinx/source/api/Introduction.md")

for file_ in os.listdir("../examples"):
if ("document" in file_) or ("README" in file_):
shutil.copy(
"../examples/%s" % file_, os.path.join("sphinx/source/api/examples", file_)
)
20 changes: 20 additions & 0 deletions docs/sphinx/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
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

# 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)
35 changes: 35 additions & 0 deletions docs/sphinx/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
10 changes: 10 additions & 0 deletions docs/sphinx/source/_static/pydata-custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*Tweaks to the Pydata default CSS */

/*No yellow background highlight when targeted by summary tables */
/*dt:target { background-color: #f8f8f8; border: 1px solid black, }*/
dt:target { background: transparent;}
/*More space between H1s and signatures in API reference*/
h1 { margin-bottom: 40px; }

/*No line underneath summary table headings (clashes with line above first member)*/
p.rubric { border-bottom: 0px; }
35 changes: 35 additions & 0 deletions docs/sphinx/source/_static/rtd-custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Override nav bar color */
/*.wy-side-nav-search {
background-color: #fbfbb6;
}
.wy-side-nav-search > a {
color: #b2355c
}*/

/* Override text bar color */
/*.caption-text {
color: #b2355c;
}*/

/* Override code signature colour */
/*.rst-content dl:not(.docutils) dt {
background: #fbfbb6;
color: #b2355c;
border-top: solid 3px #b2355c;
}*/

/* Override hyperlink colour */
/* a {
color: #b2355c;
}*/

/* Make content width wider*/
.wy-nav-content {
max-width: 75% !important;
}

/* Word-wrap tables */
.wy-table-responsive table td,
.wy-table-responsive table th {
white-space: normal;
}
23 changes: 23 additions & 0 deletions docs/sphinx/source/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:special-members: __call__, __add__, __mul__

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
{%- if not item.startswith('_') %}
{%- if item not in inherited_members %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}
67 changes: 67 additions & 0 deletions docs/sphinx/source/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}

{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
{% for item in functions %}
{%- if not item.startswith('_') %}
{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: custom-class-template.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. autosummary::
:toctree:
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
11 changes: 11 additions & 0 deletions docs/sphinx/source/api/Contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(Modelspec:contributors)=

# Modelspec contributors

This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
This page is generated periodically, most recently on 2023-07-05.

- Padraig Gleeson ([@pgleeson](https://github.com/pgleeson))
- David Turner ([@davidt0x](https://github.com/davidt0x))
- Parikshit Singh Rathore ([@parikshit14](https://github.com/parikshit14))
- Katherine Mantel ([@kmantel](https://github.com/kmantel))
Loading

0 comments on commit 67382cb

Please sign in to comment.