From: "Antonin Godard" <antonin.godard@bootlin.com>
To: <twoerner@gmail.com>, <docs@lists.yoctoproject.org>
Subject: Re: [docs] [PATCH v2 2/2] sphinx: add a lexer for pydevshell sessions
Date: Fri, 27 Nov 2026 09:10:33 +0100 [thread overview]
Message-ID: <DN5UAAGPMBRN.1JXZ9W6JD6NPH@bootlin.com> (raw)
In-Reply-To: <20261126223650.3701672-3-twoerner@gmail.com>
On Thu Nov 26, 2026 at 11:36 PM CET, Trevor Woerner via docs wrote:
> 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 <twoerner@gmail.com>
> ---
> 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 = '... '
What's _ps2 here and what's its purpose?
Antonin
next prev parent reply other threads:[~2026-11-27 8:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 22:36 [PATCH v2 0/2] sphinx: add lexers for wic kickstart files and pydevshell sessions Trevor Woerner
2026-11-26 22:36 ` [PATCH v2 1/2] sphinx: add a lexer for wic kickstart files Trevor Woerner
2026-11-26 22:36 ` [PATCH v2 2/2] sphinx: add a lexer for pydevshell sessions Trevor Woerner
2026-11-27 8:10 ` Antonin Godard [this message]
2026-11-27 11:57 ` [docs] " Trevor Woerner
2026-11-27 8:10 ` [docs] [PATCH v2 0/2] sphinx: add lexers for wic kickstart files and " Antonin Godard
2026-11-27 12:03 ` Trevor Woerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DN5UAAGPMBRN.1JXZ9W6JD6NPH@bootlin.com \
--to=antonin.godard@bootlin.com \
--cc=docs@lists.yoctoproject.org \
--cc=twoerner@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox