Skip to content

Commit b266dc6

Browse files
authored
Merge pull request #227 from melissawm/add-docs
Add basic documentation site
2 parents bf28864 + 8b5bb66 commit b266dc6

File tree

9 files changed

+186
-2
lines changed

9 files changed

+186
-2
lines changed

.github/workflows/build_docs.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # Make sure this job can be triggered manually
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
steps:
17+
- uses: actions/checkout@v5
18+
- uses: actions/configure-pages@v3
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.13'
22+
- name: Install dependencies
23+
run: |
24+
cd quaddtype/
25+
python -m pip install --upgrade pip
26+
python -m pip install "numpy @ git+https://github.com/numpy/numpy.git" pytest meson meson-python
27+
- name: Build quaddtype package
28+
run: |
29+
cd quaddtype/
30+
python -m pip install . -v --no-build-isolation
31+
- name: Build Sphinx documentation
32+
run: |
33+
cd quaddtype/
34+
python -m pip install ."[docs]"
35+
cd docs/
36+
sphinx-build -b html . _build/html/quaddtype
37+
- name: Upload artifact
38+
uses: actions/upload-pages-artifact@v4
39+
with:
40+
path: './quaddtype/docs/_build/html'
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,6 @@ compile_commands.json
143143
/quaddtype/subprojects/sleef/
144144
/quaddtype/subprojects/pythoncapi-compat/
145145
.wraplock
146+
147+
# docs
148+
/quaddtype/docs/_build/

quaddtype/README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ np.array([1,2,3], dtype=QuadPrecDType("longdouble"))
2525

2626
## Installation from source
2727

28-
#### Prerequisites
28+
### Prerequisites
2929

3030
- **gcc/clang**
3131
- **CMake** (≥3.15)
@@ -170,4 +170,37 @@ This is a development feature to help detect threading issues. To build `numpy-q
170170
export CXXFLAGS="-fsanitize=thread -g -O0"
171171
export LDFLAGS="-fsanitize=thread"
172172
python -m pip install . -vv --no-build-isolation -Csetup-args=-Db_sanitize=thread
173-
```
173+
```
174+
175+
## Building the documentation
176+
177+
The documentation for the `numpy-quaddtype` package is built using Sphinx. To build the documentation, follow these steps:
178+
179+
1. Install the required dependencies:
180+
181+
```bash
182+
pip install ."[docs]"
183+
```
184+
185+
2. Navigate to the `docs` directory and build the documentation:
186+
187+
```bash
188+
cd docs/
189+
make html
190+
```
191+
192+
3. The generated HTML documentation can be found in the `_build/html` directory within the `docs` folder. Open the `index.html` file in a web browser to view the documentation, or use a local server to serve the files:
193+
194+
```bash
195+
python3 -m http.server --directory _build/html
196+
```
197+
198+
### Serving the documentation
199+
200+
The documentation is automatically built and served using GitHub Pages. Every time changes are pushed to the `main` branch, the documentation is rebuilt and deployed to the `gh-pages` branch of the repository. You can access the documentation at:
201+
202+
```
203+
https://numpy.github.io/numpy-user-dtypes/quaddtype/
204+
```
205+
206+
Check the `.github/workflows/build_docs.yml` file for details.

quaddtype/docs/Makefile

Lines changed: 20 additions & 0 deletions
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)

quaddtype/docs/api_docs.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NumPy QuadDType API Documentation
2+
=================================
3+
4+
.. automodule:: numpy_quaddtype
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

quaddtype/docs/conf.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = 'NumPy QuadDType'
10+
copyright = '2025, NumPy Community'
11+
author = 'NumPy Community'
12+
13+
# -- General configuration ---------------------------------------------------
14+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
15+
16+
extensions = [
17+
'sphinx.ext.autodoc',
18+
'sphinx.ext.napoleon',
19+
'myst_parser',
20+
]
21+
22+
templates_path = ['_templates']
23+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
24+
25+
# -- Options for HTML output -------------------------------------------------
26+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
27+
28+
html_theme = 'pydata_sphinx_theme'
29+

quaddtype/docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```{include} ../README.md
2+
```
3+
4+
```{toctree}
5+
:hidden:
6+
7+
api_docs.rst
8+
```

quaddtype/docs/make.bat

Lines changed: 35 additions & 0 deletions
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

quaddtype/pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ test = [
3737
"pytest-run-parallel"
3838
]
3939

40+
docs = [
41+
"sphinx",
42+
"pydata-sphinx-theme",
43+
"myst-parser",
44+
]
45+
4046
[project.urls]
4147
Repository = "https://github.com/numpy/numpy-user-dtypes"
4248
Documentation = "https://github.com/numpy/numpy-user-dtypes/tree/main/quaddtype"

0 commit comments

Comments
 (0)