Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24FDCC531F9 for ; Fri, 24 Jul 2026 13:40:45 +0000 (UTC) Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.19495.1784900443644107343 for ; Fri, 24 Jul 2026 06:40:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=dkim header.b=Vob7H1Qz; spf=pass (domain: bootlin.com, ip: 185.246.85.4, mailfrom: antonin.godard@bootlin.com) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 825F84E40F26; Fri, 24 Jul 2026 13:40:41 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5795C60395; Fri, 24 Jul 2026 13:40:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BB0F611C12509; Fri, 24 Jul 2026 15:40:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784900440; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wcjFt1ex8L0SjyIESGp5T5Odo+inIxVaCm1BBLoASdA=; b=Vob7H1Qz6CzMqHGcCSfXKEv/92LifzkrhxTRSeK/gYa2leSZ0nIVyXJSDeVVeBELlyM1Ny 3AkMfzaS/XGSQVLm/ypbtpDmrv1Ix01LCNyNCE4OJg+DyMY5rDd+QGs0tty3TN4TGrQSqA o+7knDNhhslp97xbg7S8Zwd082pf9SqL/orwI9Dm61jycf7QnxXSVzTmWXyY7zIzFV46Me MS0yPQyIbPOSrhcZnYJf/XqZptYQcSKrnJWg1iJl2o9zCHblOqfnRxS/QIZDTxpgS0I919 vvqLF5fDxyT39gAxzvkyBSYBUOfspXDL2Bd78c4k8M4K8RVvF3thEklOz+gD9g== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 24 Jul 2026 15:40:39 +0200 Message-Id: Subject: Re: [docs] [PATCH v2 3/4] tools: add gen-doc-links to generate documentation link flags Cc: "Thomas Petazzoni" From: "Antonin Godard" To: , References: <20260716-gen-doc-links-intersphinx-v2-0-83cb3aef6ff6@bootlin.com> <20260716-gen-doc-links-intersphinx-v2-3-83cb3aef6ff6@bootlin.com> <9b51a647-76c1-4bbf-b4fe-c9fc57109bc7@cherry.de> In-Reply-To: <9b51a647-76c1-4bbf-b4fe-c9fc57109bc7@cherry.de> X-Last-TLS-Session-Version: TLSv1.3 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 24 Jul 2026 13:40:45 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/docs/message/10139 Hi, On Mon Jul 20, 2026 at 6:39 PM CEST, Quentin Schulz via lists.yoctoproject.= org wrote: > Hi Antonin, > > On 7/16/26 2:18 PM, Antonin Godard via lists.yoctoproject.org wrote: >> The gen-doc-links utility can be used to generate a configuration to be >> included in any project that want to get access to documentation links >> for documented variables. For that it opens the objects.inv file >> generate by our HTML build and creates links for existing variables and >> tasks. >>=20 >> Signed-off-by: Antonin Godard >> --- >> documentation/oecore/doclinks.conf | 1064 ++++++++++++++++++++++++++++= ++++++++ >> documentation/tools/gen-doc-links | 112 ++++ >> 2 files changed, 1176 insertions(+) >>=20 > [...] >> diff --git a/documentation/tools/gen-doc-links b/documentation/tools/gen= -doc-links >> new file mode 100755 >> index 000000000..11b3ef858 >> --- /dev/null >> +++ b/documentation/tools/gen-doc-links >> @@ -0,0 +1,112 @@ >> +#!/usr/bin/env python3 >> +# >> +# SPDX-License-Identifier: MIT >> +# >> +# Author: Antonin Godard >> +# >> +# Copyright (C) 2026 Bootlin >> +# >> + >> +import argparse >> +import sys >> + >> +from pathlib import Path >> +from sphinx.util.inventory import InventoryFile >> + >> + >> +YOCTO_DOCS_URL =3D "https://docs.yoctoproject.org/${LAYERSERIES_COMPAT_= core}" >> +BITBAKE_DOCS_URL =3D "https://docs.yoctoproject.org/bitbake/${LAYERSERI= ES_COMPAT_core}" > > Sorry for the mangled link, but this is invalid. We only have bitbake=20 > version number, and not Yocto release name so this won't work. /o\ you're right=E2=80=A6 good catch. Perhaps this will have to depend on t= he releases.json file which contains the mapping. >> +DOCS_DIR =3D Path(__file__).parent.parent >> +PREAMBLE =3D """# >> +# This file is automatically generated with tools/gen-doc-links, do not= edit manually. >> +# >> +""" >> +YOCTO_DOCS_SECTION =3D """ >> +# yocto-docs >> + >> +""" >> +BITBAKE_SECTION =3D """ >> +# bitbake >> + >> +""" >> + >> + >> +def parse_arguments() -> argparse.Namespace: >> + parser =3D argparse.ArgumentParser(description=3D"Generate glossari= es from Sphinx text output") >> + >> + parser.add_argument("--yocto-docs-inv", >> + type=3DPath, >> + default=3DDOCS_DIR / "_build/html/objects.inv", >> + help=3D"Input yocto-docs inventory file") >> + >> + parser.add_argument("--bitbake-inv", >> + type=3DPath, >> + default=3DDOCS_DIR / "_build/doctrees/__intersp= hinx_cache__/bitbake_objects.inv", >> + help=3D"Input bitbake inventory file") >> + >> + parser.add_argument("-o", "--output", >> + type=3DPath, >> + default=3DDOCS_DIR / "oecore/doclinks.conf", >> + help=3D"Output doclinks.conf file") >> + >> + return parser.parse_args() >> + >> + >> +def doclink(name: str, uri) -> str: >> + return f'{name}[doclink] =3D "{uri}"\n' >> + >> + >> +def main(): >> + args =3D parse_arguments() >> + >> + yocto_docs_dict =3D {} >> + >> + if not args.yocto_docs_inv.exists(): >> + print(f"yocto-docs inventory not found at {args.yocto_docs_inv}= , " >> + "use the --yocto-docs-inv option or set YOCTO_DOCS_INV_PA= TH " >> + "in your environment") >> + sys.exit(0) >> + >> + if not args.bitbake_inv.exists(): >> + print(f"bitbake inventory not found at {args.yocto_docs_inv}, " >> + "use the --bitbake-inv option or set BITBAKE_INV_PATH " >> + "in your environment") >> + sys.exit(0) > > Don't you want to sys.exit(1) here (and above) instead to show the user= =20 > this is an error? I did not want to block creating a commit because the docs wasn't built. I looked a bit at it and pre-commit does not have a special error code that could signify a SKIP. >> + >> + yocto_docs_data =3D args.yocto_docs_inv.read_bytes() >> + yocto_docs_inv =3D InventoryFile.loads(yocto_docs_data, uri=3DYOCTO= _DOCS_URL) >> + >> + yocto_docs_uris =3D ( >> + f"{YOCTO_DOCS_URL}/ref-manual/variables.html#term-", >> + f"{YOCTO_DOCS_URL}/ref-manual/tasks.html#term-", >> + ) >> + >> + for key in sorted(yocto_docs_inv.data): >> + inv_entries =3D sorted(yocto_docs_inv.data[key].items()) >> + for entry, inv_item in inv_entries: >> + if inv_item.uri.startswith(yocto_docs_uris): >> + yocto_docs_dict[entry] =3D inv_item.uri >> + >> + bitbake_dict =3D {} >> + bitbake_data =3D args.bitbake_inv.read_bytes() >> + bitbake_inv =3D InventoryFile.loads(bitbake_data, uri=3DBITBAKE_DOC= S_URL) >> + >> + bitbake_uris =3D ( >> + f"{BITBAKE_DOCS_URL}/bitbake-user-manual/bitbake-user-manual-re= f-variables.html#term-", >> + ) >> + >> + for key in sorted(bitbake_inv.data): >> + inv_entries =3D sorted(bitbake_inv.data[key].items()) >> + for entry, inv_item in inv_entries: >> + if inv_item.uri.startswith(bitbake_uris) and entry not in y= octo_docs_dict: >> + bitbake_dict[entry] =3D inv_item.uri >> + > > 1. Does the uri need to be YOCTO_DOCS_URL? We only need to have it in=20 > the output file, which we can add in the write calls below. But we could= =20 > also simply have the empty ('') string. This should make it faster to=20 > compare (fewer letters to compare against). True, that's what I did first but then changed it. I'll revert that. > 2. Why do we need to check that it startswith()? I'm assuming you want=20 > to avoid the ref-manual/terms.html entries? Please document this with a= =20 > comment. Will do. > 3. Can't you avoid the first for-loop and directly iterate over=20 > bitbake_inv.data['std:term'].items() since that's the only thing we're=20 > interested in? Good point, I'll simplify that. >> + with open(args.output, "w") as links_conf: >> + links_conf.write(PREAMBLE) >> + links_conf.write(YOCTO_DOCS_SECTION) >> + [links_conf.write(doclink(name, uri)) for name, uri in yocto_do= cs_dict.items()] >> + links_conf.write(BITBAKE_SECTION) >> + [links_conf.write(doclink(name, uri)) for name, uri in bitbake_= dict.items()] > > I'm also a bit concerned about the use of $(LAYERSERIES_COMPAT_core} as= =20 > this may induce some mismatch between what OE-Core is at and the version= =20 > used to generate this file. We may actually document a variable that=20 > shouldn't be used anymore, or that isn't accessible yet due to a=20 > different major version being used. We do know what we're building the=20 > docs for (c.f. conf.py) so maybe we should hardcode that? I did not think of simply using the current version of the documentation an= d hardcore that in the file. It's actually probably safer, I agree. I'll see = how I can change that, thanks! Antonin