Skip to content

Commit

Permalink
Create book for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iluuu1994 committed Feb 18, 2024
1 parent 68f1050 commit 19d2b84
Show file tree
Hide file tree
Showing 21 changed files with 1,068 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docs
on:
push:
branches:
- master
paths:
- docs/*
pull_request:
paths:
- docs/*
jobs:
pages:
runs-on: ubuntu-22.04
permissions:
pages: write
id-token: write
steps:
- name: git checkout
uses: actions/checkout@v4
- name: Install dependencies
run: pip install sphinx-design sphinxawesome-theme rstfmt
- name: Check formatting
run: rstfmt --check -w 100 docs/source
- name: Publish
if: github.event_name == 'push'
uses: sphinx-notes/pages@v3
with:
checkout: false
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.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
31 changes: 31 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# php-src docs

This is the home of the php-src internal documentation. 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
* Blogs from contributors

## How to build

`python` 3 and `pip` are required.

```bash
pip install sphinx sphinx-design sphinxawesome-theme
make html
```

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

## Formatting

The files in this documentation are formatted using the [``rstfmt``](https://github.com/dzhu/rstfmt) tool.

```bash
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.
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Empty file added docs/source/_static/.gitkeep
Empty file.
Empty file added docs/source/_templates/.gitkeep
Empty file.
59 changes: 59 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from dataclasses import asdict
from sphinxawesome_theme import ThemeOptions
from sphinxawesome_theme.postprocess import Icons
from sphinx.highlighting import lexers
from pygments.lexers.web import PhpLexer

lexers['php'] = PhpLexer(startinline=True)
lexers['php-annotations'] = PhpLexer(startinline=True)

project = 'php-src docs'
author = 'The PHP Group'
extensions = [
'sphinx_design',
'sphinxawesome_theme.highlighting',
]
templates_path = ['_templates']
html_theme = 'sphinxawesome_theme'
html_static_path = ['_static']
html_title = project
html_permalinks_icon = Icons.permalinks_icon
theme_options = ThemeOptions(
show_prev_next=True,
extra_header_link_icons={
'repository on GitHub': {
'link': 'https://github.com/php/php-src',
'icon': (
'<svg height="26px" style="margin-top:-2px;display:inline" '
'viewBox="0 0 45 44" '
'fill="currentColor" xmlns="http://www.w3.org/2000/svg">'
'<path fill-rule="evenodd" clip-rule="evenodd" '
'd="M22.477.927C10.485.927.76 10.65.76 22.647c0 9.596 6.223 17.736 '
'14.853 20.608 1.087.2 1.483-.47 1.483-1.047 '
'0-.516-.019-1.881-.03-3.693-6.04 '
'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
'2.18.154 3.327 2.24 3.327 2.24 1.937 3.318 5.084 2.36 6.321 '
'1.803.197-1.403.759-2.36 '
'1.379-2.903-4.823-.548-9.894-2.412-9.894-10.734 '
'0-2.37.847-4.31 2.236-5.828-.224-.55-.969-2.759.214-5.748 0 0 '
'1.822-.584 5.972 2.226 '
'1.732-.482 3.59-.722 5.437-.732 1.845.01 3.703.25 5.437.732 '
'4.147-2.81 5.967-2.226 '
'5.967-2.226 1.185 2.99.44 5.198.217 5.748 1.392 1.517 2.232 3.457 '
'2.232 5.828 0 '
'8.344-5.078 10.18-9.916 10.717.779.67 1.474 1.996 1.474 4.021 0 '
'2.904-.027 5.247-.027 '
'5.96 0 .58.392 1.256 1.493 1.044C37.981 40.375 44.2 32.24 44.2 '
'22.647c0-11.996-9.726-21.72-21.722-21.72" '
'fill="currentColor"/></svg>'
),
},
},
)
html_theme_options = asdict(theme_options)
pygments_style = 'sphinx'
12 changes: 12 additions & 0 deletions docs/source/core/data-structures/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#################
Data structures
#################

.. toctree::
:hidden:

zval
reference-counting
zend_string

This section provides an overview of the core data structures used in php-src.
Loading

0 comments on commit 19d2b84

Please sign in to comment.