Skip to content

Commit 67382cb

Browse files
authored
Merge pull request #57 from ModECI/development
Mainly contribs from Outreachy May-Aug 2023
2 parents 40185ef + d3aa38b commit 67382cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2461
-42
lines changed

.github/workflows/ci.yml

+26-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919
extra_args: --hook-stage manual --all-files
2020

2121
build:
22-
23-
runs-on: ubuntu-latest
22+
name: Build for Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
23+
runs-on: ${{ matrix.runs-on }}
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python-version: ["3.7", "3.8", "3.9", "3.10"]
27+
python-version: [ "3.7", "3.8", "3.9", "3.10"]
28+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
2829

2930
steps:
3031
- uses: actions/checkout@v2
@@ -54,6 +55,17 @@ jobs:
5455
cd test
5556
python test.py
5657
58+
## Test NeuroML example
59+
60+
cd ../neuroml2
61+
python neuroml2_spec.py
62+
63+
pip install pyneuroml
64+
65+
# Requires: pip install pyneuroml
66+
pynml -validate hello_world_neuroml.net.nml
67+
pynml -validate TestNeuroML.xml
68+
5769
- name: Run pytest
5870
run: |
5971
pytest tests
@@ -76,6 +88,17 @@ jobs:
7688
cd examples/MDF
7789
python arrays.py -run # test one example
7890
91+
- name: Build Documentation
92+
run: |
93+
94+
pip install .[docs]
95+
cd docs
96+
python generate.py
97+
python contributors.py
98+
cd sphinx
99+
make clean
100+
make html
101+
79102
- name: Final version info
80103
run: |
81104
pip list

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ instance/
8080

8181
# Sphinx documentation
8282
docs/_build/
83+
docs/sphinx/source/api/_autosummary
8384

8485
# PyBuilder
8586
.pybuilder/
@@ -161,3 +162,4 @@ cython_debug/
161162
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162163
.idea/
163164
/examples/document.specification.bson
165+
/examples/neuroml2/hello_world.v.dat

docs/contributors.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import requests
2+
import pandas as pd
3+
import json
4+
import textwrap
5+
from datetime import date
6+
7+
8+
url = "https://api.github.com/repos/modeci/modelspec/contributors"
9+
10+
response = requests.get(url=url, auth=("<github_username>", "<github_token>"))
11+
12+
json_data = response.json()
13+
14+
df = pd.DataFrame(json_data)
15+
16+
per_info = list(df["url"].unique())
17+
len_per_info = len(per_info)
18+
19+
empty_list = []
20+
for i in range(len_per_info):
21+
url = per_info[i]
22+
print(url)
23+
data = requests.get(url=url)
24+
requests_status = "unknown"
25+
while (requests_status == "unknown") or (requests_status == "unsuccessful"):
26+
if data.status_code == 200:
27+
requests_status = "successful"
28+
empty_list.append(data.json())
29+
else:
30+
# handle failure on requests to the url for mac os
31+
requests_status = "unsuccessful"
32+
print(f"Failed to get data from: {url}")
33+
# make request again to get data from the url
34+
data = requests.get(url=url)
35+
36+
df1 = pd.DataFrame(empty_list)
37+
df1["name"] = df1["name"].fillna("")
38+
name = df1["name"]
39+
login = df1["login"]
40+
url_html = df1["html_url"]
41+
url_id = df1["id"]
42+
43+
login_html = list(zip(name, login, url_html))
44+
zip_dict = dict(zip(url_id, login_html))
45+
46+
file = "sphinx/source/api/Contributors.md"
47+
with open(file, "w") as f:
48+
print(
49+
textwrap.dedent(
50+
"""\
51+
(Modelspec:contributors)=
52+
53+
# Modelspec contributors
54+
55+
This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
56+
This page is generated periodically, most recently on {}.""".format(
57+
date.today()
58+
)
59+
),
60+
file=f,
61+
)
62+
63+
print("", file=f)
64+
65+
for key, val in zip_dict.items():
66+
print("- {} ([@{}]({}))".format(val[0], val[1], val[2]), file=f)

docs/generate.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import shutil
2+
import os
3+
4+
shutil.copy("../README.md", "sphinx/source/api/Introduction.md")
5+
6+
for file_ in os.listdir("../examples"):
7+
if ("document" in file_) or ("README" in file_):
8+
shutil.copy(
9+
"../examples/%s" % file_, os.path.join("sphinx/source/api/examples", file_)
10+
)

docs/sphinx/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/sphinx/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*Tweaks to the Pydata default CSS */
2+
3+
/*No yellow background highlight when targeted by summary tables */
4+
/*dt:target { background-color: #f8f8f8; border: 1px solid black, }*/
5+
dt:target { background: transparent;}
6+
/*More space between H1s and signatures in API reference*/
7+
h1 { margin-bottom: 40px; }
8+
9+
/*No line underneath summary table headings (clashes with line above first member)*/
10+
p.rubric { border-bottom: 0px; }
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Override nav bar color */
2+
/*.wy-side-nav-search {
3+
background-color: #fbfbb6;
4+
}
5+
.wy-side-nav-search > a {
6+
color: #b2355c
7+
}*/
8+
9+
/* Override text bar color */
10+
/*.caption-text {
11+
color: #b2355c;
12+
}*/
13+
14+
/* Override code signature colour */
15+
/*.rst-content dl:not(.docutils) dt {
16+
background: #fbfbb6;
17+
color: #b2355c;
18+
border-top: solid 3px #b2355c;
19+
}*/
20+
21+
/* Override hyperlink colour */
22+
/* a {
23+
color: #b2355c;
24+
}*/
25+
26+
/* Make content width wider*/
27+
.wy-nav-content {
28+
max-width: 75% !important;
29+
}
30+
31+
/* Word-wrap tables */
32+
.wy-table-responsive table td,
33+
.wy-table-responsive table th {
34+
white-space: normal;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members:
7+
:show-inheritance:
8+
:special-members: __call__, __add__, __mul__
9+
10+
{% block methods %}
11+
{% if methods %}
12+
.. rubric:: {{ _('Methods') }}
13+
14+
.. autosummary::
15+
{% for item in methods %}
16+
{%- if not item.startswith('_') %}
17+
{%- if item not in inherited_members %}
18+
~{{ name }}.{{ item }}
19+
{%- endif -%}
20+
{%- endif -%}
21+
{%- endfor %}
22+
{% endif %}
23+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block attributes %}
6+
{% if attributes %}
7+
.. rubric:: Module attributes
8+
9+
.. autosummary::
10+
:toctree:
11+
{% for item in attributes %}
12+
{{ item }}
13+
{%- endfor %}
14+
{% endif %}
15+
{% endblock %}
16+
17+
{% block functions %}
18+
19+
{% if functions %}
20+
.. rubric:: {{ _('Functions') }}
21+
22+
.. autosummary::
23+
:toctree:
24+
{% for item in functions %}
25+
{%- if not item.startswith('_') %}
26+
{{ item }}
27+
{% endif %}
28+
{%- endfor %}
29+
{% endif %}
30+
{% endblock %}
31+
32+
{% block classes %}
33+
{% if classes %}
34+
.. rubric:: {{ _('Classes') }}
35+
36+
.. autosummary::
37+
:toctree:
38+
:template: custom-class-template.rst
39+
{% for item in classes %}
40+
{{ item }}
41+
{%- endfor %}
42+
{% endif %}
43+
{% endblock %}
44+
45+
{% block exceptions %}
46+
{% if exceptions %}
47+
.. rubric:: {{ _('Exceptions') }}
48+
49+
.. autosummary::
50+
:toctree:
51+
{% for item in exceptions %}
52+
{{ item }}
53+
{%- endfor %}
54+
{% endif %}
55+
{% endblock %}
56+
57+
{% block modules %}
58+
{% if modules %}
59+
.. autosummary::
60+
:toctree:
61+
:template: custom-module-template.rst
62+
:recursive:
63+
{% for item in modules %}
64+
{{ item }}
65+
{%- endfor %}
66+
{% endif %}
67+
{% endblock %}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(Modelspec:contributors)=
2+
3+
# Modelspec contributors
4+
5+
This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
6+
This page is generated periodically, most recently on 2023-07-05.
7+
8+
- Padraig Gleeson ([@pgleeson](https://github.com/pgleeson))
9+
- David Turner ([@davidt0x](https://github.com/davidt0x))
10+
- Parikshit Singh Rathore ([@parikshit14](https://github.com/parikshit14))
11+
- Katherine Mantel ([@kmantel](https://github.com/kmantel))

0 commit comments

Comments
 (0)