comparison 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
comparison
equal deleted inserted replaced
62:7153e945a3d6 63:414bf3cbb152
2 # 2 #
3 # For the full list of built-in configuration values, see the documentation: 3 # For the full list of built-in configuration values, see the documentation:
4 # https://www.sphinx-doc.org/en/master/usage/configuration.html 4 # https://www.sphinx-doc.org/en/master/usage/configuration.html
5 5
6 import ast 6 import ast
7 import functools
7 import io 8 import io
9 import os
10 import sys
8 import re 11 import re
12
13 sys.path.insert(0, os.path.dirname(os.path.abspath('.')))
9 14
10 # -- Project information ----------------------------------------------------- 15 # -- Project information -----------------------------------------------------
11 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 16 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
12 17
13 project = 'Pygments Pseudocode Lexer' 18 project = 'Pygments Pseudocode Lexer'
48 html_theme = 'alabaster' 53 html_theme = 'alabaster'
49 html_theme = 'haiku' 54 html_theme = 'haiku'
50 html_static_path = ['_static'] 55 html_static_path = ['_static']
51 #pygments_style = "sphinx" 56 #pygments_style = "sphinx"
52 pygments_style = "default" 57 pygments_style = "default"
58
59
60 def setup(app):
61 # Add a custom lexer: AlgPseudocodeLexer with custom init option "no_end"
62 from pygments_lexer_pseudocode2.algpseudocode import AlgPseudocodeLexer
63
64 # Given lexer must be callable: also use an indirection with "partial"
65 app.add_lexer("NoEndAlgPseudocode",
66 functools.partial(AlgPseudocodeLexer, no_end=True))