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

Improve php-src docs sphinx build, also on *nix #16743

Open
wants to merge 4 commits into
base: PHP-8.4
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ max_line_length = 80

[*.patch]
trim_trailing_whitespace = false

[*.rst]
indent_style = space
max_line_length = 100
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: git checkout
uses: actions/checkout@v4
- name: Install dependencies
run: pip install sphinx-design sphinxawesome-theme rstfmt
run: pip install -r docs/requirements.txt
- name: Check formatting
run: rstfmt --check -w 100 docs/source
Copy link
Member

Choose a reason for hiding this comment

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

This should probably use the make file, to make sure the commands stay consistent.

- name: Publish
Expand Down
29 changes: 29 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Makefile for php-src/docs
# Copyright (c) The PHP Group

# If people set these on the make command line, use 'em

SPHINXBUILD ?= sphinx-build
GH_PAGES_URL ?= https://php.github.io/php-src/

SOURCEDIR = source
BUILDDIR = build

rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
FILES = $(call rwildcard,$(SOURCEDIR),*.rst)

all : html

.PHONY : clean html

clean :
rm -rf -- $(wildcard $(SOURCEDIR)/.~ $(BUILDDIR))

html : $(SOURCEDIR)/.~
$(SPHINXBUILD) -M $@ $(SOURCEDIR) $(BUILDDIR)
@printf 'Browse the php-src docs \e]8;;%s\e\\%s\e]8;;\e\\ (or \e]8;;%s\e\\%s\e]8;;\e\\)\n' \
"file://$(abspath $(BUILDDIR))/$@/index.$@" "local" "$(GH_PAGES_URL)" "online"
Copy link
Member

Choose a reason for hiding this comment

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

Why do we spell out the online version? That makes it sound like it was deployed.


$(SOURCEDIR)/.~ : $(FILES)
rstfmt -w 100 $?
touch $@
19 changes: 12 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# php-src docs

This is the home of the php-src internal documentation, hosted at
[php.github.io/php-src/](https://php.github.io/php-src/). It is in very early stages, but is
intended to become the primary place where new information about php-src is documented. Over time,
it is expected to replace various mediums like:
[php.github.io/php-src/](https://php.github.io/php-src/). It is in very early
stages, but is intended to become the primary place where new information about
php-src is documented. Over time, it is expected to replace various mediums
like:

* https://www.phpinternalsbook.com/
* https://wiki.php.net/internals
Expand All @@ -14,11 +15,15 @@ it is expected to replace various mediums like:
`python` 3 and `pip` are required.

```bash
pip install sphinx sphinx-design sphinxawesome-theme
cd docs
# Recommended: Initialize and activate a Python virtual environment
pip install --upgrade pip
pip install -r requirements.txt
make html
```

That's it! You can view the documentation under `./build/html/index.html` in your browser.
That's it! You can view the documentation under `./build/html/index.html` in
your browser.

## Formatting

Expand All @@ -29,5 +34,5 @@ The files in this documentation are formatted using the
rstfmt -w 100 source
```

This tool is not perfect. It breaks on custom directives, so we might switch to either a fork or
something else in the future.
This tool is not perfect. It breaks on custom directives, so we might switch to
either a fork or something else in the future.
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sphinx
sphinx-design
sphinxawesome-theme
rstfmt
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
author = 'The PHP Group'
extensions = [
'sphinx_design',
'sphinxawesome_theme.highlighting',
Copy link
Member

Choose a reason for hiding this comment

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

Why is this dropped?

]
templates_path = ['_templates']
html_theme = 'sphinxawesome_theme'
Expand Down
Loading