rougail/docs/ext/extinclude.py

33 lines
885 B
Python
Raw Normal View History

2024-10-14 19:17:44 +02:00
from __future__ import annotations
from docutils import nodes
from sphinx.application import Sphinx
from sphinx.util.docutils import SphinxDirective, SphinxRole
from sphinx.util.typing import ExtensionMetadata
2024-10-14 19:28:12 +02:00
from httpx import get
2024-10-14 19:17:44 +02:00
class HelloDirective(SphinxDirective):
"""A directive to say hello!"""
required_arguments = 1
def run(self) -> list[nodes.Node]:
2024-10-14 19:28:12 +02:00
content = get("https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_001/firefox/00-proxy.yml")
#paragraph_node = nodes.paragraph(text=f'hello {self.arguments[0]}!')
paragraph_node = nodes.paragraph(text=content.text)
2024-10-14 19:17:44 +02:00
return [paragraph_node]
def setup(app: Sphinx) -> ExtensionMetadata:
app.add_directive('hello', HelloDirective)
return {
'version': '0.1',
'parallel_read_safe': True,
'parallel_write_safe': True,
}