# HG changeset patch # User Franz Glasner # Date 1777363804 -7200 # Node ID 414bf3cbb1520eba3eb53756f75a3326c290f51a # Parent 7153e945a3d6cc625c7675c4c41c8b4227c84078 Add a custom lexer to the Sphinx application dynamically with "no_end" set to True diff -r 7153e945a3d6 -r 414bf3cbb152 docs/conf.py --- a/docs/conf.py Tue Apr 28 10:09:17 2026 +0200 +++ b/docs/conf.py Tue Apr 28 10:10:04 2026 +0200 @@ -4,9 +4,14 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import ast +import functools import io +import os +import sys import re +sys.path.insert(0, os.path.dirname(os.path.abspath('.'))) + # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -50,3 +55,12 @@ html_static_path = ['_static'] #pygments_style = "sphinx" pygments_style = "default" + + +def setup(app): + # Add a custom lexer: AlgPseudocodeLexer with custom init option "no_end" + from pygments_lexer_pseudocode2.algpseudocode import AlgPseudocodeLexer + + # Given lexer must be callable: also use an indirection with "partial" + app.add_lexer("NoEndAlgPseudocode", + functools.partial(AlgPseudocodeLexer, no_end=True))