- Add documentation for how to build documentation and its several builds

- Add sphinx-design for tabs
- Use `Makefile` from plone-sphinx-theme and tweak
- Add Sphinx linkcheckbroken and linkcheck builds. See #854.
- Move the docs build directory to the root of the repo for ease of access and simplify builds
pull/822/head
Steve Piercy 2025-10-05 01:47:38 -07:00
rodzic 13082ec917
commit 243a55ee1f
7 zmienionych plików z 270 dodań i 200 usunięć

3
.gitignore vendored
Wyświetl plik

@ -3,12 +3,12 @@
*.sw?
*~
.*
_build/
bin/
build/
coverage-*
develop-eggs/
dist/
docs/_build/
eggs/
htmlcov/
include/
@ -23,6 +23,7 @@ src/icalendar.egg-info/
venv
/ical_fuzzer.pkg.spec
/src/icalendar/_version.py
uv.lock
coverage.xml
!.coveragerc

143
Makefile 100644
Wyświetl plik

@ -0,0 +1,143 @@
# Makefile for Sphinx documentation
.DEFAULT_GOAL = help
SHELL = bash
# You can set these variables from the command line.
SPHINXOPTS ?=
PAPER ?=
# Internal variables.
SPHINXBUILD = "$(realpath .venv/bin/sphinx-build)"
SPHINXAUTOBUILD = "$(realpath .venv/bin/sphinx-autobuild)"
DOCS_DIR = ./docs/
BUILDDIR = ../_build
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# See https://github.com/collective/icalendar/issues/853 for future implementation
#VALEFILES := $(shell find $(DOCS_DIR) -type f -name "*.rst" -print) # Also add `src` for docstrings.
#VALEOPTS ?=
PYTHONVERSION = >=3.11,<3.14
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: # This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# environment management
.PHONY: dev
dev: ## Install required Python, create Python virtual environment, and install package requirements
@uv python install "$(PYTHONVERSION)"
@uv venv --python "$(PYTHONVERSION)"
@uv sync --group docs
.PHONY: sync
sync: ## Sync package requirements
@uv sync
.PHONY: init
init: clean clean-python dev docs ## Clean docs build directory and initialize Python virtual environment
.PHONY: clean
clean: ## Clean docs build directory
cd $(DOCS_DIR) && rm -rf $(BUILDDIR)/
.PHONY: clean-python
clean-python: clean
rm -rf .venv/
# /environment management
# documentation builders
.PHONY: html
html: dev ## Build html
cd $(DOCS_DIR) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: livehtml
livehtml: dev ## Rebuild Sphinx documentation on changes, with live-reload in the browser
cd "$(DOCS_DIR)" && ${SPHINXAUTOBUILD} \
--ignore "*.swp" \
--port 8050 \
-b html . "$(BUILDDIR)/html" $(SPHINXOPTS) $(O)
.PHONY: dirhtml
dirhtml: dev
cd $(DOCS_DIR) && $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml: dev
cd $(DOCS_DIR) && $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: text
text: dev
cd $(DOCS_DIR) && $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: changes
changes: dev
cd $(DOCS_DIR) && $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
# /documentation builders
# test
.PHONY: linkcheck
linkcheck: dev ## Run linkcheck
cd $(DOCS_DIR) && $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/ ."
.PHONY: linkcheckbroken
linkcheckbroken: dev ## Run linkcheck and show only broken links
cd $(DOCS_DIR) && $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | GREP_COLORS='0;31' grep -wi "broken\|redirect" --color=always | GREP_COLORS='0;31' grep -vi "https://github.com/plone/volto/issues/" --color=always && if test $$? = 0; then exit 1; fi || test $$? = 1
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/ ."
# See https://github.com/collective/icalendar/issues/853 and above comment
#.PHONY: vale
#vale: dev ## Run Vale style, grammar, and spell checks
# @uv run vale sync
# @uv run vale --no-wrap $(VALEOPTS) $(VALEFILES)
# @echo
# @echo "Vale is finished; look for any errors in the above output."
# Not yet implemented
#.PHONY: doctest
#doctest: dev ## Test snippets in the documentation
# cd $(DOCS_DIR) && $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
# @echo "Testing of doctests in the sources finished, look at the " \
# "results in $(BUILDDIR)/doctest/output.txt."
.PHONY: test
#test: clean vale linkcheckbroken doctest ## Clean docs build, then run vale and linkcheckbroken
test: clean linkcheckbroken ## Clean docs build, then run vale and linkcheckbroken
# /test
# development
.PHONY: rtd-prepare
rtd-prepare: ## Prepare environment on Read the Docs
asdf plugin add uv
asdf install uv latest
asdf global uv latest
.PHONY: rtd-pr-preview
rtd-pr-preview: rtd-prepare dev ## Build pull request preview on Read the Docs
cd $(DOCS_DIR) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/
.PHONY: all
all: clean linkcheck html ## Clean docs build, then run linkcheck, and build html
#all: clean vale linkcheck html ## Clean docs build, then run vale and linkcheck, and build html
# /development

Wyświetl plik

@ -1,177 +0,0 @@
# Makefile for Sphinx documentation
.DEFAULT_GOAL = help
SHELL = bash
# You can set these variables from the command line.
SPHINXOPTS ?=
# Internal variables.
SPHINXBUILD = "$(realpath ../.venv/bin/sphinx-build)"
SPHINXAUTOBUILD = "$(realpath ../.venv/bin/sphinx-autobuild)"
PAPER =
BUILDDIR = _build
LOCALESDIR = _locales
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext livehtml rtd-pr-preview
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " livehtml to view a live preview of standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in docs/$(BUILDDIR)/html."
rm -rf build
manual: *.rst
$(SPHINXBUILD) -b html -t manual . manual
presentation: *.rst
$(SPHINXBUILD) -b html -t presentation . presentation
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/icalendar.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/icalendar.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/icalendar"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/icalendar"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(LOCALESDIR)
@echo
@echo "Build finished. The message catalogs are in $(LOCALESDIR)."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: livehtml
livehtml:
$(SPHINXAUTOBUILD) \
--watch ../src \
--ignore "*.swp" \
--port 8050 \
-b html . "$(BUILDDIR)/html" $(SPHINXOPTS) $(O)
rtd-pr-preview: ## Build pull request preview on Read the Docs
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/

Wyświetl plik

@ -13,6 +13,7 @@ extensions = [
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"sphinx_design",
"sphinx_reredirects",
"sphinx.ext.intersphinx",
"sphinx.ext.autosectionlabel",

Wyświetl plik

@ -143,39 +143,145 @@ Try it out:
>>> icalendar.Calendar()
VCALENDAR({})
Build the documentation
-----------------------
Documentation prerequisites
---------------------------
To build the documentation, follow these steps:
Documentation builds require that you install GNU Make and uv.
Make
````
``make`` is used to provide an interface to developers to perform repetitive tasks with a single command.
``make`` comes installed on most Linux distributions.
On macOS, you must first [install Xcode](https://developer.apple.com/xcode/resources/), then install its command line tools.
On Windows, it is strongly recommended to [Install Linux on Windows with WSL](https://learn.microsoft.com/en-us/windows/wsl/install), which will include ``make``.
Finally, it is a good idea to update your system's version of ``make``, because some distributions, especially macOS, have an outdated version.
Use your favorite search engine or trusted online resource for how to update ``make``.
uv
``
`uv <https://docs.astral.sh/uv/>`_ is used for installing Python, creating a Python virtual environment, and managing dependencies for documentation.
Install uv.
Carefully read the console output for further instructions, and follow them, if needed.
.. tab-set::
.. tab-item:: macOS, Linux, and Windows with WSL
.. code-block:: shell
curl -LsSf https://astral.sh/uv/install.sh | sh
.. tab-item:: Windows
.. code-block:: shell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
.. seealso::
[Other {term}`uv` installation methods](https://docs.astral.sh/uv/getting-started/installation/)
Documentation builds
--------------------
All build and check commands use the file :file:`Makefile` at the root of the repository.
To see descriptions of the builds, use the following command.
.. code-block:: shell
make help
Else you can open the :file:`Makefile` file to see other build formats.
The following sections describe the most frequently used ``make`` commands.
All ``make`` commands that build documentation will
- create a Python virtual environment,
- install requirements,
- initialize or update the `volto`, `plone.restapi`, and `plone.api` submodules, and
- finally create symlinks to the source files.
html
````
To build the documentation as HTML, run the following command.
.. code-block:: shell
source .tox/py311/bin/activate
pip install -r requirements_docs.txt
cd docs
make html
You can now open the output from ``_build/html/index.html``.
You can now open the output from ``docs/_build/html/index.html``.
To build the documentation, view it in a web browser, and automatically reload changes while you edit documentation, use the following command.
livehtml
````````
``livehtml`` rebuilds documentation as you edit its files, with live reload in the browser.
.. code-block:: shell
make livehtml
Then open a web browser at `http://127.0.0.1:8050 <http://127.0.0.1:8050>`_.
The console will give you the URL to open in a web browser.
To build the presentation-version use the following command.
.. code-block:: console
[sphinx-autobuild] Serving on http://127.0.0.1:8050
linkcheckbroken
```````````````
``linkcheckbroken`` checks all links, returning a list of only broken links.
.. code-block:: shell
make presentation
make linkcheckbroken
You can open the presentation at ``presentation/index.html``.
Open `docs/_build/linkcheck/output.txt` for the entire list of links that were checked and their result.
You can also use ``tox`` to build the documentation:
.. For future implementation
.. ### `vale`
.. `vale` checks for American English spelling, grammar, and syntax, and follows the Microsoft Writing Style Guide.
.. See {ref}`authors-english-label` for configuration.
.. .. code-block:: shell
.. make vale
.. See the output on the console for suggestions.
clean
`````
``clean`` removes all builds and cached files of the documentation.
Use this command before a build to troubleshoot issues with edits not showing up and to ensure that cached files do not hide errors in the documentation.
.. code-block:: shell
cd icalendar
tox -e docs
make clean
clean-python
````````````
``clean-python`` cleans the documentation build directory and Python virtual environment.
Use this command when packages that you have installed in your virtual environment yield unexpected results.
.. code-block:: shell
make clean-python

Wyświetl plik

@ -214,10 +214,12 @@ filterwarnings = [
]
[dependency-groups]
dev = [
docs = [
"pydata-sphinx-theme>=0.14.4",
"sphinx>=7",
"sphinx-autobuild>=2021.3.14",
"sphinx-copybutton>=0.5.2",
"sphinx-design>=0.5.0",
"sphinx-reredirects>=0.1.6",
]

Wyświetl plik

@ -1,6 +0,0 @@
Sphinx>=7
pydata-sphinx-theme
sphinx-autobuild
sphinx-copybutton
sphinx-reredirects
.