summaryrefslogtreecommitdiff
path: root/doc/development/tutorials/examples
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/tutorials/examples')
-rw-r--r--doc/development/tutorials/examples/recipe.py6
-rw-r--r--doc/development/tutorials/examples/todo.py16
2 files changed, 8 insertions, 14 deletions
diff --git a/doc/development/tutorials/examples/recipe.py b/doc/development/tutorials/examples/recipe.py
index 9c54a93f0..6aa17077c 100644
--- a/doc/development/tutorials/examples/recipe.py
+++ b/doc/development/tutorials/examples/recipe.py
@@ -44,9 +44,6 @@ class IngredientIndex(Index):
localname = 'Ingredient Index'
shortname = 'Ingredient'
- def __init__(self, *args, **kwargs):
- super(IngredientIndex, self).__init__(*args, **kwargs)
-
def generate(self, docnames=None):
content = defaultdict(list)
@@ -84,9 +81,6 @@ class RecipeIndex(Index):
localname = 'Recipe Index'
shortname = 'Recipe'
- def __init__(self, *args, **kwargs):
- super(RecipeIndex, self).__init__(*args, **kwargs)
-
def generate(self, docnames=None):
content = defaultdict(list)
diff --git a/doc/development/tutorials/examples/todo.py b/doc/development/tutorials/examples/todo.py
index d46f90821..2bcf6788f 100644
--- a/doc/development/tutorials/examples/todo.py
+++ b/doc/development/tutorials/examples/todo.py
@@ -1,5 +1,7 @@
from docutils import nodes
from docutils.parsers.rst import Directive
+
+from sphinx.util.docutils import SphinxDirective
from sphinx.locale import _
@@ -25,26 +27,24 @@ class TodolistDirective(Directive):
return [todolist('')]
-class TodoDirective(Directive):
+class TodoDirective(SphinxDirective):
# this enables content in the directive
has_content = True
def run(self):
- env = self.state.document.settings.env
-
- targetid = 'todo-%d' % env.new_serialno('todo')
+ targetid = 'todo-%d' % self.env.new_serialno('todo')
targetnode = nodes.target('', '', ids=[targetid])
todo_node = todo('\n'.join(self.content))
todo_node += nodes.title(_('Todo'), _('Todo'))
self.state.nested_parse(self.content, self.content_offset, todo_node)
- if not hasattr(env, 'todo_all_todos'):
- env.todo_all_todos = []
+ if not hasattr(self.env, 'todo_all_todos'):
+ self.env.todo_all_todos = []
- env.todo_all_todos.append({
- 'docname': env.docname,
+ self.env.todo_all_todos.append({
+ 'docname': self.env.docname,
'lineno': self.lineno,
'todo': todo_node.deepcopy(),
'target': targetnode,