view docs/conf.py @ 90:2af4684c8e78

Restrict whitespace before required and optional arguments. Instead of "\s*" use explicit allowed whitespace chars (" " and "\t").
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 02 May 2026 14:46:28 +0200
parents 93ade4c595b7
children a861ac4d11fc
line wrap: on
line source

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# 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('.')))

from pygments_lexer_pseudocode2.algpseudocode import AlgPseudocodeLexer


# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Pygments Pseudocode Lexer'
copyright = '2026 Franz Glasner'
author = 'Franz Glasner'
# Determine "release" dynamically from the package's "__version__"
with io.open("../pygments_lexer_pseudocode2/__init__.py",
             "rt",
             encoding="utf-8") as relfp:
    release = ast.literal_eval(
        re.search(r"""^\s*__version__\s*=\s*(("|')[^"']*\2)""",
                  relfp.read(),
                  re.MULTILINE)
        .group(1)
        )
version = release
del relfp


# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    "sphinx.ext.todo",
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# --- Options for todo extension ---------------------------------------------
todo_include_todos = True


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_theme = 'haiku'
html_static_path = ['_static']
#pygments_style = "sphinx"
pygments_style = "default"


def setup(app):
    #
    # Add a custom lexer: AlgPseudocodeLexer with custom init option "no_end"
    # Given lexer must be callable: also use an indirection with "partial"
    #
    app.add_lexer("NoEndAlgPseudocode",
                  functools.partial(AlgPseudocodeLexer, no_end=True))