From 1c21e26d08f636410ddca44c896083b1b203318f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 16 Jan 2022 13:23:09 +0100 Subject: [PATCH] docs: load custom lexer with plain Python import The next commit will load another of our Python extensions from a separate file. That extension will contain more than just a Pygments lexer, so instead of using a function that can only load a lexer, just import from the module to keep things consistent. --- doc_src/conf.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/doc_src/conf.py b/doc_src/conf.py index def07e916..22708e950 100644 --- a/doc_src/conf.py +++ b/doc_src/conf.py @@ -8,8 +8,8 @@ import glob import os.path -import pygments import subprocess +import sys from sphinx.errors import SphinxWarning from docutils import nodes @@ -41,10 +41,10 @@ def setup(app): from sphinx.highlighting import lexers this_dir = os.path.dirname(os.path.realpath(__file__)) - fish_indent_lexer = pygments.lexers.load_lexer_from_file( - os.path.join(this_dir, "fish_indent_lexer.py"), lexername="FishIndentLexer" - ) - lexers["fish-docs-samples"] = fish_indent_lexer + sys.path.insert(0, this_dir) + from fish_indent_lexer import FishIndentLexer + + lexers["fish-docs-samples"] = FishIndentLexer() app.add_config_value("issue_url", default=None, rebuild="html") app.add_role("issue", issue_role) @@ -53,17 +53,6 @@ def setup(app): # The default language to assume highlight_language = "fish-docs-samples" -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - # -- Project information ----------------------------------------------------- project = "fish-shell"