From patchwork Thu Nov 26 22:36:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Woerner X-Patchwork-Id: 105800 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.6921.1795732615755762706 for ; Thu, 26 Nov 2026 14:36:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=jpZcsD4M; spf=pass (domain: gmail.com, ip: 209.85.219.47, mailfrom: twoerner@gmail.com) Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-9217fbf97fbso17895976d6.2 for ; Thu, 26 Nov 2026 14:36:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795732615; x=1796337415; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=QO4ScvIJJqjHwj4Nau2oY0xE0pWJ/+ZfXD1Ld+ZUcJk=; b=jpZcsD4M4lyK8qLbnkwbYyYfJ8vZLweVEzawhqleZP0tYwMfCW5xXIakYVPTFZiajM YDr9WqYWcBlcDwW47uQ5d923gqp3uxExSr/pZkVgKuPAK8koF51ZSPR7HfjIjKntfGvC uQGjhZxZC3cD91gQXxXq36pgGE8a08WPXRBMR2ByQBIJxoQaYv/RjLivwU2xFElY+KIT KkuNZW5Y5CIlc62pvrT5O9iXg+rKXNHshXFYyxYVNpdPNY/RLhYfCddbeznKvFPMAlnD m8QiCS9HBC+7k8p5HMOtkRd2QJ33ht2tUQFnxth4FJQjm2LnE0kTjmLDTKGBWIGmnJx0 zM3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795732615; x=1796337415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=QO4ScvIJJqjHwj4Nau2oY0xE0pWJ/+ZfXD1Ld+ZUcJk=; b=gqS30vlyXqR597XHcshi4O1FqojKnGtpEE53MrpYc5PB5N0GSUdx8rqoVZUkGYtUl0 OUzU4HyGM/DYeaSWc8sErDUNG8S75wkg6MsLv2uD30mNBNv6Lkg9jqrhOTpfKcPxtKgC C3sUnIHivw1SdhSpoazq9Hhy+xOahL1i6fw1ZuZePzA1RKExHH55fio0oy46i+O9h4+s XcH3UttZnj7jSQSbac9AR8G0OjukMZkS5n0KhTK4gDtXxG5zpUjhK20Ea1Dqv3hXg3vM o3bZTLbfK5dIYi9EUX0J88VPOJrdG+27EtUd/YOEhN+IJxW+YUFwhKTTRlLlC36GODNE 9H+A== X-Gm-Message-State: APuU4Z9CFNpVe6ZZPA6aol3cnih2NEhN0qKzpRxmXUSokexOkoNewCsT /r5TAn9lKDPqLR7tVqMg3hEHKBM6Fao1HE6YKNnIWWDUu2fS744NqSVt7iDaXQ== X-Gm-Gg: AZFdTZeM5eCXZus+INxzYgKoX0ubBhRLNZCqXy5g+KtZUIfssSeeYfMzyP6IvV5E0nl XLVvW5+yM6WHao/vmpID+u8+SWLjmLHJU2rNyEM+G1oFC7UizZ9S04HP7oCW9FAlGvOCFFL3PxS 7cWJoh3JbX1cTAp6E5RvOKbMpzn23/SCuSKd+ENt0mpQkyocbK7uDS8rkwTTROqO8k/CtHK2FWa 4s1YFQVc8/y87ZZriLzgpaO3RnGwI9cLQ6kaevfltrIDZySweD4Si9ejZr8NMx3aLuPsCqxxGKv pIDaB9gAyzdr2hZ8wHZKmnusC+NTMqxzdqaXz5T+irURCy8Px5TEa1cuAewDryJDYlU0DA1KUEh 07P/vnh4udIBd3BHXzxWxpTIBac1j2F4jQBMpYhda33byzeiRrwKZergc3VCeNhbTDX/ux8Pmd8 8P8ErreV2XojotF2f3Q/vj8Zj4H1Ncd5RPhwhIWxba64QZel6igzJ/8ZWkMw+k/snfzHiAX2dd2 CIPtANB9LqaoaGBA/aBZim2ZKtz3xcpN5U+qKCyrhL5dE9EaWWny8jkHG5iT6C+4uQU/EvVjZRr d0f0B7GiDHxwtZtXBsRIGRnqQXhBxo8vhaaWyEb81jC8uxh/Ze+ZpO0vgV3Nh8sdD3OGJH63MhR 8EgF9j5fR9XDm00m6XFoSdMuZT1PWYf8= X-Received: by 2002:a05:6214:4890:b0:921:7be2:a720 with SMTP id 6a1803df08f44-9217be2a9f4mr111873136d6.33.1795732614673; Thu, 26 Nov 2026 14:36:54 -0800 (PST) Return-Path: Received: from localhost.localdomain (pppoe-209-91-167-254.vianet.ca. [209.91.167.254]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349ec64csm201742136d6.28.2026.11.26.14.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 14:36:53 -0800 (PST) From: Trevor Woerner To: docs@lists.yoctoproject.org Subject: [PATCH v2 1/2] sphinx: add a lexer for wic kickstart files Date: Thu, 26 Nov 2026 17:36:49 -0500 Message-ID: <20261126223650.3701672-2-twoerner@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261126223650.3701672-1-twoerner@gmail.com> References: <20261126223650.3701672-1-twoerner@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 26 Nov 2026 22:36:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/docs/message/10847 The manuals show .wks files in several places and have no language for them, so they are tagged text, tagged shell, or left to the default. Shell comes closest, because wic splits each line with shlex and expands ${VAR} before parsing, but it does not know the vocabulary: the "part" opening a line and every option come out as ordinary text. This extends the bash lexer to mark the statements and long options that wic's own parser registers. AI-Generated: codex/claude-opus 5.5 (xhigh) Signed-off-by: Trevor Woerner --- changes in v2: - rebase on master, where conf.py no longer lists the dropped lexers --- documentation/conf.py | 3 +- documentation/sphinx/wks-lexer.py | 60 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 documentation/sphinx/wks-lexer.py diff --git a/documentation/conf.py b/documentation/conf.py index d2252d5ab966..8992496f7569 100644 --- a/documentation/conf.py +++ b/documentation/conf.py @@ -51,7 +51,8 @@ extensions = [ 'sphinx.ext.intersphinx', 'sphinx_copybutton', 'sphinxcontrib.rsvgconverter', - 'yocto-vars' + 'yocto-vars', + 'wks-lexer' ] # current_version = "dev" diff --git a/documentation/sphinx/wks-lexer.py b/documentation/sphinx/wks-lexer.py new file mode 100644 index 000000000000..1e5e5ec1e5b9 --- /dev/null +++ b/documentation/sphinx/wks-lexer.py @@ -0,0 +1,60 @@ +"""A lexer for wic kickstart (.wks) files. + +wic reads a .wks file line by line: a line whose first non-blank +character is ``#`` is a comment, and every other line is split with +``shlex.split`` and handed to ``argparse``, after ``${VAR}`` has been +expanded. The quoting is therefore shell quoting, which is why this +extends the bash lexer. What the bash lexer cannot do is mark the +vocabulary: ``part`` is not a shell builtin, so the statement opening +each line comes out as ordinary text, and so does every ``--option``. + +The statements and options below are taken from wic's parser, +``ksparser.py``, rather than from the manual, so update them from there +when wic gains one. ``partition`` is not a statement: it was an alias +while wic bundled pykickstart, and the parser that replaced it in 2016 +kept only ``part``. +""" +from pygments.lexer import bygroups, inherit +from pygments.lexers.shell import BashLexer +from pygments.token import Comment, Keyword, Name, Text, Whitespace + +__version__ = '1.0' + +# The subparsers wic registers. +STATEMENTS = ('part', 'bootloader', 'include') + + +class WksLexer(BashLexer): + """wic kickstart.""" + + name = 'wic kickstart' + aliases = ['wks'] + filenames = ['*.wks', '*.wks.in'] + mimetypes = [] + + tokens = { + 'root': [ + # A statement is only a statement at the start of a line. + # Anchoring matters: "include" is also an ordinary word in + # "--include-path", and "part" appears inside several option + # names, so an unanchored keyword would mark both. + (r'^(\s*)(%s)(\b)' % '|'.join(STATEMENTS), + bygroups(Whitespace, Keyword, Text)), + # Long options carry the meaning on a wic line; bash leaves + # them as plain text because it has no notion of them. + (r'--[\w-]+', Name.Attribute), + # wic tests the first character of the stripped line, so a + # comment may be indented and is never trailing. + (r'^\s*#.*$', Comment.Single), + inherit, + ], + } + + +def setup(app): + app.add_lexer('wks', WksLexer) + return { + 'version': __version__, + 'parallel_read_safe': True, + 'parallel_write_safe': True, + } From patchwork Thu Nov 26 22:36:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Woerner X-Patchwork-Id: 105799 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.6922.1795732616878624283 for ; Thu, 26 Nov 2026 14:36:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=C0eQtKey; spf=pass (domain: gmail.com, ip: 209.85.219.54, mailfrom: twoerner@gmail.com) Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-92157f2e8c1so58580666d6.1 for ; Thu, 26 Nov 2026 14:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795732616; x=1796337416; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=P1OWVU62l40giFw7hio7PLhjDGYJ4BA0AF2/wBaUbfc=; b=C0eQtKey1GqaURF0OTjha99GFx2Yjwo0jJQV02OmGUdadAHPhSfFlb5tnprffYNf1T Wsi8t+JRg9/x/Edo9lsdFozs+rRalm+xkXy2g/zEgezoNmJhmShk5EQkuCa3JjaMeqAs 80fxP12odSJbrXBPMyfjYY712HTYP4aQoXL0cGKsvL4jaFBCtam6n80KVdzW3fYvbz8h bOfliTaJNzvc4Q7BsKtFrmvIboGPtbTtGC7v32i3bjW+WcVWR/YsqBsXZSdrzfp7jWT2 glfY30El7+Y1gCENuiMve3dgTZvXPPB+ufBCHLdbDKxXKv444s/tV2YdlssNMTuQb4QK z5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795732616; x=1796337416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=P1OWVU62l40giFw7hio7PLhjDGYJ4BA0AF2/wBaUbfc=; b=w1DUhHwO2bEtJHqISu59H+kGSzsgHNjd3crtDsuGjRpP99tRmPMPsI6yAdxsvuZXGZ bGzwBxThET9Xdykp6G+R4z9ytrsxZ+z6EUdGMT1bjEm3qj99KR2cU4/X6iUvManxNIlk 6QbT1Kd3g73yxJYKltqfTwLwZX5lS7s1iU8K10QCvcfCes9aUhfcmQPdlFJcFLEYt549 Jvnrj52/HRVPPHaFU7nGduxgOE3dug61nn5rdFhNKCruz6pPxfzHSAmMLPByf1wf9171 oy7t/sn4UfEMtU129dv065DfbuV1KHIENbCNw3zu/bXS+u64Ekr5jsI16bVfO6UJJOcd LCDQ== X-Gm-Message-State: APuU4Z9JIGkcBbcmhKzpxlYqokR7+NXVgvy+c7QgifR7iGAjraTjw5bX JcwX7AKQUW27J57YLzaZuebbz8Teq166NDFwnT04oz5GUV/wAPIgEki0MG9NWA== X-Gm-Gg: AZFdTZcU4I6Ak4Qwi5XujB9BQKrh5F/Kt+khJPrW/OKpP6Z0y6XgLIA1ycJMtOfcr1s uBWsxU6ZVH/1hbMyLGKryMkZehRuRUn/o9wBqmjooD46emh3PBBpj2HQxvtdmKaJunMV0TK0lR6 mllR/qrjmJCsP2WsLTnILldgLNBLa6PEm0ndmS6+2UEf0xkTR85RqQPoOQexfvjmtTgLhE9Zh3A QCxnaFwkST9FUkS7lx1RMKFyhnIqbxHiXi1AvO/fVzP6t5yu+h3yef4oJEuAUUD/GeTYyno2bE8 HQXe5/LXx1giPWOyrxUWL2Ygput9hYv3vgGZvSyT9kMEfInxecwoKGfkzUBpTaGk/B3+sC+LSQJ 8k9IhntWoFXtqdX9ZYXiVg3NFDJScFslarIw4PuYPNYl292L54NxTHUaeofiLy1SVZsCPdJobkT y9DAmkbq1yyAxWCp20jwq9H/4HUXxJfDMI6tcc1rGaLE7evdSzDjO46nxXG0bBsMPplzrGkyu4q TQnSYSfmPQFaJAz1huAB20ZEXq7pOJhw0MRhjbZpmYdLRJP+n5h6uxtwUdehqvvDKfgfj4jSwSc 5Hi7IvQjx5rfGZ3g6I65ahe5rCs3YziloUHl6BAnqkSPbzLwPhsywNUsg4VGWDxIKqkIA+qNjDT +tYTKeINUhwYUqtCFP1eqrahGpx/uxPw= X-Received: by 2002:a05:6214:1943:b0:921:4cf4:5472 with SMTP id 6a1803df08f44-9214cf4550emr318283046d6.18.1795732615734; Thu, 26 Nov 2026 14:36:55 -0800 (PST) Return-Path: Received: from localhost.localdomain (pppoe-209-91-167-254.vianet.ca. [209.91.167.254]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349ec64csm201742136d6.28.2026.11.26.14.36.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 14:36:55 -0800 (PST) From: Trevor Woerner To: docs@lists.yoctoproject.org Subject: [PATCH v2 2/2] sphinx: add a lexer for pydevshell sessions Date: Thu, 26 Nov 2026 17:36:50 -0500 Message-ID: <20261126223650.3701672-3-twoerner@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20261126223650.3701672-1-twoerner@gmail.com> References: <20261126223650.3701672-1-twoerner@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 26 Nov 2026 22:36:59 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/docs/message/10848 The development manual shows a session in BitBake's Python development shell, and no lexer reads it: console wants a prompt ending in $, #, or %, pycon wants >>>, and both mark the whole block as program output, which the theme greys. The prompt cannot be changed to suit them either, since devshell.bbclass is what sets it. Teach a session lexer the prompt instead, with Python inside it, so the expressions the reader types are highlighted as Python and the results are not. AI-Generated: codex/claude-opus 5.5 (xhigh) Signed-off-by: Trevor Woerner --- changes in v2: - rebase on master, where conf.py no longer lists the dropped lexers --- documentation/conf.py | 3 +- documentation/sphinx/pydevshell-lexer.py | 48 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 documentation/sphinx/pydevshell-lexer.py diff --git a/documentation/conf.py b/documentation/conf.py index 8992496f7569..7d0e103042fd 100644 --- a/documentation/conf.py +++ b/documentation/conf.py @@ -52,7 +52,8 @@ extensions = [ 'sphinx_copybutton', 'sphinxcontrib.rsvgconverter', 'yocto-vars', - 'wks-lexer' + 'wks-lexer', + 'pydevshell-lexer' ] # current_version = "dev" diff --git a/documentation/sphinx/pydevshell-lexer.py b/documentation/sphinx/pydevshell-lexer.py new file mode 100644 index 000000000000..a0dd7c9fa684 --- /dev/null +++ b/documentation/sphinx/pydevshell-lexer.py @@ -0,0 +1,48 @@ +"""Lexer for ``bitbake -c pydevshell`` sessions. + +The development manual shows a session in BitBake's Python development +shell: expressions typed at a ``pydevshell> `` prompt with their results +beneath. No existing lexer reads it. ``console`` is a shell session and +wants a prompt ending in ``$``, ``#``, or ``%``; ``pycon`` wants ``>>>``. +Both mark the whole block as program output, which the theme renders in +grey, so the block ends up dimmer than the prose around it and no better +told apart. + +The prompt is not ours to change: ``devshell.bbclass`` sets +``ps1 = "pydevshell> "``, so what the manual shows is what the reader +sees. That leaves teaching a lexer the prompt as the only way to render +one of these correctly. + +``ShellSessionBaseLexer`` does the work once ``_ps1rgx`` matches: it +splits the typed line from its output and hands the typed part to an inner +lexer, which here is Python. +""" +import re + +from pygments.lexers.python import PythonLexer +from pygments.lexers.shell import ShellSessionBaseLexer + +__version__ = '1.0' + + +class PyDevShellSessionLexer(ShellSessionBaseLexer): + """A session in BitBake's Python development shell.""" + + name = 'BitBake pydevshell session' + aliases = ['pydevshell'] + filenames = [] + mimetypes = [] + url = 'https://docs.yoctoproject.org/dev-manual/python-development-shell.html' + + _innerLexerCls = PythonLexer + _ps1rgx = re.compile(r'^(pydevshell> )(.*\n?)') + _ps2 = '... ' + + +def setup(app): + app.add_lexer('pydevshell', PyDevShellSessionLexer) + return { + 'version': __version__, + 'parallel_read_safe': True, + 'parallel_write_safe': True, + }