From 9740f1b24aab02c5bb1e3b186386fadb79c387f4 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 21 Jun 2026 22:00:20 -0700 Subject: [PATCH] doc: drop Jekyll underscore workaround We now have enough flexibility in OpenSlide's website pipeline to work around the Sphinx/Jekyll conflict from that side. Stop carrying a custom Sphinx extension. Signed-off-by: Benjamin Gilbert --- doc/conf.py | 1 - doc/jekyll_fix.py | 84 ----------------------------------------------- 2 files changed, 85 deletions(-) delete mode 100644 doc/jekyll_fix.py diff --git a/doc/conf.py b/doc/conf.py index b6d694c5..cf9c9a48 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -29,7 +29,6 @@ extensions = [ 'sphinx.ext.coverage', 'sphinx.ext.intersphinx', - 'jekyll_fix', ] # Add any paths that contain templates here, relative to this directory. diff --git a/doc/jekyll_fix.py b/doc/jekyll_fix.py deleted file mode 100644 index b9547fab..00000000 --- a/doc/jekyll_fix.py +++ /dev/null @@ -1,84 +0,0 @@ -# -# openslide-python - Python bindings for the OpenSlide library -# -# Copyright (c) 2014 Carnegie Mellon University -# Copyright (c) 2024 Benjamin Gilbert -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of version 2.1 of the GNU Lesser General Public License -# as published by the Free Software Foundation. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library. If not, see . -# - -# Sphinx hardcodes that certain output paths have names starting with -# an underscore. -# Jekyll hardcodes that filenames starting with an underscore are not -# deployed to the website. -# Rename Sphinx output paths to drop the underscore. - -from __future__ import annotations - -import os -from pathlib import Path - -from sphinx.application import Sphinx -from sphinx.util import logging -from sphinx.util.console import bold - -DIRS = { - '_static': 'static', - '_sources': 'sources', -} -FILES = { - # Added in Sphinx 5.0.0, scheduled to be removed in Sphinx 6 - 'static/_sphinx_javascript_frameworks_compat.js': 'static/sphinx_javascript_frameworks_compat.js', -} -REWRITE_EXTENSIONS = {'.html', '.js'} - - -def remove_path_underscores(app: Sphinx, exception: Exception | None) -> None: - if exception: - return - # Get logger - logger = logging.getLogger(__name__) - logger.info(bold('fixing pathnames... '), nonl=True) - # Rewrite references in HTML/JS files - outdir = Path(app.outdir) - for dirpath, _, filenames in os.walk(outdir): - for filename in filenames: - path = Path(dirpath) / filename - if path.suffix in REWRITE_EXTENSIONS: - with path.open(encoding='utf-8') as fh: - contents = fh.read() - for old, new in DIRS.items(): - contents = contents.replace(old + '/', new + '/') - for old, new in FILES.items(): - contents = contents.replace(old, new) - with path.open('w', encoding='utf-8') as fh: - fh.write(contents) - # Move directory contents - for old, new in DIRS.items(): - olddir = outdir / old - newdir = outdir / new - newdir.mkdir(exist_ok=True) - if olddir.is_dir(): - for oldfile in olddir.iterdir(): - oldfile.rename(newdir / oldfile.name) - olddir.rmdir() - # Move files - for old, new in FILES.items(): - oldfile = outdir / old - if oldfile.is_file(): - oldfile.rename(outdir / new) - logger.info('done') - - -def setup(app: Sphinx) -> None: - app.connect('build-finished', remove_path_underscores)