Skip to content

Commit 935fb3e

Browse files
authored
minor: simplify docs build process & pin pip package versions (#17816)
1 parent 032117a commit 935fb3e

File tree

9 files changed

+72
-73
lines changed

9 files changed

+72
-73
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ updates:
5050
interval: "daily"
5151
open-pull-requests-limit: 10
5252
labels: [auto-dependencies]
53+
- package-ecosystem: "pip"
54+
directory: "/docs"
55+
schedule:
56+
interval: "weekly"
57+
labels: [auto-dependencies]

docs/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
build
19-
temp
18+
temp/
19+
build/
2020
venv/
2121
.python-version
22+
__pycache__/

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# You can set these variables from the command line, and also
2323
# from the environment for the first two.
24-
SPHINXOPTS ?=
24+
SPHINXOPTS ?= -W
2525
SPHINXBUILD ?= sphinx-build
2626
SOURCEDIR = source
2727
BUILDDIR = build

docs/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,36 @@ https://datafusion.apache.org/ as part of the release process.
2828
It's recommended to install build dependencies and build the documentation
2929
inside a Python virtualenv.
3030

31-
- Python
32-
- `pip install -r requirements.txt`
31+
```sh
32+
python3 -m venv venv
33+
pip install -r requirements.txt
34+
```
35+
36+
If using [uv](https://docs.astral.sh/uv/) the script can be run like so without
37+
needing to create a virtual environment:
38+
39+
```sh
40+
uv run --with-requirements requirements.txt bash build.sh
41+
```
3342

3443
## Build & Preview
3544

3645
Run the provided script to build the HTML pages.
3746

3847
```bash
48+
# If using venv, ensure you have activated it
3949
./build.sh
4050
```
4151

42-
The HTML will be generated into a `build` directory.
52+
The HTML will be generated into a `build` directory. Open `build/html/index.html`
53+
in your preferred browser, e.g.
4354

4455
Preview the site on Linux by running this command.
4556

4657
```bash
58+
# On macOS
59+
open build/html/index.html
60+
# On Linux with Firefox
4761
firefox build/html/index.html
4862
```
4963

docs/build.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,5 @@
2020

2121
set -e
2222
rm -rf build 2> /dev/null
23-
rm -rf temp 2> /dev/null
24-
mkdir temp
25-
cp -rf source/* temp/
26-
# replace relative URLs with absolute URLs
27-
sed -i -e 's/\.\.\/\.\.\/\.\.\//https:\/\/github.com\/apache\/arrow-datafusion\/blob\/main\//g' temp/contributor-guide/index.md
2823

29-
python rustdoc_trim.py
30-
31-
make SOURCEDIR=`pwd`/temp SPHINXOPTS=-W html
24+
make html

docs/make.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ REM Command file for Sphinx documentation
2323

2424
if "%SPHINXBUILD%" == "" (
2525
set SPHINXBUILD=sphinx-build
26-
)
26+
)
27+
set SPHINXOPTS=-W
2728
set SOURCEDIR=source
2829
set BUILDDIR=build
2930

docs/requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
sphinx
19-
sphinx-reredirects
18+
sphinx==8.2.3
19+
sphinx-reredirects==1.0.0
2020
pydata-sphinx-theme==0.8.0
21-
myst-parser
22-
maturin
23-
jinja2
24-
setuptools>=48.0.0
21+
myst-parser==4.0.1
22+
maturin==1.9.4
23+
jinja2==3.1.6
24+
setuptools==80.9.0

docs/rustdoc_trim.py

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
# under the License.
1717

1818
import re
19-
20-
from pathlib import Path
19+
from sphinx.application import Sphinx
2120

2221
# Regex pattern to match Rust code blocks in Markdown
2322
RUST_CODE_BLOCK_PATTERN = re.compile(r"```rust\s*(.*?)```", re.DOTALL)
@@ -46,30 +45,16 @@ def _process_code_block(match):
4645
return RUST_CODE_BLOCK_PATTERN.sub(_process_code_block, markdown_content)
4746

4847

49-
# Example usage
50-
def process_markdown_file(file_path):
51-
# Read the Markdown file
52-
with open(file_path, "r", encoding="utf-8") as file:
53-
markdown_content = file.read()
54-
48+
def process_source_file(app: Sphinx, docname: str, source: list[str]):
49+
original_content = source[0]
5550
# Remove lines starting with '#' in Rust code blocks
56-
updated_markdown_content = remove_hashtag_lines_in_rust_blocks(markdown_content)
57-
58-
# Write the updated content back to the Markdown file
59-
with open(file_path, "w", encoding="utf-8") as file:
60-
file.write(updated_markdown_content)
61-
62-
print(f"Done processing file: {file_path}")
63-
64-
65-
root_directory = Path("./temp/library-user-guide")
66-
for file_path in root_directory.rglob("*.md"):
67-
print(f"Processing file: {file_path}")
68-
process_markdown_file(file_path)
51+
modified_content = remove_hashtag_lines_in_rust_blocks(original_content)
52+
source[0] = modified_content
6953

70-
root_directory = Path("./temp/user-guide")
71-
for file_path in root_directory.rglob("*.md"):
72-
print(f"Processing file: {file_path}")
73-
process_markdown_file(file_path)
7454

75-
print("All Markdown files processed.")
55+
def setup(app: Sphinx):
56+
app.connect("source-read", process_source_file)
57+
return dict(
58+
parallel_read_safe=True,
59+
parallel_write_safe=True,
60+
)

docs/source/conf.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@
2626
# If extensions (or modules to document with autodoc) are in another directory,
2727
# add these directories to sys.path here. If the directory is relative to the
2828
# documentation root, use os.path.abspath to make it absolute, like shown here.
29-
#
30-
# import os
31-
# import sys
32-
# sys.path.insert(0, os.path.abspath('.'))
29+
import os
30+
import sys
31+
32+
# To pickup rustdoc_trim.py
33+
sys.path.insert(0, os.path.abspath(".."))
3334

3435
# -- Project information -----------------------------------------------------
3536

36-
project = 'Apache DataFusion'
37-
copyright = '2019-2025, Apache Software Foundation'
38-
author = 'Apache Software Foundation'
37+
project = "Apache DataFusion"
38+
copyright = "2019-2025, Apache Software Foundation"
39+
author = "Apache Software Foundation"
3940

4041

4142
# -- General configuration ---------------------------------------------------
@@ -44,24 +45,25 @@
4445
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4546
# ones.
4647
extensions = [
47-
'sphinx.ext.autodoc',
48-
'sphinx.ext.autosummary',
49-
'sphinx.ext.doctest',
50-
'sphinx.ext.ifconfig',
51-
'sphinx.ext.mathjax',
52-
'sphinx.ext.viewcode',
53-
'sphinx.ext.napoleon',
54-
'myst_parser',
55-
'sphinx_reredirects',
48+
"sphinx.ext.autodoc",
49+
"sphinx.ext.autosummary",
50+
"sphinx.ext.doctest",
51+
"sphinx.ext.ifconfig",
52+
"sphinx.ext.mathjax",
53+
"sphinx.ext.viewcode",
54+
"sphinx.ext.napoleon",
55+
"myst_parser",
56+
"sphinx_reredirects",
57+
"rustdoc_trim",
5658
]
5759

5860
source_suffix = {
59-
'.rst': 'restructuredtext',
60-
'.md': 'markdown',
61+
".rst": "restructuredtext",
62+
".md": "markdown",
6163
}
6264

6365
# Add any paths that contain templates here, relative to this directory.
64-
templates_path = ['_templates']
66+
templates_path = ["_templates"]
6567

6668
# List of patterns, relative to source directory, that match files and
6769
# directories to ignore when looking for source files.
@@ -83,7 +85,7 @@
8385
# The theme to use for HTML and HTML Help pages. See the documentation for
8486
# a list of builtin themes.
8587
#
86-
html_theme = 'pydata_sphinx_theme'
88+
html_theme = "pydata_sphinx_theme"
8789

8890
html_theme_options = {
8991
"use_edit_page_button": True,
@@ -99,13 +101,11 @@
99101
# Add any paths that contain custom static files (such as style sheets) here,
100102
# relative to this directory. They are copied after the builtin static files,
101103
# so a file named "default.css" will overwrite the builtin "default.css".
102-
html_static_path = ['_static']
104+
html_static_path = ["_static"]
103105

104106
html_logo = "_static/images/2x_bgwhite_original.png"
105107

106-
html_css_files = [
107-
"theme_overrides.css"
108-
]
108+
html_css_files = ["theme_overrides.css"]
109109

110110
html_sidebars = {
111111
"**": ["docs-sidebar.html"],
@@ -121,9 +121,9 @@
121121
# presence of some special characters like: 🚀, å, {,... But this isn’t a major
122122
# issue for our documentation. So, suppress these warnings to keep our build
123123
# log cleaner.
124-
suppress_warnings = ['misc.highlighting_failure']
124+
suppress_warnings = ["misc.highlighting_failure"]
125125

126126
redirects = {
127127
"library-user-guide/adding-udfs": "functions/index.html",
128128
"user-guide/runtime_configs": "configs.html",
129-
}
129+
}

0 commit comments

Comments
 (0)