11#!/usr/bin/env python
2- # flake8: noqa
2+ """Defines configuration for sphinx and readthedocs."""
3+
4+ from __future__ import annotations
5+
6+ import logging
7+
38#
49# tiatoolbox documentation build configuration file, created by
510# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
1217#
1318# All configuration values have a default; values that are commented out
1419# serve to show the default.
15-
1620# If extensions (or modules to document with autodoc) are in another
1721# directory, add these directories to sys.path here. If the directory is
1822# relative to the documentation root, use os.path.abspath to make it
1923# absolute, like shown here.
2024#
2125import os
22- from pathlib import Path
2326import shutil
2427import sys
28+ from pathlib import Path
2529
26- sys .path .insert (0 , os . path . abspath ( ".." ))
30+ sys .path .insert (0 , str ( Path ( ".." ). resolve () ))
2731
2832import tiatoolbox
2933
8488
8589# General information about the project.
8690project = "TIA Toolbox"
87- copyright = "2025, TIA Lab"
91+ copyright = "2025, TIA Lab" # noqa: A001
8892author = "TIA Lab"
8993
9094# The version info for the project you're documenting, acts as replacement
134138#
135139html_theme_options = {
136140 "navigation_with_keys" : True ,
137- "top_of_page_button " : None ,
141+ "top_of_page_buttons " : [ "view" , "edit" ] ,
138142 "footer_icons" : [
139143 {
140144 "name" : "TIA" ,
141145 "url" : "https://warwick.ac.uk/fac/cross_fac/tia/" ,
142146 "html" : """
143- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
144- viewBox="0 0 173 175" style="enable-background:new 0 0 173 175;" xml:space="preserve">
145- <image style="overflow:visible;" width="519" height="525" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgcAAAINCAYAAACqOtxdAAABemlDQ1BJQ0MgUHJvZmlsZQAAKJF9
147+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
148+ xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
149+ viewBox="0 0 173 175" style="enable-background:new 0 0 173 175;"
150+ xml:space="preserve">
151+ <image style="overflow:visible;" width="519" height="525"
152+ xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgcAAAINCAYAAACqOtxdAAABemlDQ1BJQ0MgUHJvZmlsZQAAKJF9
146153 kE0rRFEYx38GjbxEsbCwuHlbDTFKbJSZNKYsNChvmzvXnRllrtudK2RjoWwVJTbeFnwCNhbKWilF
147154 Sna+ALGRrufMjMZLeeo5z+885zn/zvmDL6Db9lxJB6Qt14lFQtr4xKTmf8KHnxqqqNeNjN0/PDyE
148155 xFf9GW+3FKl606a0/p7/GxUzZsaAojLhPsN2XOFB4aZF11as9OoceZTwquJkjrcUx3N8kp0ZjYWF
884891 "name" : "TIA" ,
885892 "url" : "https://warwick.ac.uk/fac/cross_fac/tia/" ,
886893 "html" : """
887- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
888- viewBox="0 0 178 171.89" style="enable-background:new 0 0 178 171.89;" xml:space="preserve">
889- <image style="overflow:visible;" width="518" height="525" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgYAAAINCAYAAABF+LdjAAABfWlDQ1BJQ0MgUHJvZmlsZQAAKJF9
894+ <svg version="1.1" id="Layer_1"
895+ xmlns="http://www.w3.org/2000/svg"
896+ xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
897+ viewBox="0 0 178 171.89"
898+ style="enable-background:new 0 0 178 171.89;" xml:space="preserve">
899+ <image style="overflow:visible;"
900+ width="518" height="525"
901+ xlink:href="data:image/png;base64,
902+ iVBORw0KGgoAAAANSUhEUgAAAgYAAAINCAYAAABF+LdjAAABfWlDQ1BJQ0MgUHJvZmlsZQAAKJF9
890903 kM9LAkEUx7+uhVGGQR06dBjKOqnYBlKXQCVM8CBmkNVlXVcNdF12Nyq6dAi6CgVRl34d6i+oS4eg
891904 cxAERRDd+geKuoRsb1xDK+gNM+8zb958mfkCgk/StFJbECirpp6KRdhcZp65XiDAhR4aTJINLZxM
892905 JkDxnX/Gxz0cPN/5udbf83+jK6cYMuDoIJ6UNd0kniYeWjE1zlyvT6dHEW9wLti8wzlr81m9J52K
18631876 SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
18641877 SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
18651878 SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
1866- SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE0iPwfxKOnjvVcLCDAAAAAElFTkSuQmCC" transform="matrix(0.3333 0 0 0.3333 0 -3.11)">
1879+ SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE0iPwfxKOnjvVcLCDAAAAAElFTkSuQmCC"
1880+ transform="matrix(0.3333 0 0 0.3333 0 -3.11)">
18671881 </image>
18681882 </svg>
18691883 """ ,
18731887 "name" : "GitHub" ,
18741888 "url" : "https://github.com/TissueImageAnalytics/tiatoolbox" ,
18751889 "html" : """
1876- <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github v-align-middle">
1877- <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
1890+ <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1"
1891+ width="32" data-view-component="true"
1892+ class="octicon octicon-mark-github v-align-middle">
1893+ <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29
1894+ 6.53 5.47 7.59.4.07.55-.17.55-.38
1895+ 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94
1896+ -.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21
1897+ 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
1898+ 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21
1899+ 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82
1900+ 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87
1901+ 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
1902+ .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
18781903 </svg>
18791904 """ ,
18801905 "class" : "only-light" ,
18831908 "name" : "GitHub" ,
18841909 "url" : "https://github.com/TissueImageAnalytics/tiatoolbox" ,
18851910 "html" : """
1886- <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github v-align-middle">
1887- <path fill="#ffffff" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
1911+ <svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1"
1912+ width="32" data-view-component="true" class="octicon octicon-mark-github
1913+ v-align-middle">
1914+ <path fill="#ffffff" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0
1915+ 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38
1916+ 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94
1917+ -.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21
1918+ 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
1919+ 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21
1920+ 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82
1921+ 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87
1922+ 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
1923+ .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
18881924 </svg>
18891925 """ ,
18901926 "class" : "only-dark" ,
19011937html_static_path = []
19021938
19031939# These paths are either relative to html_static_path
1904- # or fully qualified paths (eg. https://...)
1905- # html_css_files = []
1940+ # or fully qualified paths (e.g., https://...)
19061941
19071942# -- Options for HTMLHelp output ---------------------------------------
19081943
19631998 "Sphinx" : ("https://www.sphinx-doc.org/en/stable/" , None ),
19641999}
19652000
1966- # create latex preamble so that we can build arbitrary nested depth
1967- fh = open ("latex_preamble.tex" , "r+" )
1968- PREAMBLE = fh .read ()
1969- fh .close ()
1970- latex_elements = {
1971- # Additional stuff for the LaTeX preamble.
1972- "preamble" : PREAMBLE ,
1973- }
1974-
19752001# -- Options for autodoc -----------------------------------------------
19762002
19772003autodoc_typehints = "description"
19802006 "ArrayLike" : "ArrayLike" ,
19812007}
19822008
1983- print ("=" * 43 )
1984- print ("Copy example notebooks into docs/_notebooks" )
1985- print ("=" * 43 )
2009+ logging . info ("=" * 43 )
2010+ logging . info ("Copy example notebooks into docs/_notebooks" )
2011+ logging . info ("=" * 43 )
19862012
19872013
1988- def all_but_ipynb (dir_path , contents ) :
1989- """Helper to copy all .ipynb"""
2014+ def all_but_ipynb (dir_path : str , contents : list ) -> list :
2015+ """Helper to copy all * .ipynb files. """
19902016 result = []
19912017 for c in contents :
1992- flag = os . path . isfile ( os . path . join (dir_path , c ) ) and (not c .endswith (".ipynb" ))
2018+ flag = ( Path (dir_path ) / c ). is_file ( ) and (not c .endswith (".ipynb" ))
19932019 if flag :
19942020 result += [c ]
19952021 return result
19962022
19972023
1998- DOC_ROOT = os .path .dirname (os .path .realpath (__file__ ))
1999- PROJ_ROOT = Path (DOC_ROOT ).parent
2000- shutil .rmtree (os .path .join (PROJ_ROOT , "docs/_notebooks" ), ignore_errors = True )
2024+ PROJ_ROOT = Path (os .path .realpath (__file__ )).parent .parent
2025+ shutil .rmtree (PROJ_ROOT / "docs/_notebooks" , ignore_errors = True )
20012026shutil .copytree (
2002- os . path . join ( PROJ_ROOT , "examples" ) ,
2003- os . path . join ( PROJ_ROOT , "docs/_notebooks/jnb" ) ,
2027+ PROJ_ROOT / "examples" ,
2028+ PROJ_ROOT / "docs/_notebooks/jnb" ,
20042029 ignore = all_but_ipynb ,
20052030)
20062031
2007- # shutil.copy(
2008- # os.path.join(PROJ_ROOT, "docs/usage_examples.rst"),
2009- # os.path.join(PROJ_ROOT, "docs/_notebooks/usage_examples.rst"),
2010- # )
2011-
20122032# Read in the file
2013- with open ("../examples/README.md" , "r" ) as file :
2033+ with Path ("../examples/README.md" ). open ( ) as file :
20142034 file_data = file .read ()
20152035
20162036# Replace the target string
@@ -2020,5 +2040,5 @@ def all_but_ipynb(dir_path, contents):
20202040file_data = file_data .replace ("../docs/" , "./" )
20212041
20222042# Write the file out again
2023- with open ("_notebooks/README.md" , "w" ) as file :
2043+ with Path ("_notebooks/README.md" ). open ( "w" ) as file :
20242044 file .write (file_data )
0 commit comments