diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:57:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:57:09 +0000 |
commit | 2722609ed8cf1f24bb6a8b8a5ad9d7ac6dec58c3 (patch) | |
tree | e0f8becff83e01bc4228b1824e81a6a355d6e439 /doc/development/tutorials/examples | |
parent | Releasing progress-linux version 7.3.7-3~progress7.99u1. (diff) | |
download | sphinx-2722609ed8cf1f24bb6a8b8a5ad9d7ac6dec58c3.tar.xz sphinx-2722609ed8cf1f24bb6a8b8a5ad9d7ac6dec58c3.zip |
Merging upstream version 7.4.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/development/tutorials/examples')
-rw-r--r-- | doc/development/tutorials/examples/autodoc_intenum.py | 7 | ||||
-rw-r--r-- | doc/development/tutorials/examples/helloworld.py | 25 | ||||
-rw-r--r-- | doc/development/tutorials/examples/recipe.py | 1 | ||||
-rw-r--r-- | doc/development/tutorials/examples/todo.py | 3 |
4 files changed, 29 insertions, 7 deletions
diff --git a/doc/development/tutorials/examples/autodoc_intenum.py b/doc/development/tutorials/examples/autodoc_intenum.py index c52bb4c..7a19a23 100644 --- a/doc/development/tutorials/examples/autodoc_intenum.py +++ b/doc/development/tutorials/examples/autodoc_intenum.py @@ -9,6 +9,7 @@ if TYPE_CHECKING: from docutils.statemachine import StringList from sphinx.application import Sphinx + from sphinx.util.typing import ExtensionMetadata class IntEnumDocumenter(ClassDocumenter): @@ -52,6 +53,10 @@ class IntEnumDocumenter(ClassDocumenter): self.add_line('', source_name) -def setup(app: Sphinx) -> None: +def setup(app: Sphinx) -> ExtensionMetadata: app.setup_extension('sphinx.ext.autodoc') # Require autodoc extension app.add_autodocumenter(IntEnumDocumenter) + return { + 'version': '1', + 'parallel_read_safe': True, + } diff --git a/doc/development/tutorials/examples/helloworld.py b/doc/development/tutorials/examples/helloworld.py index da29562..3f7e504 100644 --- a/doc/development/tutorials/examples/helloworld.py +++ b/doc/development/tutorials/examples/helloworld.py @@ -1,18 +1,33 @@ +from __future__ import annotations + from docutils import nodes -from docutils.parsers.rst import Directive from sphinx.application import Sphinx +from sphinx.util.docutils import SphinxDirective, SphinxRole from sphinx.util.typing import ExtensionMetadata -class HelloWorld(Directive): - def run(self): - paragraph_node = nodes.paragraph(text='Hello World!') +class HelloRole(SphinxRole): + """A role to say hello!""" + + def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]: + node = nodes.inline(text=f'Hello {self.text}!') + return [node], [] + + +class HelloDirective(SphinxDirective): + """A directive to say hello!""" + + required_arguments = 1 + + def run(self) -> list[nodes.Node]: + paragraph_node = nodes.paragraph(text=f'hello {self.arguments[0]}!') return [paragraph_node] def setup(app: Sphinx) -> ExtensionMetadata: - app.add_directive('helloworld', HelloWorld) + app.add_role('hello', HelloRole()) + app.add_directive('hello', HelloDirective) return { 'version': '0.1', diff --git a/doc/development/tutorials/examples/recipe.py b/doc/development/tutorials/examples/recipe.py index 28d25f2..baf85fe 100644 --- a/doc/development/tutorials/examples/recipe.py +++ b/doc/development/tutorials/examples/recipe.py @@ -122,6 +122,7 @@ class RecipeDomain(Domain): 'recipes': [], # object list 'recipe_ingredients': {}, # name -> object } + data_version = 0 def get_full_qualified_name(self, node): return f'recipe.{node.arguments[0]}' diff --git a/doc/development/tutorials/examples/todo.py b/doc/development/tutorials/examples/todo.py index 2baac5c..4e9dc66 100644 --- a/doc/development/tutorials/examples/todo.py +++ b/doc/development/tutorials/examples/todo.py @@ -38,7 +38,7 @@ class TodoDirective(SphinxDirective): todo_node = todo('\n'.join(self.content)) todo_node += nodes.title(_('Todo'), _('Todo')) - self.state.nested_parse(self.content, self.content_offset, todo_node) + todo_node += self.parse_content_to_nodes() if not hasattr(self.env, 'todo_all_todos'): self.env.todo_all_todos = [] @@ -132,6 +132,7 @@ def setup(app: Sphinx) -> ExtensionMetadata: return { 'version': '0.1', + 'env_version': 1, 'parallel_read_safe': True, 'parallel_write_safe': True, } |