Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render PDEPs using myst-parser and the sphinx doc theme #51467

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ dependencies:
- pyyaml
- requests
- pygments # Code highlighting
- myst-parser

- pip:
- adbc-driver-postgresql>=0.10.0
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ feedparser
pyyaml
requests
pygments
myst-parser
adbc-driver-postgresql>=0.10.0
adbc-driver-sqlite>=0.8.0
typing_extensions; python_version<"3.11"
Expand Down
20 changes: 20 additions & 0 deletions web/pandas/pdeps/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those Makefile and make.bat files are not actually needed, but we could keep them in case you locally just want to build the PDEPs (although then you can also run sphinx-build -M html . _build, so that might not be worth it)

#

# 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)
4 changes: 4 additions & 0 deletions web/pandas/pdeps/_static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
17 changes: 17 additions & 0 deletions web/pandas/pdeps/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends "pydata_sphinx_theme/layout.html" %}
{% block docs_navbar %}
<header>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<div class="container">
<a class="navbar-brand" href="../."><img alt="" src="../static/img/pandas_white.svg"></a>
<div class="navbar-collapse collapse" id="nav-content">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" href="../about/roadmap.html">Back to the PDEP index</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
{% endblock %}
65 changes: 65 additions & 0 deletions web/pandas/pdeps/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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"

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".
html_static_path = ["_static"]

html_css_files = [
"pandas.css",
]
7 changes: 7 additions & 0 deletions web/pandas/pdeps/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Index of Pandas Enhancement Proposals
=====================================

.. toctree::

0001-purpose-and-guidelines.md
0004-consistent-to-datetime-parsing.md
35 changes: 35 additions & 0 deletions web/pandas/pdeps/make.bat
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions web/pandas/static/css/pandas.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
html {
--pst-color-primary: #130654 !important;
}

body {
padding-top: 5em;
color: #444;
Expand Down
14 changes: 14 additions & 0 deletions web/pandas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ def get_source_files(source_path: str) -> typing.Generator[str, None, None]:
"""
for root, dirs, fnames in os.walk(source_path):
root_rel_path = os.path.relpath(root, source_path)
if root_rel_path.startswith("pdeps"):
continue
for fname in fnames:
yield os.path.join(root_rel_path, fname)

Expand Down Expand Up @@ -484,6 +486,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.")
Expand Down
Loading