doc: pytest: Framework for documenting tests and document test_000_version

In order to easily document pytests, we need to include the autodoc
extension. We also need to make sure that for building the docs, CI
includes pytest and that we have PYTHONPATH configured such that it will
find all of the tests and related files. Finally, we need to have our
comments in the test file by in proper pydoc format in order to be
included in the output.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Tom Rini
2025-05-07 16:08:18 -06:00
committed by Heinrich Schuchardt
parent be2bdfd019
commit a865d1d254
7 changed files with 27 additions and 8 deletions

View File

@@ -92,7 +92,7 @@ stages:
set -e set -e
python3 -m venv /tmp/venvhtml python3 -m venv /tmp/venvhtml
. /tmp/venvhtml/bin/activate . /tmp/venvhtml/bin/activate
pip install -r doc/sphinx/requirements.txt pip install -r doc/sphinx/requirements.txt pytest
make htmldocs KDOC_WERROR=1 make htmldocs KDOC_WERROR=1
make infodocs make infodocs

View File

@@ -164,7 +164,7 @@ docs:
script: script:
- python3 -m venv /tmp/venvhtml - python3 -m venv /tmp/venvhtml
- . /tmp/venvhtml/bin/activate - . /tmp/venvhtml/bin/activate
- pip install -r doc/sphinx/requirements.txt - pip install -r doc/sphinx/requirements.txt pytest
- make htmldocs KDOC_WERROR=1 - make htmldocs KDOC_WERROR=1
- make infodocs - make infodocs

View File

@@ -2448,7 +2448,8 @@ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
linkcheckdocs dochelp refcheckdocs texinfodocs infodocs linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
PHONY += $(DOC_TARGETS) PHONY += $(DOC_TARGETS)
$(DOC_TARGETS): scripts_basic FORCE $(DOC_TARGETS): scripts_basic FORCE
$(Q)$(MAKE) $(build)=doc $@ $(Q)PYTHONPATH=$(srctree)/test/py/tests:$(srctree)/test/py \
$(MAKE) $(build)=doc $@
PHONY += checkstack ubootrelease ubootversion PHONY += checkstack ubootrelease ubootversion

View File

@@ -48,7 +48,7 @@ extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
'kfigure', 'sphinx.ext.ifconfig', # 'automarkup', 'kfigure', 'sphinx.ext.ifconfig', # 'automarkup',
'maintainers_include', 'sphinx.ext.autosectionlabel', 'maintainers_include', 'sphinx.ext.autosectionlabel',
'kernel_abi', 'kernel_feat', 'sphinx-prompt', 'kernel_abi', 'kernel_feat', 'sphinx-prompt',
'sphinx_reredirects' ] 'sphinx_reredirects', 'sphinx.ext.autodoc' ]
# #
# cdomain is badly broken in Sphinx 3+. Leaving it out generates *most* # cdomain is badly broken in Sphinx 3+. Leaving it out generates *most*

View File

@@ -10,3 +10,11 @@ General
:maxdepth: 1 :maxdepth: 1
usage usage
Individual tests
----------------
.. toctree::
:maxdepth: 1
test_000_version

View File

@@ -0,0 +1,8 @@
test_000_version
================
.. automodule:: test_000_version
:synopsis:
:member-order: bysource
:members:
:undoc-members:

View File

@@ -2,10 +2,12 @@
# Copyright (c) 2015 Stephen Warren # Copyright (c) 2015 Stephen Warren
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
# pytest runs tests the order of their module path, which is related to the """
# filename containing the test. This file is named such that it is sorted pytest runs tests the order of their module path, which is related to the
# first, simply as a very basic sanity check of the functionality of the U-Boot filename containing the test. This file is named such that it is sorted
# command prompt. first, simply as a very basic sanity check of the functionality of the U-Boot
command prompt.
"""
def test_version(ubman): def test_version(ubman):
"""Test that the "version" command prints the U-Boot version.""" """Test that the "version" command prints the U-Boot version."""