-
Notifications
You must be signed in to change notification settings - Fork 7
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
Revamp the software section #19
Changes from 8 commits
af727ea
a84b52c
4a837ba
2f6bd49
de4cada
ef311af
508f2ed
f0a218e
176ebe5
72c5bf1
c3e6c8c
667b9e3
494892b
993d3d1
ab7b846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ _build/ | |
|
||
.DS_Store | ||
Thumbs.db | ||
|
||
gallery.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
extensions = [ | ||
'myst_parser', # there's also myst_nb, which supports embedding Jupyter notebooks, but is heavier. | ||
'sphinx_panels', | ||
'sphinx_design', | ||
] | ||
|
||
myst_heading_anchors = 4 # enable #section links: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors | ||
|
@@ -103,3 +104,96 @@ | |
"README.html")): # don't create dangling symlinks; | ||
# it annoyes Github Pages. | ||
os.symlink("README.html", z) | ||
|
||
|
||
|
||
|
||
# -- Custom scripts ---------------------------------------------------------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line should be above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, fixed in 176ebe5 |
||
|
||
import os | ||
from pathlib import Path | ||
import random | ||
import requests | ||
from subprocess import run | ||
from textwrap import dedent | ||
from urllib.parse import urlparse | ||
from ghapi.all import GhApi | ||
import pandas as pd | ||
|
||
import yaml | ||
|
||
from sphinx.application import Sphinx | ||
from sphinx.util import logging | ||
|
||
LOGGER = logging.getLogger("conf") | ||
|
||
def build_gallery(app: Sphinx): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's inelegant to do all this in the conf.py file, running it on every parse like this. It would be significantly cleaner to package this script as a custom directive, stick it up on pypi, and then instead of
do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and those images should be inlined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed-- but i don't have the time to do it, so #47 |
||
# Build the gallery file | ||
LOGGER.info("building gallery...") | ||
grid_items = [] | ||
projects = yaml.safe_load((Path(app.srcdir) / "gallery.yml").read_text()) | ||
random.shuffle(projects) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'shuffle'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah! thanks, i was wondering why they were shuffled 😅 fixed in c3e6c8c |
||
for item in projects: | ||
if not item.get("image"): | ||
item["image"] = "https://jupyterbook.org/_images/logo-square.svg" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This image should be inlined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad, fixed in 72c5bf1 |
||
|
||
repo_text = "" | ||
star_text = "" | ||
|
||
if item["repository"]: | ||
repo_text = f'{{bdg-link-secondary}}`repo <{item["repository"]}>`' | ||
|
||
try: | ||
url = urlparse(item["repository"]) | ||
if url.netloc == "github.com": | ||
_, org, repo = url.path.rstrip("/").split("/") | ||
star_text = f"[![GitHub Repo stars](https://img.shields.io/github/stars/{org}/{repo}?style=social)]({item['repository']})" | ||
except Exception as error: | ||
pass | ||
|
||
grid_items.append( | ||
f"""\ | ||
`````{{grid-item-card}} {" ".join(item["name"].split())} | ||
:text-align: center | ||
<img src="{item["image"]}" alt="logo" loading="lazy" style="max-width: 100%; max-height: 200px; margin-top: 1rem;" /> | ||
+++ | ||
````{{grid}} 2 2 2 2 | ||
:margin: 0 0 0 0 | ||
:padding: 0 0 0 0 | ||
:gutter: 1 | ||
```{{grid-item}} | ||
:child-direction: row | ||
:child-align: start | ||
:class: sd-fs-5 | ||
{{bdg-link-secondary}}`website <{item["website"]}>` | ||
{repo_text} | ||
``` | ||
```{{grid-item}} | ||
:child-direction: row | ||
:child-align: end | ||
{star_text} | ||
``` | ||
```` | ||
````` | ||
""" | ||
) | ||
grid_items = "\n".join(grid_items) | ||
|
||
# :column: text-center col-6 col-lg-4 | ||
# :card: +my-2 | ||
# :img-top-cls: w-75 m-auto p-2 | ||
# :body: d-none | ||
|
||
panels = f""" | ||
``````{{grid}} 1 2 3 3 | ||
:gutter: 1 1 2 2 | ||
:class-container: full-width | ||
{dedent(grid_items)} | ||
`````` | ||
""" | ||
(Path(app.srcdir) / "gallery.txt").write_text(panels) | ||
|
||
|
||
def setup(app: Sphinx): | ||
app.add_css_file("_static/theme.css") | ||
app.connect("builder-inited", build_gallery) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- name: Spinal Cord Toolbox | ||
website: https://spinalcordtoolbox.com/ | ||
repository: https://github.com/spinalcordtoolbox/spinalcordtoolbox | ||
image: https://raw.githubusercontent.com/spinalcordtoolbox/spinalcordtoolbox/master/documentation/source/_static/img/logo_sct.png | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These images should be inlined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't understand this comment (ie: what do you mean by 'inlined'?) |
||
- name: ivadomed | ||
website: https://ivadomed.org | ||
repository: https://github.com/ivadomed/ivadomed | ||
image: https://raw.githubusercontent.com/ivadomed/ivadomed/master/images/ivadomed_logo.png | ||
- name: qMRLab | ||
website: https://qmrlab.readthedocs.io | ||
repository: https://github.com/qMRLab/qMRLab | ||
image: https://raw.githubusercontent.com/qMRLab/documentation/master/logo/qMR_logo_orig.png | ||
- name: Shimming Toolbox | ||
website: https://shimming-toolbox.org | ||
repository: https://github.com/shimming-toolbox | ||
image: https://raw.githubusercontent.com/shimming-toolbox/shimming-toolbox/master/docs/source/_static/img/shimming_toolbox_logo.png | ||
- name: AxonDeepSeg | ||
website: https://axondeepseg.readthedocs.io/ | ||
repository: https://github.com/neuropoly/axondeepseg | ||
image: https://raw.githubusercontent.com/neuropoly/axondeepseg/master/docs/source/_static/logo_ads-alpha.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ | |
"myst-parser", | ||
"sphinx-book-theme", | ||
"sphinx-panels", | ||
# pinned because of this bug https://github.com/pydata/pydata-sphinx-theme/pull/509 | ||
"sphinx-design~=0.0.11", | ||
# pinned because of this bug https://github.com/pydata/pydata-sphinx-theme/pull/509 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. careful, this changed the meaning of the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad, fixed in 72c5bf1 |
||
# and that the patched sphinx-book-theme isn't out yet: https://github.com/executablebooks/sphinx-book-theme/issues/428#issuecomment-966021270 | ||
"sphinx~=4.2.0", # TODO: unpin when the next sphinx-book-theme is released | ||
], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a strange dependency. It pulls in bootstrap? But bootstrap has already been deprecated for several years by the existence of https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids. If I look at the web debugger in https://sphinx-design.readthedocs.io/en/sbt-theme/grids.html#grid-options I see they're not using that at all though:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed, otherwise on compilation i get: