Markdown (myst) and sphinx

Avertissement

« …recommonmark is going to be deprecated, and the community is encouraged to move to MyST… »

The community is encouraged to move to MyST

How to start

This conf.py file

  1# Configuration file for the Sphinx documentation builder.
  2#
  3# This file only contains a selection of the most common options. For a full
  4# list see the documentation:
  5# http://www.sphinx-doc.org/en/master/config
  6# -- Path setup --------------------------------------------------------------
  7# If extensions (or modules to document with autodoc) are in another directory,
  8# add these directories to sys.path here. If the directory is relative to the
  9# documentation root, use os.path.abspath to make it absolute, like shown here.
 10#
 11# import os
 12# import sys
 13# sys.path.insert(0, os.path.abspath('.'))
 14import platform
 15from datetime import datetime
 16from zoneinfo import ZoneInfo
 17
 18import sphinx
 19import sphinx_material
 20
 21# If extensions (or modules to document with autodoc) are in another directory,
 22# add these directories to sys.path here. If the directory is relative to the
 23# documentation root, use os.path.abspath to make it absolute, like shown here.
 24# sys.path.insert(0, os.path.abspath("./src"))
 25
 26
 27project = "Documentation formats"
 28html_title = project
 29
 30author = f"DevOps people"
 31html_logo = "images/documentation.png"
 32html_favicon = "images/documentation.png"
 33release = "0.1.0"
 34now = datetime.now(tz=ZoneInfo("Europe/Paris"))
 35version = f"{now.year}-{now.month:02}-{now.day:02} {now.hour:02}H ({now.tzinfo})"
 36today = version
 37
 38extensions = [
 39    "sphinx.ext.autodoc",
 40    "sphinx.ext.doctest",
 41    "sphinx.ext.extlinks",
 42    "sphinx.ext.intersphinx",
 43    "sphinx.ext.todo",
 44    "sphinx.ext.mathjax",
 45    "sphinx.ext.viewcode",
 46    "sphinx_copybutton",
 47]
 48
 49# https://sphinx-design.readthedocs.io/en/furo-theme/get_started.html
 50extensions.append("sphinx_design")
 51
 52
 53# Add any paths that contain templates here, relative to this directory.
 54templates_path = ["_templates"]
 55exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
 56html_static_path = ["_static"]
 57html_show_sourcelink = True
 58html_sidebars = {
 59    "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]
 60}
 61extensions.append("sphinx_material")
 62html_theme_path = sphinx_material.html_theme_path()
 63html_context = sphinx_material.get_html_context()
 64html_theme = "sphinx_material"
 65
 66extensions.append("sphinx_design")
 67
 68extensions.append("sphinx.ext.intersphinx")
 69intersphinx_mapping = {
 70    "sphinx": ("https://www.sphinx-doc.org/en/master", None),
 71    "python": ("https://docs.python.org/", None),
 72    "tuto_python": ("https://gdevops.frama.io/python/tuto/", None),
 73    "tuto_doc": ("https://gdevops.frama.io/documentation/tuto", None),
 74    "doc_news": ("https://gdevops.frama.io/documentation/news", None),
 75    "tuto_css": ("https://gdevops.frama.io/web/tuto-css/", None),
 76    "tuto_django": ("https://gdevops.frama.io/django/tuto/", None),
 77    "blockdiag": ("http://blockdiag.com/en/", None),
 78    "tuto_sphinx": ("https://gdevops.frama.io/documentation/sphinx", None),
 79}
 80extensions.append("sphinx.ext.todo")
 81todo_include_todos = True
 82
 83
 84# material theme options (see theme.conf for more information)
 85# https://gitlab.com/bashtage/sphinx-material/blob/master/sphinx_material/sphinx_material/theme.conf
 86# Colors
 87# The theme color for mobile browsers. Hex color.
 88# theme_color = #3f51b5
 89# Primary colors:
 90# red, pink, purple, deep-purple, indigo, blue, light-blue, cyan,
 91# teal, green, light-green, lime, yellow, amber, orange, deep-orange,
 92# brown, grey, blue-grey, white
 93# Accent colors:
 94# red, pink, purple, deep-purple, indigo, blue, light-blue, cyan,
 95# teal, green, light-green, lime, yellow, amber, orange, deep-orange
 96# color_accent = blue
 97# color_primary = blue-grey
 98
 99# material theme options (see theme.conf for more information)
100html_theme_options = {
101    "base_url": "https://gdevops.frama.io/documentation/formats",
102    "repo_url": "https://framagit.org/gdevops/documentation/formats",
103    "repo_name": project,
104    "html_minify": False,
105    "html_prettify": True,
106    "css_minify": True,
107    "globaltoc_depth": -1,
108    "repo_type": "gitlab",
109    "color_primary": "green",
110    "color_accent": "cyan",
111    "theme_color": "#2196f3",
112    "nav_title": f"{project} ({today})",
113    "master_doc": False,
114    "nav_links": [
115        {
116            "href": "genindex",
117            "internal": True,
118            "title": "Index",
119        },
120        {
121            "href": "https://gdevops.frama.io/documentation/linkertree",
122            "internal": False,
123            "title": "Liens documentation",
124        },
125        {
126            "href": "https://gdevops.frama.io/web/linkertree/",
127            "internal": False,
128            "title": "Liens Web",
129        },
130        {
131            "href": "https://linkertree.frama.io/pvergain/",
132            "internal": False,
133            "title": "Liens pvergain",
134        },
135    ],
136    "heroes": {
137        "index": "Documentation formats",
138    },
139    "table_classes": ["plain"],
140}
141# https://github.com/sphinx-contrib/yasfb
142extensions.append("yasfb")
143feed_base_url = html_theme_options["base_url"]
144feed_author = "Scribe"
145# https://sphinx-design.readthedocs.io/en/furo-theme/get_started.html
146extensions.append("sphinx_design")
147# https://sphinx-tags.readthedocs.io/en/latest/quickstart.html#installation
148extensions.append("sphinx_tags")
149tags_create_tags = True
150# Whether to display tags using sphinx-design badges.
151tags_create_badges = True
152
153extlinks = {
154    "duref": (
155        "http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#%s",
156        "rST %s",
157    ),
158    "durole": (
159        "http://docutils.sourceforge.net/docs/ref/rst/roles.html#%s",
160        "rST role %s",
161    ),
162    "dudir": (
163        "http://docutils.sourceforge.net/docs/ref/rst/directives.html#%s",
164        "rST directive %s",
165    ),
166    "graphvizattr": (
167        "https://graphviz.org/docs/attrs/%s/",
168        "%s attribute",
169    ),
170    "dutree": (
171        "https://docutils.sourceforge.io/docs/ref/doctree.html#%s",
172        "%s",
173    ),
174}
175
176def setup(app):
177    from sphinx.ext.autodoc import cut_lines
178    from sphinx.util.docfields import GroupedField
179    app.add_object_type('confval', 'confval',
180                        objname='configuration value',
181                        indextemplate='pair: %s; configuration value')
182
183language = "fr"
184html_last_updated_fmt = ""
185
186todo_include_todos = True
187# html_favicon = "images/favicon.ico"
188
189html_use_index = True
190html_domain_indices = True
191
192
193rst_prolog = """
194.. |sphinx| image:: /images/documentation.png
195.. |yaml| image:: /images/yaml_avatar.png
196.. |JsonSchema| image:: /images/json_schema_avatar.png
197.. |eb| image:: /images/executable_book_avatar.png
198.. |yed| image:: /images/yed_avatar.png
199.. |vrt| image:: /images/vrt_avatar.png
200.. |arsouilles| image:: /images/arsouilles_avatar.png
201.. |FluxWeb| image:: /images/rss_avatar.webp
202"""
203copyright = f"2018-{now.year}, {author} Built with sphinx {sphinx.__version__} Python {platform.python_version()}"