Source code for sphinx_llms_txt_link

import os
import posixpath

from docutils import nodes

__title__ = "sphinx-llms-txt-link"
__version__ = "0.1.2"
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
__copyright__ = "2025 Artur Barseghyan"
__license__ = "MIT"
__all__ = (
    "add_llm_link_node",
    "setup",
    "add_static_path",
)






[docs] def setup(app): app.connect("doctree-resolved", add_llm_link_node) # Inject the CSS file reference into the HTML <head> # Ship the CSS file alongside this extension app.add_css_file("sphinx_llms_txt_link.css") # Standard way for plugins: # Using app.connect('builder-inited', ...) to append to html_static_path app.connect("builder-inited", add_static_path) # format: name, default, rebuild-trigger # 'html' means rebuilding html is required if this changes app.add_config_value("sphinx_llms_txt_link_url_prefix", "", "html") # Config for the text displayed in the link app.add_config_value( "sphinx_llms_txt_link_text", "View llms.txt version", "html", ) return { "version": __version__, "parallel_read_safe": True, "parallel_write_safe": True }
[docs] def add_static_path(app): # This assumes 'assets' is a folder inside the python package # containing sphinx_llms_txt_link.css static_path = os.path.abspath( os.path.join(os.path.dirname(__file__), "assets") ) app.config.html_static_path.append(static_path)