Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion doc/_static/js/contrib-avatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function putAvatarsInPage() {
}
// finish
outer.append(title, inner);
document.getElementById("institution-logos").after(outer);
document.body.append(outer);
}

putAvatarsInPage();
2 changes: 2 additions & 0 deletions doc/_templates/homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
</div>
{% endfor %}
</div>
<!-- contributors -->
{% include 'avatars.html' %}
</div>
3 changes: 0 additions & 3 deletions doc/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
{%- block scripts_end %}
{{ super() }}
<script src="https://mne.tools/versionwarning.js"></script>
{% if pagename == 'index' %}
<script src="{{ pathto('_static/js/contrib-avatars.js', 1) }}"></script>
{% endif %}
{%- endblock %}
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"sphinxcontrib.bibtex",
"sphinxcontrib.youtube",
# homegrown
"contrib_avatars",
"gen_commands",
"gen_names",
"gh_substitutions",
Expand Down
7 changes: 7 additions & 0 deletions doc/sphinxext/_avatar_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
<script src="../_static/js/contrib-avatars.js"></script>
</head>
<body>
</body>
</html>
34 changes: 34 additions & 0 deletions doc/sphinxext/contrib_avatars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pathlib import Path

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException


def generate_contrib_avatars(app, config):
"""Render a template webpage with avatars generated by JS and a GitHub API call."""
root = Path(app.srcdir)
infile = root / "sphinxext" / "_avatar_template.html"
outfile = root / "_templates" / "avatars.html"
try:
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
except WebDriverException:
options = webdriver.FirefoxOptions()
options.add_argument("--headless=new")
driver = webdriver.Firefox(options=options)
driver.get(f"file://{infile}")
wait = WebDriverWait(driver, 20)
wait.until(lambda d: d.find_element(by=By.ID, value="contributor-avatars"))
body = driver.find_element(by=By.TAG_NAME, value="body").get_attribute("innerHTML")
with open(outfile, "w") as fid:
fid.write(body)
driver.quit()


def setup(app):
"""Set up the Sphinx app."""
app.connect("config-inited", generate_contrib_avatars)
return
1 change: 1 addition & 0 deletions requirements_doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pytest
graphviz
pyzmq!=24.0.0
ipython!=8.7.0
selenium
2 changes: 2 additions & 0 deletions tools/circleci_bash_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -o pipefail

./tools/setup_xvfb.sh
sudo apt install -qq graphviz optipng python3.10-venv python3-venv libxft2 ffmpeg
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
python3.10 -m venv ~/python_env
echo "set -e" >> $BASH_ENV
echo "set -o pipefail" >> $BASH_ENV
Expand Down