Skip to content

Commit 65882ba

Browse files
Render PDEPs using sphinx
1 parent 4965c51 commit 65882ba

File tree

11 files changed

+162
-0
lines changed

11 files changed

+162
-0
lines changed

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ dependencies:
114114
- feedparser
115115
- pyyaml
116116
- requests
117+
- myst-parser
117118

118119
- pip:
119120
- sphinx-toggleprompt

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ markdown
8585
feedparser
8686
pyyaml
8787
requests
88+
myst-parser
8889
sphinx-toggleprompt
8990
setuptools>=61.0.0

web/pandas/config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ main:
55
ignore:
66
- _templates/layout.html
77
- config.yml
8+
- pdeps/conf.py
9+
- pdeps/Makefile
10+
- pdeps/make.bat
11+
- pdeps/_templates/layout.html
812
github_repo_url: pandas-dev/pandas
913
context_preprocessors:
1014
- pandas_web.Preprocessors.current_year

web/pandas/pdeps/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

web/pandas/pdeps/_static/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% extends "pydata_sphinx_theme/layout.html" %}
2+
{% block docs_navbar %}
3+
<header>
4+
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
5+
<div class="container">
6+
<a class="navbar-brand" href="../."><img alt="" src="../static/img/pandas_white.svg"></a>
7+
<div class="navbar-collapse collapse" id="nav-content">
8+
<ul class="navbar-nav ms-auto">
9+
<li class="nav-item">
10+
<a class="nav-link" href="../about/roadmap.html">Back to the PDEP index</a>
11+
</li>
12+
</ul>
13+
</div>
14+
</div>
15+
</nav>
16+
</header>
17+
{% endblock %}

web/pandas/pdeps/conf.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = "Pandas Enhancement Proposals"
21+
copyright = "2023, Pandas"
22+
author = "Pandas"
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
extensions = ["myst_parser"]
31+
32+
# Add any paths that contain templates here, relative to this directory.
33+
templates_path = ["_templates"]
34+
35+
# List of patterns, relative to source directory, that match files and
36+
# directories to ignore when looking for source files.
37+
# This pattern also affects html_static_path and html_extra_path.
38+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
39+
40+
41+
# -- Options for HTML output -------------------------------------------------
42+
43+
# The theme to use for HTML and HTML Help pages. See the documentation for
44+
# a list of builtin themes.
45+
#
46+
html_theme = "pydata_sphinx_theme"
47+
48+
# Add any paths that contain custom static files (such as style sheets) here,
49+
# relative to this directory. They are copied after the builtin static files,
50+
# so a file named "default.css" will overwrite the builtin "default.css".
51+
html_static_path = ["_static"]
52+
53+
html_css_files = [
54+
"pandas.css",
55+
]

web/pandas/pdeps/index.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Index of Pandas Enhancement Proposals
2+
=====================================
3+
4+
.. toctree::
5+
6+
0001-purpose-and-guidelines.md
7+
0004-consistent-to-datetime-parsing.md

web/pandas/pdeps/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

web/pandas/static/css/pandas.css

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
html {
2+
--pst-color-primary: #130654 !important;
3+
}
4+
15
body {
26
padding-top: 5em;
37
color: #444;

web/pandas_web.py

+14
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ def get_source_files(source_path: str) -> typing.Generator[str, None, None]:
363363
Generate the list of files present in the source directory.
364364
"""
365365
for root, dirs, fnames in os.walk(source_path):
366+
if root.startswith("pandas/pdeps"):
367+
continue
366368
root = os.path.relpath(root, source_path)
367369
for fname in fnames:
368370
yield os.path.join(root, fname)
@@ -429,6 +431,18 @@ def main(
429431
os.path.join(source_path, fname), os.path.join(target_path, dirname)
430432
)
431433

434+
# build the PDEPs and copy them to the correct location
435+
pdep_source = os.path.join(source_path, "pdeps")
436+
pdep_build = os.path.join(source_path, "pdeps", "_build")
437+
shutil.copy(
438+
os.path.join(source_path, "static", "css", "pandas.css"),
439+
os.path.join(pdep_source, "_static", "pandas.css"),
440+
)
441+
os.system(f"sphinx-build -M html {pdep_source} {pdep_build}")
442+
shutil.copytree(
443+
os.path.join(pdep_build, "html"), os.path.join(target_path, "pdeps")
444+
)
445+
432446

433447
if __name__ == "__main__":
434448
parser = argparse.ArgumentParser(description="Documentation builder.")

0 commit comments

Comments
 (0)