From 8e92ff65e499d559a5348df8ae48c1f4fb92718f Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 17 Feb 2023 21:45:10 +0100 Subject: [PATCH 1/3] Render PDEPs using sphinx --- environment.yml | 1 + requirements-dev.txt | 1 + web/pandas/pdeps/Makefile | 20 +++++++++ web/pandas/pdeps/_static/.gitignore | 4 ++ web/pandas/pdeps/_templates/layout.html | 17 ++++++++ web/pandas/pdeps/conf.py | 55 +++++++++++++++++++++++++ web/pandas/pdeps/index.rst | 7 ++++ web/pandas/pdeps/make.bat | 35 ++++++++++++++++ web/pandas/static/css/pandas.css | 4 ++ web/pandas_web.py | 14 +++++++ 10 files changed, 158 insertions(+) create mode 100644 web/pandas/pdeps/Makefile create mode 100644 web/pandas/pdeps/_static/.gitignore create mode 100644 web/pandas/pdeps/_templates/layout.html create mode 100644 web/pandas/pdeps/conf.py create mode 100644 web/pandas/pdeps/index.rst create mode 100644 web/pandas/pdeps/make.bat diff --git a/environment.yml b/environment.yml index 04ded62262483..1508db97b2797 100644 --- a/environment.yml +++ b/environment.yml @@ -114,6 +114,7 @@ dependencies: - feedparser - pyyaml - requests + - myst-parser - pip: - sphinx-toggleprompt diff --git a/requirements-dev.txt b/requirements-dev.txt index 044052f4624f5..9cd1c5595b58e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -85,5 +85,6 @@ markdown feedparser pyyaml requests +myst-parser sphinx-toggleprompt setuptools>=61.0.0 diff --git a/web/pandas/pdeps/Makefile b/web/pandas/pdeps/Makefile new file mode 100644 index 0000000000000..d4bb2cbb9eddb --- /dev/null +++ b/web/pandas/pdeps/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/web/pandas/pdeps/_static/.gitignore b/web/pandas/pdeps/_static/.gitignore new file mode 100644 index 0000000000000..5e7d2734cfc60 --- /dev/null +++ b/web/pandas/pdeps/_static/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/web/pandas/pdeps/_templates/layout.html b/web/pandas/pdeps/_templates/layout.html new file mode 100644 index 0000000000000..88ca346d06477 --- /dev/null +++ b/web/pandas/pdeps/_templates/layout.html @@ -0,0 +1,17 @@ +{% extends "pydata_sphinx_theme/layout.html" %} +{% block docs_navbar %} +
+ +
+{% endblock %} diff --git a/web/pandas/pdeps/conf.py b/web/pandas/pdeps/conf.py new file mode 100644 index 0000000000000..c93f27fa7b26a --- /dev/null +++ b/web/pandas/pdeps/conf.py @@ -0,0 +1,55 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# 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('.')) + + +# -- Project information ----------------------------------------------------- + +project = "Pandas Enhancement Proposals" +copyright = "2023, Pandas" +author = "Pandas" + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ["myst_parser"] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + + +# -- 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 = "pydata_sphinx_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +html_css_files = [ + "pandas.css", +] diff --git a/web/pandas/pdeps/index.rst b/web/pandas/pdeps/index.rst new file mode 100644 index 0000000000000..0760b156494e8 --- /dev/null +++ b/web/pandas/pdeps/index.rst @@ -0,0 +1,7 @@ +Index of Pandas Enhancement Proposals +===================================== + +.. toctree:: + + 0001-purpose-and-guidelines.md + 0004-consistent-to-datetime-parsing.md diff --git a/web/pandas/pdeps/make.bat b/web/pandas/pdeps/make.bat new file mode 100644 index 0000000000000..954237b9b9f2b --- /dev/null +++ b/web/pandas/pdeps/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/web/pandas/static/css/pandas.css b/web/pandas/static/css/pandas.css index ec9a4bd502dd1..7430dfefd1226 100644 --- a/web/pandas/static/css/pandas.css +++ b/web/pandas/static/css/pandas.css @@ -1,3 +1,7 @@ +html { + --pst-color-primary: #130654 !important; +} + body { padding-top: 5em; color: #444; diff --git a/web/pandas_web.py b/web/pandas_web.py index e4ffa2cde7cc9..bbeef24cb8afc 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -363,6 +363,8 @@ def get_source_files(source_path: str) -> typing.Generator[str, None, None]: Generate the list of files present in the source directory. """ for root, dirs, fnames in os.walk(source_path): + if root.startswith("pandas/pdeps"): + continue root = os.path.relpath(root, source_path) for fname in fnames: yield os.path.join(root, fname) @@ -429,6 +431,18 @@ def main( os.path.join(source_path, fname), os.path.join(target_path, dirname) ) + # build the PDEPs and copy them to the correct location + pdep_source = os.path.join(source_path, "pdeps") + pdep_build = os.path.join(source_path, "pdeps", "_build") + shutil.copy( + os.path.join(source_path, "static", "css", "pandas.css"), + os.path.join(pdep_source, "_static", "pandas.css"), + ) + os.system(f"sphinx-build -M html {pdep_source} {pdep_build}") + shutil.copytree( + os.path.join(pdep_build, "html"), os.path.join(target_path, "pdeps") + ) + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Documentation builder.") From ebaf4caae9276f4a912222572ef2d236b14e96d6 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 17 Feb 2023 23:18:02 +0100 Subject: [PATCH 2/3] fix path --- web/pandas_web.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/pandas_web.py b/web/pandas_web.py index bbeef24cb8afc..6300eefe91403 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -363,9 +363,9 @@ def get_source_files(source_path: str) -> typing.Generator[str, None, None]: Generate the list of files present in the source directory. """ for root, dirs, fnames in os.walk(source_path): - if root.startswith("pandas/pdeps"): - continue root = os.path.relpath(root, source_path) + if root.startswith("pdeps"): + continue for fname in fnames: yield os.path.join(root, fname) From 25e97ec4d932a04a6727d73310cddb5408d35d1e Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 20 May 2024 13:52:52 +0200 Subject: [PATCH 3/3] force light theme + remove breadcrumbs --- web/pandas/pdeps/conf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/web/pandas/pdeps/conf.py b/web/pandas/pdeps/conf.py index c93f27fa7b26a..09ee61a252b0e 100644 --- a/web/pandas/pdeps/conf.py +++ b/web/pandas/pdeps/conf.py @@ -45,6 +45,16 @@ # html_theme = "pydata_sphinx_theme" +html_context = { + # always force light theme + "default_mode": "light" +} + +html_theme_options = { + # remove the breadcrumbs + "article_header_start": [], +} + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css".