From 4d51b4584d94c1a5a11fcfc96864458862ddcb07 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Strub Date: Wed, 4 Feb 2026 19:12:02 +0100 Subject: [PATCH] documentation: Sphinx: change default role to code:easycrypt The default role (`xxx`) is now set to the EasyCrypt code highlighter. --- doc/_static/easycrypt.css | 9 +++++++++ doc/conf.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 doc/_static/easycrypt.css diff --git a/doc/_static/easycrypt.css b/doc/_static/easycrypt.css new file mode 100644 index 000000000..5c5bba266 --- /dev/null +++ b/doc/_static/easycrypt.css @@ -0,0 +1,9 @@ +/* Keep EasyCrypt inline role neutral (inherit text color). */ +code.easycrypt, +code.code.easycrypt, +code.code.highlight.easycrypt, +span.easycrypt, +span.code.easycrypt, +span.code.highlight.easycrypt { + color: inherit; +} diff --git a/doc/conf.py b/doc/conf.py index a2358b6a6..568857a10 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -8,7 +8,9 @@ import pathlib import sys +from docutils.parsers.rst import roles from sphinx.util import logging as sphinx_logging +from sphinx.roles import code_role # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -32,6 +34,7 @@ ] highlight_language = 'easycrypt' +default_role = 'easycrypt' templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] @@ -56,3 +59,16 @@ html_theme = 'sphinx_rtd_theme' html_static_path = ['_static'] +html_css_files = [ + 'easycrypt.css', +] + +# -- EasyCrypt role ---------------------------------------------------------- +def _easycrypt_role(name, rawtext, text, lineno, inliner, options=None, content=()): + options = {} if options is None else options.copy() + options['language'] = 'easycrypt' + return code_role(name, rawtext, text, lineno, inliner, options, content) + +# -- Setup app --------------------------------------------------------------- +def setup(app): + app.add_role('easycrypt', _easycrypt_role)