1+ """Configuration file for the Sphinx documentation builder.
2+
3+ This file only contains a selection of the most common options. For a full
4+ list see the documentation:
5+ https://www.sphinx-doc.org/en/master/usage/configuration.html
6+ """
7+
18# -- Path setup --------------------------------------------------------------
29import os
310import sys
11+ from pathlib import Path
12+ from typing import Any , Dict
13+
414import pydata_sphinx_theme
15+ from sphinx .application import Sphinx
516
6- sys .path .append ("scripts" )
7- from gallery_directive import GalleryDirective
17+ sys .path .append (str (Path ("." ).resolve ()))
818
919# -- Project information -----------------------------------------------------
1020
2232 "sphinxext.rediraffe" ,
2333 "sphinx_design" ,
2434 "sphinx_copybutton" ,
35+ "_extension.gallery_directive" ,
2536 # For extension examples and demos
2637 "ablog" ,
2738 "jupyter_sphinx" ,
5768
5869autosummary_generate = True
5970
60-
6171# -- Internationalization ----------------------------------------------------
6272
6373# specifying the natural language populates some key tags
223233# -- application setup -------------------------------------------------------
224234
225235
226- def setup_to_main (app , pagename , templatename , context , doctree ):
236+ def setup_to_main (
237+ app : Sphinx , pagename : str , templatename : str , context , doctree
238+ ) -> None :
239+ """Add a function that jinja can access for returning an "edit this page" link pointing to `main`."""
240+
227241 def to_main (link : str ) -> str :
228- """Transform "edit on github" links and make sure they always point to the main branch
242+ """Transform "edit on github" links and make sure they always point to the main branch.
229243
230244 Args:
231245 link: the link to the github edit interface
@@ -240,6 +254,17 @@ def to_main(link: str) -> str:
240254 context ["to_main" ] = to_main
241255
242256
243- def setup (app ):
244- app .add_directive ("gallery-grid" , GalleryDirective )
257+ def setup (app : Sphinx ) -> Dict [str , Any ]:
258+ """Add custom configuration to sphinx app.
259+
260+ Args:
261+ app: the Sphinx application
262+ Returns:
263+ the 2 parralel parameters set to ``True``.
264+ """
245265 app .connect ("html-page-context" , setup_to_main )
266+
267+ return {
268+ "parallel_read_safe" : True ,
269+ "parallel_write_safe" : True ,
270+ }
0 commit comments