Skip to content

test on upstream-main #4

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

Open
wants to merge 27 commits into
base: upstream-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b12089c
Rudimentary `array_api_stubs` pkg and folder-per-version docs
honno Jan 3, 2023
63be79b
Regex nitpick ignore for array types
honno Oct 14, 2022
b19d021
Move `2021.12` docs to respective sub-folders
honno Nov 10, 2022
217a519
Fix autosummary by patching stub sub-modules in `conf.py`
honno Nov 10, 2022
4761a6c
Rudimentary build-all Makefile rule
honno Oct 20, 2022
c8a9e7f
Specify versions in `conf.py`
honno Oct 20, 2022
ecd615f
Use `versions.json` method for sphinx-material
honno Oct 31, 2022
7026521
Update image paths to shared `_static/`
honno Oct 31, 2022
29ee59b
Use vars in `make build` definition
honno Oct 31, 2022
640a1c4
Expand regex used to identify unwanted type hint prefixes
honno Oct 31, 2022
958f66a
Update `pages.yml` workflow
honno Nov 1, 2022
3df54fb
Store gh-pages `.gitignore` in `main` to be copied over
honno Nov 3, 2022
8177e15
`_spec_conf.py` -> `_array_api_conf.py`
honno Nov 7, 2022
6373c32
Basic package necessities
honno Nov 7, 2022
29b4af3
Replace `requirements.txt` with extra dependency `doc`
honno Nov 7, 2022
5790c7d
Basic local build guide
honno Nov 7, 2022
8d37dd6
Update preview workflow
honno Nov 10, 2022
e92d697
Remove out-of-date make things, new top-level Makefile
honno Nov 14, 2022
8ee3d1b
Minor `CONTRIBUTING.md` improvements
honno Nov 14, 2022
d30b635
Basic `_array_api_conf.py` module docstring
honno Nov 14, 2022
6ad5f7c
Move quickstart to `README.md`
honno Nov 14, 2022
0e6b2a9
Use `array_api` as opposed to `signatures` for `2021.12` autodoc
honno Nov 15, 2022
df732da
More consistent Makefile
honno Nov 15, 2022
e2ff1d9
Introduce `_ghpages` to hold the non-Sphinx static files
honno Nov 15, 2022
106b990
Rudimentary spec release guide
honno Nov 21, 2022
e2cd5fa
Guide to preserve history for future spec releases
honno Nov 22, 2022
1574723
Update draft references with newest spec release
honno Jan 3, 2023
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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
name: build docs
no_output_timeout: 25m
command: |
pip install -r requirements.txt
sphinx-build -b html -WT --keep-going spec build/draft -d doctrees
pip install .[doc]
make
- store_artifacts:
path: build/draft
path: _site/

workflows:
version: 2
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,14 @@ jobs:
# Install dependencies:
- name: 'Install dependencies'
run: |
pip install -r ./requirements.txt
pip install .[doc]

# Generate the documentation:
- name: 'Build documentation'
run: |
# Turn warnings into errors and ensure .doctrees is not deployed:
sphinx-build -b html -WT --keep-going spec build/draft -d doctrees

# Upload the build artifact:
- name: 'Upload build artifact'
uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'pull_request'}}
with:
name: html
path: build/
if-no-files-found: error
export SPHINXOPTS="-b html -WT --keep-going -d doctrees"
make

# Configure Git:
- name: 'Configure Git'
Expand All @@ -107,10 +99,10 @@ jobs:
git checkout gh-pages
timeout-minutes: 5

# Copy build artifact:
- name: 'Copy build artifact'
- name: 'Copy build to root'
run: |
rm -rf ./draft && cp -R ./build/draft ./draft
cp -R ./_site/* .
cp ./_site/.gitignore .
timeout-minutes: 10

# Commit changes to:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
uses: larsoner/circleci-artifacts-redirector-action@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
artifact-path: 0/build/draft/index.html
artifact-path: 0/_site/draft/index.html
circleci-jobs: build_page
job-title: Check the rendered docs here!
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
# SOFTWARE.
#/

spec/_build/
_site/
doctrees/
build/
.vscode/
node_modules/
__pycache__/
*.pyc
spec/**/generated
tmp/
tmp/
*.egg-info/
*.egg
dist/
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exclude README.md
exclude src/_array_api_conf.py
include PACKAGE.md
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# You can set these variables from the command line.
SPHINXOPTS ?= -W --keep-going
SOURCEDIR = spec
BUILDDIR = _site

.PHONY: default clean build

default: clean build

clean:
-rm -rf $(BUILDDIR)
-find . -type d -name generated -exec rm -rf {} +

build:
-mkdir -p $(BUILDDIR)
-cp "$(SOURCEDIR)/_ghpages/_gitignore.txt" "$(BUILDDIR)/.gitignore"
-cp "$(SOURCEDIR)/_ghpages/versions.json" "$(BUILDDIR)/versions.json"
-cp "$(SOURCEDIR)/_ghpages/index.html" "$(BUILDDIR)/index.html"
-touch "$(BUILDDIR)/.nojekyll"
-sphinx-build "$(SOURCEDIR)/2021.12" "$(BUILDDIR)/2021.12" $(SPHINXOPTS)
-cp -r "$(BUILDDIR)/2021.12" "$(BUILDDIR)/latest"
-sphinx-build "$(SOURCEDIR)/2022.12" "$(BUILDDIR)/2022.12" $(SPHINXOPTS)
9 changes: 9 additions & 0 deletions PACKAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Stubs for the array API standard

Documentation specific to singular Python objects in the spec (i.e. functions,
methods and attributes) are infact represented by stub objects in the package
`array-api-stubs`. These stubs ultimately get rendered via the autodoc
capabilities in Sphinx.

TODO: describe how `array-api-stubs` can be used for tooling, once it actually
has the capacity to do so.
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,122 @@ These are relevant documents related to the content in this repository:
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to go about contributing to
this array API standard.


## Building docs locally

The spec website comprises of multiple Sphinx docs (one for each spec version),
all of which exist in `spec/` and rely on the modules found in `src/` (most
notably `array_api_stubs`). To install these modules and the additional
dependencies of the Sphinx docs, you can use

```sh
$ pip install -e .[doc] # ensure you install the dependencies extra "doc"
```

To build specific versions of the spec, run `sphinx-build` on the respective
folder in `spec/`, e.g.

```sh
$ sphinx-build spec/draft/ _site/draft/
```

To build the whole website, which includes every version of
the spec, you can utilize the `make` commands defined in `spec/Makefile`, e.g.

```sh
$ make
$ ls _site/
2021.12/ draft/ index.html latest/ versions.json
```


## Making a spec release

The Sphinx doc at `spec/draft/` should be where the in-development spec resides,
with `src/array_api_stubs/_draft/` containing its respective stubs. A spec
release should involve:

* Renaming `src/array_api_stubs/_draft/` to `src/array_api_stubs/_YYYY_MM`
* Renaming `spec/draft/` to `spec/YYYY.MM`
* Updating `spec/YYYY.MM/conf.py`

```diff
...
- from array_api_stubs import _draft as stubs_mod
+ from array_api_stubs import _YYYY_MM as stubs_mod
...
- release = "DRAFT"
+ release = "YYYY.MM"
...
```

* Updating `spec/_ghpages/versions.json`

```diff
{
+ "YYYY.MM": "YYYY.MM",
...
```

* Updating `Makefile`

```diff
...
-sphinx-build "$(SOURCEDIR)/PREVIOUS.VER" "$(BUILDDIR)/PREVIOUS.VER" $(SPHINXOPTS)
+ -sphinx-build "$(SOURCEDIR)/YYYY.MM" "$(BUILDDIR)/YYYY.MM" $(SPHINXOPTS)
- -cp -r "$(BUILDDIR)/PREVIOUS.VER" "$(BUILDDIR)/latest"
+ -cp -r "$(BUILDDIR)/YYYY.MM" "$(BUILDDIR)/latest"
...
```

These changes should be committed and tagged. The next draft should then be
created. To preserve git history for both the new release and the next draft:

1. Create and checkout to a new temporary branch.

```sh
$ git checkout -b tmp
```

2. Make an empty commit. <sup>This is required so merging the temporary branch
(4.) is not automatic.</sup>

```sh
$ git commit --allow-empty -m "Empty commit for draft at YYYY.MM "
```

3. Checkout back to the branch you are making a spec release in.

```sh
$ git checkout YYYY.MM-release
```

4. Merge the temporary branch, specifying no commit and no fast-forwarding.

```sh
$ git merge --no-commit --no-ff tmp
Automatic merge went well; stopped before committing as requested
```

5. Checkout the `spec/draft/` files from the temporary branch.

```sh
$ git checkout tmp -- spec/draft/
```

6. Commit your changes.

```sh
$ git commit -m "Copy YYYY.MM as draft with preserved git history"
```

You can run `git blame` on both `spec/YYYY.MM` and `spec/draft` files to verify
we've preserved history. See this [StackOverflow question](https://stackoverflow.com/q/74365771/5193926)
for more background on the approach we use.

<!-- TODO: write a script to automate/standardise spec releases -->


## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[project]
name = "array-api-stubs"
version = "0.0.2"
description = "Stubs for the array API standard"
authors = []
license = {file = "LICENSE"}
readme = "PACKAGE.md"
requires-python = ">=3.8"
keywords = []
classifiers = []

[project.urls]
Source = "https://github.com/data-apis/array-api/"
Documentation = "https://data-apis.org/array-api/"
Homepage = "https://data-apis.org/"

[project.optional-dependencies]
doc = [
"sphinx==4.3.0",
"sphinx-material==0.0.30",
"myst-parser",
"sphinx_markdown_tables",
"sphinx_copybutton",
"docutils<0.18",
"sphinx-math-dollar",
]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

Loading