Compare commits
No commits in common. "cb52c774be841a43eff3a68b9528835b8d60190d" and "9c2885ce9430c1ab9f4377e0d3ced075d8e7a65e" have entirely different histories.
cb52c774be
...
9c2885ce94
5 changed files with 10 additions and 115 deletions
15
docs/conf.py
15
docs/conf.py
|
|
@ -34,21 +34,6 @@ extensions = [
|
||||||
'ext.xref', 'ext.extinclude'
|
'ext.xref', 'ext.extinclude'
|
||||||
]
|
]
|
||||||
|
|
||||||
#---- disable highlight warnings with yaml new version ----
|
|
||||||
# Configuration pour les blocs de code
|
|
||||||
highlight_language = 'yaml'
|
|
||||||
|
|
||||||
# Options spécifiques pour YAML
|
|
||||||
highlight_options = {
|
|
||||||
'yaml': {
|
|
||||||
'startinline': True
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suppress_warnings = [
|
|
||||||
'misc.highlighting_failure'
|
|
||||||
]
|
|
||||||
|
|
||||||
#---- xref links ----
|
#---- xref links ----
|
||||||
#import the xref.py extension
|
#import the xref.py extension
|
||||||
xref_links = {"link_name" : ("user text", "url")}
|
xref_links = {"link_name" : ("user text", "url")}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.util.docutils import SphinxDirective, SphinxRole
|
from sphinx.util.docutils import SphinxDirective, SphinxRole
|
||||||
|
|
@ -7,8 +8,6 @@ from sphinx.util.typing import ExtensionMetadata
|
||||||
from sphinx.directives.code import LiteralInclude, container_wrapper
|
from sphinx.directives.code import LiteralInclude, container_wrapper
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests.exceptions import RequestException
|
|
||||||
from docutils.parsers.rst import directives
|
|
||||||
|
|
||||||
class ExtInclude(LiteralInclude):
|
class ExtInclude(LiteralInclude):
|
||||||
"""A directive to include code that comes from an url
|
"""A directive to include code that comes from an url
|
||||||
|
|
@ -30,40 +29,12 @@ class ExtInclude(LiteralInclude):
|
||||||
|
|
||||||
def run(self) -> list[nodes.Node]:
|
def run(self) -> list[nodes.Node]:
|
||||||
url = self.arguments[0]
|
url = self.arguments[0]
|
||||||
|
headers = {
|
||||||
try:
|
'accept': 'application/text',
|
||||||
headers = {
|
'Content-Type': 'application/text',
|
||||||
'accept': 'application/text',
|
|
||||||
'Content-Type': 'application/text',
|
|
||||||
}
|
}
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
response.raise_for_status() # This will raise an exception for 4xx/5xx status codes
|
#paragraph_node = nodes.paragraph(text=f'hello {self.arguments[0]}!')
|
||||||
|
|
||||||
except requests.exceptions.HTTPError as e:
|
|
||||||
if response.status_code == 404:
|
|
||||||
error_msg = f"extinclude: URL not found (404): {url}"
|
|
||||||
else:
|
|
||||||
error_msg = f"extinclude: HTTP error {response.status_code}: {url}"
|
|
||||||
|
|
||||||
# Create an error node that will be displayed in the documentation
|
|
||||||
error_node = nodes.error()
|
|
||||||
para = nodes.paragraph()
|
|
||||||
para += nodes.Text(error_msg)
|
|
||||||
error_node += para
|
|
||||||
self.state.document.reporter.warning(error_msg, line=self.lineno)
|
|
||||||
return [error_node]
|
|
||||||
|
|
||||||
except requests.exceptions.RequestException as e:
|
|
||||||
error_msg = f"extinclude: Failed to fetch URL {url}: {str(e)}"
|
|
||||||
|
|
||||||
# Create an error node that will be displayed in the documentation
|
|
||||||
error_node = nodes.error()
|
|
||||||
para = nodes.paragraph()
|
|
||||||
para += nodes.Text(error_msg)
|
|
||||||
error_node += para
|
|
||||||
self.state.document.reporter.warning(error_msg, line=self.lineno)
|
|
||||||
return [error_node]
|
|
||||||
|
|
||||||
code = response.text
|
code = response.text
|
||||||
|
|
||||||
literal = nodes.literal_block(code, code)
|
literal = nodes.literal_block(code, code)
|
||||||
|
|
@ -83,9 +54,12 @@ class ExtInclude(LiteralInclude):
|
||||||
self.add_name(literal)
|
self.add_name(literal)
|
||||||
|
|
||||||
return [literal]
|
return [literal]
|
||||||
|
#paragraph_node = nodes.paragraph(text=content.text)
|
||||||
|
#return [paragraph_node]
|
||||||
|
|
||||||
|
|
||||||
def setup(app: Sphinx) -> ExtensionMetadata:
|
def setup(app: Sphinx) -> ExtensionMetadata:
|
||||||
|
|
||||||
app.add_directive('extinclude', ExtInclude)
|
app.add_directive('extinclude', ExtInclude)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,4 @@
|
||||||
"""adds link url in the global scope
|
"""adds link url in the global scope
|
||||||
|
|
||||||
sample use:
|
|
||||||
|
|
||||||
:xref:`Tiramisu <tiramisu>`
|
|
||||||
|
|
||||||
You must declare in the `conf.py`
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
#---- xref links ----
|
|
||||||
#import the xref.py extension
|
|
||||||
xref_links = {"link_name" : ("user text", "url")}
|
|
||||||
#link_name = "Sphinx External Links"
|
|
||||||
#user_text = "modified External Links Extension"
|
|
||||||
#url = "http://www.sphinx-doc.org/en/stable/ext/extlinks.html"
|
|
||||||
#enables syntax like:
|
|
||||||
" :xref:`tiramisu` "
|
|
||||||
links = {
|
|
||||||
'tiramisu': ('Tiramisu', 'https://tiramisu.readthedocs.io/en/latest/'),
|
|
||||||
'tiramisu library': ('Tiramisu library homepage', 'https://forge.cloud.silique.fr/stove/tiramisu'),
|
|
||||||
}
|
|
||||||
xref_links.update(links)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ After construct a configuration, loads user datas, you can choose this configura
|
||||||
First of create, let's create a structural file like this:
|
First of create, let's create a structural file like this:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
:caption: the :file:`dist/00-base.yml` file content
|
:caption: the :file:`dist/00-base.yml` file content
|
||||||
|
|
||||||
%YAML 1.2
|
%YAML 1.2
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -351,45 +351,6 @@ The constraints that come with the `choice` type
|
||||||
|
|
||||||
We say that the `proxy_mode` variable is *constrained* (by the `choice` type).
|
We say that the `proxy_mode` variable is *constrained* (by the `choice` type).
|
||||||
|
|
||||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_004/config/03/config.yml
|
|
||||||
:linenos:
|
|
||||||
:language: yaml
|
|
||||||
:caption: A user data specification
|
|
||||||
|
|
||||||
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_004/config/03/config.yml>`
|
|
||||||
|
|
||||||
If we run the rougail CLI with this user datas, we have:
|
|
||||||
|
|
||||||
.. code-block:: text
|
|
||||||
:class: terminal
|
|
||||||
|
|
||||||
rougail -m firefox -u yaml -ff config/03/config.yaml
|
|
||||||
|
|
||||||
We have this output:
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_004/config/03/output_ro.html
|
|
||||||
:class: output
|
|
||||||
|
|
||||||
..
|
|
||||||
<pre>╭────────────── Caption ───────────────╮
|
|
||||||
│ Variable Modified value │
|
|
||||||
│ (<span style="color: #00aa00">⏳ Original default value</span>) │
|
|
||||||
╰──────────────────────────────────────╯
|
|
||||||
Variables:
|
|
||||||
<span style="color: #5c5cff">┗━━ </span>📓 Configure Proxy Access to the Internet: Manual proxy configuration ◀ loaded from the YAML file "config/03/config.yml" (⏳ <span style="color: #00aa00">No proxy</span>)
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
As we set the `proxy_mode` variable from a user data file,
|
|
||||||
we now have specified a value which is **not** a default value,
|
|
||||||
and the value appears in green, which means : "user data value".
|
|
||||||
|
|
||||||
.. FIXME: verifier que cette sortie est bonne (on a des valeurs différentes)
|
|
||||||
|
|
||||||
.. type-along:: The constraints that come with the `choice` property
|
|
||||||
|
|
||||||
The `proxy_mode` variable's possible values is *constrained*.
|
|
||||||
|
|
||||||
We have the list of the possible (authorized) values:
|
We have the list of the possible (authorized) values:
|
||||||
|
|
||||||
- `No proxy`
|
- `No proxy`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue