Skip to content

Commit 19d2b84

Browse files
committed
Create book for docs
Closes phpGH-13338
1 parent 68f1050 commit 19d2b84

21 files changed

+1068
-0
lines changed

.github/workflows/docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docs
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- docs/*
8+
pull_request:
9+
paths:
10+
- docs/*
11+
jobs:
12+
pages:
13+
runs-on: ubuntu-22.04
14+
permissions:
15+
pages: write
16+
id-token: write
17+
steps:
18+
- name: git checkout
19+
uses: actions/checkout@v4
20+
- name: Install dependencies
21+
run: pip install sphinx-design sphinxawesome-theme rstfmt
22+
- name: Check formatting
23+
run: rstfmt --check -w 100 docs/source
24+
- name: Publish
25+
if: github.event_name == 'push'
26+
uses: sphinx-notes/pages@v3
27+
with:
28+
checkout: false
29+
documentation_path: docs/source
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

docs/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# php-src docs
2+
3+
This is the home of the php-src internal documentation. It is in very early stages, but is intended
4+
to become the primary place where new information about php-src is documented. Over time, it is
5+
expected to replace various mediums like:
6+
7+
* https://www.phpinternalsbook.com/
8+
* https://wiki.php.net/internals
9+
* Blogs from contributors
10+
11+
## How to build
12+
13+
`python` 3 and `pip` are required.
14+
15+
```bash
16+
pip install sphinx sphinx-design sphinxawesome-theme
17+
make html
18+
```
19+
20+
That's it! You can view the documentation under `./build/html/index.html` in your browser.
21+
22+
## Formatting
23+
24+
The files in this documentation are formatted using the [``rstfmt``](https://github.com/dzhu/rstfmt) tool.
25+
26+
```bash
27+
rstfmt -w 100 source
28+
```
29+
30+
This tool is not perfect. It breaks on custom directives, so we might switch to either a fork or
31+
something else in the future.

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=source
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

docs/source/_static/.gitkeep

Whitespace-only changes.

docs/source/_templates/.gitkeep

Whitespace-only changes.

docs/source/conf.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
from dataclasses import asdict
7+
from sphinxawesome_theme import ThemeOptions
8+
from sphinxawesome_theme.postprocess import Icons
9+
from sphinx.highlighting import lexers
10+
from pygments.lexers.web import PhpLexer
11+
12+
lexers['php'] = PhpLexer(startinline=True)
13+
lexers['php-annotations'] = PhpLexer(startinline=True)
14+
15+
project = 'php-src docs'
16+
author = 'The PHP Group'
17+
extensions = [
18+
'sphinx_design',
19+
'sphinxawesome_theme.highlighting',
20+
]
21+
templates_path = ['_templates']
22+
html_theme = 'sphinxawesome_theme'
23+
html_static_path = ['_static']
24+
html_title = project
25+
html_permalinks_icon = Icons.permalinks_icon
26+
theme_options = ThemeOptions(
27+
show_prev_next=True,
28+
extra_header_link_icons={
29+
'repository on GitHub': {
30+
'link': 'https://github.com/php/php-src',
31+
'icon': (
32+
'<svg height="26px" style="margin-top:-2px;display:inline" '
33+
'viewBox="0 0 45 44" '
34+
'fill="currentColor" xmlns="http://www.w3.org/2000/svg">'
35+
'<path fill-rule="evenodd" clip-rule="evenodd" '
36+
'd="M22.477.927C10.485.927.76 10.65.76 22.647c0 9.596 6.223 17.736 '
37+
'14.853 20.608 1.087.2 1.483-.47 1.483-1.047 '
38+
'0-.516-.019-1.881-.03-3.693-6.04 '
39+
'1.312-7.315-2.912-7.315-2.912-.988-2.51-2.412-3.178-2.412-3.178-1.972-1.346.149-1.32.149-1.32 ' # noqa
40+
'2.18.154 3.327 2.24 3.327 2.24 1.937 3.318 5.084 2.36 6.321 '
41+
'1.803.197-1.403.759-2.36 '
42+
'1.379-2.903-4.823-.548-9.894-2.412-9.894-10.734 '
43+
'0-2.37.847-4.31 2.236-5.828-.224-.55-.969-2.759.214-5.748 0 0 '
44+
'1.822-.584 5.972 2.226 '
45+
'1.732-.482 3.59-.722 5.437-.732 1.845.01 3.703.25 5.437.732 '
46+
'4.147-2.81 5.967-2.226 '
47+
'5.967-2.226 1.185 2.99.44 5.198.217 5.748 1.392 1.517 2.232 3.457 '
48+
'2.232 5.828 0 '
49+
'8.344-5.078 10.18-9.916 10.717.779.67 1.474 1.996 1.474 4.021 0 '
50+
'2.904-.027 5.247-.027 '
51+
'5.96 0 .58.392 1.256 1.493 1.044C37.981 40.375 44.2 32.24 44.2 '
52+
'22.647c0-11.996-9.726-21.72-21.722-21.72" '
53+
'fill="currentColor"/></svg>'
54+
),
55+
},
56+
},
57+
)
58+
html_theme_options = asdict(theme_options)
59+
pygments_style = 'sphinx'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#################
2+
Data structures
3+
#################
4+
5+
.. toctree::
6+
:hidden:
7+
8+
zval
9+
reference-counting
10+
zend_string
11+
12+
This section provides an overview of the core data structures used in php-src.

0 commit comments

Comments
 (0)