[DOC]: Improve Sphinx configuration and extensions #358
7 changed files with 56 additions and 76 deletions
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
|
|
@ -93,16 +93,11 @@ jobs:
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Install FSL
|
- name: Install FSL
|
||||||
run: |
|
run: |
|
||||||
curl -fsSL https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | python - -d /opt/fsl/
|
curl -fsSL https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/releases/fslinstaller.py | python - -d /opt/fsl/ --skip_registration
|
||||||
FSLOUTPUTTYPE="NIFTI_GZ"
|
echo "FSLDIR=/opt/fsl" >> $GITHUB_ENV
|
||||||
FSLMULTIFILEQUIT="TRUE"
|
echo "FSLOUTPUTTYPE=NIFTI_GZ" >> $GITHUB_ENV
|
||||||
FSLTCLSH="/opt/fsl/bin/fsltclsh"
|
echo "FSLMULTIFILEQUIT=TRUE" >> $GITHUB_ENV
|
||||||
FSLWISH="/opt/fsl/bin/fslwish"
|
echo "/opt/fsl/bin" >> $GITHUB_PATH
|
||||||
FSLLOCKDIR=""
|
|
||||||
FSLMACHINELIST=""
|
|
||||||
FSLREMOTECALL=""
|
|
||||||
FSLGECUDAQ="cuda.q"
|
|
||||||
echo "/opt/fsl" >> $GITHUB_PATH
|
|
||||||
if: matrix.python-version == 3.11
|
if: matrix.python-version == 3.11
|
||||||
# Bypass FSL installation failure
|
# Bypass FSL installation failure
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
|
||||||
|
|
@ -19,24 +19,14 @@ clean:
|
||||||
rm -rf auto_examples/
|
rm -rf auto_examples/
|
||||||
rm -rf api/generated/
|
rm -rf api/generated/
|
||||||
|
|
||||||
# For local build
|
local:
|
||||||
local: news
|
make _build_local; STATUS=$$?; exit $$STATUS
|
||||||
make _build_local; STATUS=$$?; make news_cleanup; exit $$STATUS
|
|
||||||
|
|
||||||
news:
|
|
||||||
@echo "Generating whats_new.rst"
|
|
||||||
cd ../ && towncrier build --keep
|
|
||||||
|
|
||||||
news_cleanup:
|
|
||||||
@echo "Cleaning up whats_new.rst"
|
|
||||||
git restore --staged whats_new.rst
|
|
||||||
git restore whats_new.rst
|
|
||||||
|
|
||||||
_build_local:
|
_build_local:
|
||||||
sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
sphinx-build "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
html: news
|
html:
|
||||||
make _html; STATUS=$$?; make news_cleanup; exit $$STATUS
|
make _html; STATUS=$$?; exit $$STATUS
|
||||||
|
|
||||||
_html:
|
_html:
|
||||||
$(SPHINXBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
|
$(SPHINXBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
|
||||||
|
|
|
||||||
1
docs/changes/newsfragments/358.doc
Normal file
1
docs/changes/newsfragments/358.doc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Improve Sphinx configuration and extensions by `Synchon Mandal`_
|
||||||
63
docs/conf.py
63
docs/conf.py
|
|
@ -6,36 +6,45 @@
|
||||||
# list see the documentation:
|
# list see the documentation:
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
# -- Path setup --------------------------------------------------------------
|
import datetime
|
||||||
|
from functools import partial
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
||||||
#
|
|
||||||
# import os
|
|
||||||
# import sys
|
|
||||||
# sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from setuptools_scm import get_version
|
||||||
|
|
||||||
|
|
||||||
# Check if sphinx-multiversion is installed
|
# Check if sphinx-multiversion is installed
|
||||||
use_multiversion = False
|
use_multiversion = False
|
||||||
try:
|
try:
|
||||||
import sphinx_multiversion # noqa: F401
|
import sphinx_multiversion # noqa: F401
|
||||||
|
|
||||||
use_multiversion = True
|
use_multiversion = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
curdir = Path(__file__).parent
|
|
||||||
sys.path.append((curdir / "sphinxext").as_posix())
|
# -- Path setup --------------------------------------------------------------
|
||||||
|
|
||||||
|
PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve()
|
||||||
|
get_scm_version = partial(get_version, root=PROJECT_ROOT_DIR)
|
||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = "junifer"
|
github_url = "https://github.com"
|
||||||
copyright = "2023, Authors of junifer"
|
github_repo_org = "juaml"
|
||||||
author = "Fede Raimondo"
|
github_repo_name = "junifer"
|
||||||
|
github_repo_slug = f"{github_repo_org}/{github_repo_name}"
|
||||||
|
github_repo_url = f"{github_url}/{github_repo_slug}"
|
||||||
|
|
||||||
|
project = github_repo_name
|
||||||
|
author = f"{project} Contributors"
|
||||||
|
copyright = f"{datetime.date.today().year}, {author}"
|
||||||
|
|
||||||
|
# The version along with dev tag
|
||||||
|
release = get_scm_version(
|
||||||
|
version_scheme="guess-next-dev",
|
||||||
|
local_scheme="no-local-version",
|
||||||
|
)
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -43,16 +52,19 @@ author = "Fede Raimondo"
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
|
# Built-in extensions:
|
||||||
"sphinx.ext.autodoc", # include documentation from docstrings
|
"sphinx.ext.autodoc", # include documentation from docstrings
|
||||||
"sphinx.ext.autosummary", # generate autodoc summaries
|
"sphinx.ext.autosummary", # generate autodoc summaries
|
||||||
"sphinx.ext.doctest", # test snippets in the documentation
|
"sphinx.ext.doctest", # test snippets in the documentation
|
||||||
|
"sphinx.ext.extlinks", # markup to shorten external links
|
||||||
"sphinx.ext.intersphinx", # link to other projects` documentation
|
"sphinx.ext.intersphinx", # link to other projects` documentation
|
||||||
"sphinx.ext.mathjax", # math support for HTML outputs in Sphinx
|
"sphinx.ext.mathjax", # math support for HTML outputs in Sphinx
|
||||||
|
# Third-party extensions:
|
||||||
"sphinx_gallery.gen_gallery", # HTML gallery of examples
|
"sphinx_gallery.gen_gallery", # HTML gallery of examples
|
||||||
"numpydoc", # support for NumPy style docstrings
|
"numpydoc", # support for NumPy style docstrings
|
||||||
"gh_substitutions", # custom GitHub substitutions
|
|
||||||
"sphinx_copybutton", # copy button for code blocks
|
"sphinx_copybutton", # copy button for code blocks
|
||||||
"sphinxcontrib.mermaid", # mermaid support
|
"sphinxcontrib.mermaid", # mermaid support
|
||||||
|
"sphinxcontrib.towncrier.ext", # towncrier fragment support
|
||||||
]
|
]
|
||||||
|
|
||||||
if use_multiversion:
|
if use_multiversion:
|
||||||
|
|
@ -88,11 +100,8 @@ nitpick_ignore_regex = [
|
||||||
|
|
||||||
# -- Options for HTML output -------------------------------------------------
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
||||||
# a list of builtin themes.
|
|
||||||
#
|
|
||||||
html_theme = "furo"
|
html_theme = "furo"
|
||||||
|
html_title = "junifer documentation"
|
||||||
html_logo = "./images/junifer_logo.png"
|
html_logo = "./images/junifer_logo.png"
|
||||||
|
|
||||||
# These paths are either relative to html_static_path
|
# These paths are either relative to html_static_path
|
||||||
|
|
@ -146,6 +155,12 @@ intersphinx_mapping = {
|
||||||
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
|
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -- sphinx.ext.extlinks configuration ---------------------------------------
|
||||||
|
|
||||||
|
extlinks = {
|
||||||
|
"gh": (f"{github_repo_url}/issues/%s", "#%s"),
|
||||||
|
}
|
||||||
|
|
||||||
# -- numpydoc configuration --------------------------------------------------
|
# -- numpydoc configuration --------------------------------------------------
|
||||||
|
|
||||||
numpydoc_show_class_members = False
|
numpydoc_show_class_members = False
|
||||||
|
|
@ -197,3 +212,9 @@ smv_rebuild_tags = False
|
||||||
smv_tag_whitelist = r"^v\d+\.\d+.\d+$"
|
smv_tag_whitelist = r"^v\d+\.\d+.\d+$"
|
||||||
smv_branch_whitelist = r"main"
|
smv_branch_whitelist = r"main"
|
||||||
smv_released_pattern = r"^tags/v.*$"
|
smv_released_pattern = r"^tags/v.*$"
|
||||||
|
|
||||||
|
# -- sphinxcontrib-towncrier configuration -----------------------------------
|
||||||
|
|
||||||
|
towncrier_draft_autoversion_mode = "draft"
|
||||||
|
towncrier_draft_include_empty = True
|
||||||
|
towncrier_draft_working_directory = PROJECT_ROOT_DIR
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
"""Provide GitHub substitutions in Sphinx."""
|
|
||||||
|
|
||||||
from docutils.nodes import reference
|
|
||||||
from docutils.parsers.rst.roles import set_classes
|
|
||||||
|
|
||||||
|
|
||||||
# Taken from MNE-Python
|
|
||||||
# adapted from
|
|
||||||
# https://doughellmann.com/blog/2010/05/09/defining-custom-roles-in-sphinx/
|
|
||||||
|
|
||||||
|
|
||||||
def gh_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
||||||
"""Link to a GitHub issue."""
|
|
||||||
try:
|
|
||||||
# issue/PR mode (issues/PR-num will redirect to pull/PR-num)
|
|
||||||
int(text)
|
|
||||||
except ValueError:
|
|
||||||
# direct link mode
|
|
||||||
slug = text
|
|
||||||
else:
|
|
||||||
slug = "issues/" + text
|
|
||||||
text = "#" + text
|
|
||||||
ref = "https://github.com/juaml/junifer/" + slug
|
|
||||||
set_classes(options)
|
|
||||||
node = reference(rawtext, text, refuri=ref, **options)
|
|
||||||
return [node], []
|
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
|
||||||
app.add_role("gh", gh_role)
|
|
||||||
return
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
What's new
|
What's new
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
.. towncrier-draft-entries:: |release|
|
||||||
|
|
||||||
.. towncrier release notes start
|
.. towncrier release notes start
|
||||||
|
|
||||||
Junifer 0.0.5 (2024-07-22)
|
Junifer 0.0.5 (2024-07-22)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,8 @@ docs = [
|
||||||
"sphinx-copybutton>=0.5.1,<0.5.3",
|
"sphinx-copybutton>=0.5.1,<0.5.3",
|
||||||
"towncrier>=23.10.0,<23.12.0",
|
"towncrier>=23.10.0,<23.12.0",
|
||||||
"sphinxcontrib-mermaid>=0.8.1,<0.10",
|
"sphinxcontrib-mermaid>=0.8.1,<0.10",
|
||||||
|
"sphinxcontrib-towncrier==0.4.0a0",
|
||||||
|
"setuptools-scm>=8",
|
||||||
]
|
]
|
||||||
|
|
||||||
################
|
################
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue