Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff docs/conf.py @ 63:414bf3cbb152
Add a custom lexer to the Sphinx application dynamically with "no_end" set to True
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 28 Apr 2026 10:10:04 +0200 |
| parents | 0ff291eac663 |
| children | 93ade4c595b7 |
line wrap: on
line diff
--- 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))
