diff --git a/.editorconfig b/.editorconfig index 7911bf8490b63..19be96087d908 100644 --- a/.editorconfig +++ b/.editorconfig @@ -32,3 +32,7 @@ max_line_length = 80 [*.patch] trim_trailing_whitespace = false + +[*.rst] +indent_style = space +max_line_length = 100 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2254b8f037e54..6ae972d92e49c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,9 +19,9 @@ 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 + run: make -C docs check-formatting - name: Publish if: github.event_name == 'push' uses: sphinx-notes/pages@v3 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000000..12f3a0600a949 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,36 @@ +# Makefile for php-src/docs +# Copyright (c) The PHP Group + +# If people set these on the make command line, use 'em + +SPHINXBUILD ?= sphinx-build + +SOURCEDIR = source +BUILDDIR = build +RSTFMT = rstfmt +RSTFMTFLAGS = -w 100 + +rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) +FILES = $(call rwildcard,$(SOURCEDIR),*.rst) + +all : html + +.PHONY : check-formatting clean html preflight +.SUFFIXES : # Disable legacy behavior + +check-formatting : + $(RSTFMT) $(RSTFMTFLAGS) --check $(SOURCEDIR) + +clean : + rm -rf -- $(wildcard $(SOURCEDIR)/.~ $(BUILDDIR)) + +html : preflight + $(SPHINXBUILD) -M $@ $(SOURCEDIR) $(BUILDDIR) + @printf 'Browse the \e]8;;%s\e\\%s\e]8;;\e\\.\n' \ + "file://$(abspath $(BUILDDIR))/$@/index.$@" "php-src html docs locally" + +preflight : $(SOURCEDIR)/.~ + +$(SOURCEDIR)/.~ : $(FILES) + $(RSTFMT) $(RSTFMTFLAGS) $? + touch $@ diff --git a/docs/README.md b/docs/README.md index fbd58155a5141..3c0d7ddd2bcc3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 @@ -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 @@ -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. diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 747ffb7b30336..0000000000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@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 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000000000..ca19fe15c2e05 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +Sphinx +sphinx-design +sphinxawesome-theme +rstfmt diff --git a/docs/source/conf.py b/docs/source/conf.py index 2eb75d509cc07..1129eb08a8216 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,7 +16,6 @@ author = 'The PHP Group' extensions = [ 'sphinx_design', - 'sphinxawesome_theme.highlighting', ] templates_path = ['_templates'] html_theme = 'sphinxawesome_theme'