Preparation patches for auto-documenting oecore's library
cover Preparation patches for auto-documenting oecore's library
This series prepares the autobuilder to auto-document functions from the openembedded-core library. For that we need the openembedded-core repo to be available before building, and to be on the correct version.
Depends on yocto-autobuilder2's patch sent here (and the config to be applied on the autobuilder too):
https://lore.kernel.org/r/20261120-run-docs-build-with-oecore-v1-1-75124e549421@bootlin.com
Tested on a local Autobuilder instance.
---
Antonin Godard (4):
scripts/run-docs-build: add openembedded-core as new argument of the script scripts/run-docs-build: checkout closest known ref for oecore/bitbake scripts/run-docs-build: export AUTOBUILDER_BUILD when building the docs scripts/run-docs-build: export bitbake/oecore repository paths
scripts/docsutils/get-bbmapping | 24 +++++++++++++++++++ scripts/run-docs-build | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)
---
base-commit: 7c55f8249e74281d843f3c20453d63774a38c63e
change-id: 20261102-docs-build-oecore-functions-d6c7f2e94576
PATCH 1/4 scripts/run-docs-build: add openembedded-core as new argument of the script
The script should now support openembedded-core as an argument to be able to auto-document library functions in meta/lib/. This directory is passed from yocto-autobuilder2's Buildbot configuration.
--- scripts/run-docs-build | 1 + 1 file changed, 1 insertion(+)
scripts/run-docs-build +1 -0
@@ -24,6 +24,7 @@ set -x builddir=$(realpath "$1") ypdocs=$(realpath "$2/documentation/") bbdocs=$(realpath "$3/doc/") +oecore=$(realpath "$4") outputdir=$builddir/output scriptdir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" PUBLISH=${PUBLISH:-1}
Signature · 1 line
2.56.0
PATCH 2/4 scripts/run-docs-build: checkout closest known ref for oecore/bitbake
In reply to Antonin GodardDefine a checkout_closest_ref function that checks out a given $repo (bitbake or openembedded-core) and tries to checkout $ref (existing ref in yocto-docs). If not found, try to checkout the closest tag to this ref in yocto-docs in $repo.
For bitbake, we have to get the mapping between a Yocto release and a bitbake version: define a simple Python script for that leverages the json Python library to read the already available releases.json file.
--- scripts/docsutils/get-bbmapping | 24 ++++++++++++++++++++++++ scripts/run-docs-build | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
scripts/docsutils/get-bbmapping new file +24 -0
@@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-only +# +# Simple utility script called from run-docs-build, to be able to get the +# mapping between a Yocto release name and a BitBake branch, by parsing the +# releases.json file from https://dashboard.yoctoproject.org/releases.json. +# +# Takes the releases.json file as first argument and branch name as second. +# Prints the mapping when found, or empty string in all other cases. + +import json +import sys + +releases_json_path = sys.argv[1] +branch_name = sys.argv[2] + +with open(sys.argv[1], "r") as fd: + releases = json.load(fd) + +for release in releases: + if branch_name.capitalize() == release.get("release_codename", ""): + print(release.get("bitbake_version", "").strip()) + exit(0)
scripts/run-docs-build +40 -0
@@ -189,6 +189,38 @@ git clean -ffdx export LATEXMKOPTS="-silent" +function checkout_closest_ref() { + # The purpose of this function is to take a ref from yocto-docs (ref=$1) and + # checkout the closes possible ref on given (repo=$2). + # The way it works is by: + # 1. Trying to checkout the same ref on $repo. + # 2. If this fails, look for the tag closest to $ref on yocto-docs (CWD) and + # checkout this tag on $repo. + # If neither work, exit. + local repo="$1" + local ref="$2" + local bbmapping="$3" + + # keep a copy of the original ref for later + docsref="$ref" + if [ -n "$bbmapping" ]; then + ref="$bbmapping" + fi + + if git -C "$repo" rev-parse --verify --quiet "origin/${ref}" >/dev/null; then + echo "Closest ref from $docsref for $repo: origin/$ref" + git -C "$repo" checkout "origin/$ref" + return + fi + ydocs_closest_tag=$(git describe --tags --match "yocto-*" --abbrev=0 "$docsref") + if ! git -C "$repo" rev-parse --verify --quiet "${ydocs_closest_tag}"; then + echo "Tag $ydocs_closest_tag does not exists in $repo, quitting" + exit 1 + fi + echo "Closest ref from $docsref for $repo: $ydocs_closest_tag" + git -C "$repo" checkout "$ydocs_closest_tag" +} + for branch in "$ypdocsbranch" dunfell $(git branch --remote --contains "$first_sphinx_commit" --format '%(refname:lstrip=3)') $(git tag --contains "$first_sphinx_commit" --contains "$first_dunfell_sphinx_commit" 'yocto-*'); do if [ "$branch" = "HEAD" ]; then continue
@@ -215,6 +247,14 @@ for branch in "$ypdocsbranch" dunfell $(git branch --remote --contains "$first_s git reset --hard git clean -ffdx + # Tags/branches before this commit in yocto-docs do not have automatic library + # functions documentation for openembedded-core. + if git merge-base --is-ancestor 2c5846cc2c2649b29de7e7a6ac07fef5c2e7f302 HEAD; then + bbmapping="$("$scriptdir"/docsutils/get-bbmapping "$builddir/releases.json" "$branch")" + checkout_closest_ref "$bbdocs" "$branch" "$bbmapping" + checkout_closest_ref "$oecore" "$branch" "" + fi + if [ -e "${scriptdir}/docs-build-patches/${branch}/" ]; then echo "Adding patch for $branch" git apply -3 "${scriptdir}/docs-build-patches/${branch}/"000*
Signature · 1 line
2.56.0
PATCH 3/4 scripts/run-docs-build: export AUTOBUILDER_BUILD when building the docs
In reply to Antonin Godardyocto-docs reads this variable to perform stricter checks to make sure everything is setup correctly for building the docs. This ensures that docs are built correctly before publishing them. See how it is used in yocto-docs directly.
--- scripts/run-docs-build | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/run-docs-build +6 -0
@@ -21,6 +21,12 @@ set -u set -o pipefail set -x +# yocto-docs reads this variable to perform stricter checks to make sure +# everything is setup correctly for building the docs. This ensures that docs +# are built correctly before publishing them. See how it is used in yocto-docs +# directly. +export AUTOBUILDER_BUILD=1 + builddir=$(realpath "$1") ypdocs=$(realpath "$2/documentation/") bbdocs=$(realpath "$3/doc/")
Signature · 1 line
2.56.0
PATCH 4/4 scripts/run-docs-build: export bitbake/oecore repository paths
In reply to Antonin GodardWhile the Autobuilder default layout is already the one expected by yocto-docs to document docstrings, export the two environment read by yocto-docs in case this layout changes in the future, so we won't forget to update it.
--- scripts/run-docs-build | 5 +++++ 1 file changed, 5 insertions(+)
scripts/run-docs-build +5 -0
@@ -195,6 +195,11 @@ git clean -ffdx export LATEXMKOPTS="-silent" +# These two variables are used by yocto-docs to locate these two repositories +# and document Python docstrings. +export BITBAKE_REPO_PATH="$bbdocs/../" +export OECORE_REPO_PATH="$oecore" + function checkout_closest_ref() { # The purpose of this function is to take a ref from yocto-docs (ref=$1) and # checkout the closes possible ref on given (repo=$2).
Signature · 1 line
2.56.0