diff options
author | Stephen Finucane <stephen@that.guru> | 2019-02-18 13:38:42 +0000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2019-02-18 13:46:30 +0000 |
commit | a35040c454aeeb87b3e5681360f1a7b54811cd62 (patch) | |
tree | 47cdcd5b3631f27c2d365bee0e726a5ca588adb2 /doc/development/tutorials/examples | |
parent | 5c061ff2665f7177b110416b49b5dd37aadeda5b (diff) | |
download | sphinx-git-a35040c454aeeb87b3e5681360f1a7b54811cd62.tar.gz |
docs: Address further review comments
todo:
- Subclass SphinxDirective instead of Directive
recipe:
- Remove unnecessary '__init__' methods
Signed-off-by: Stephen Finucane <stephen@that.guru>
Diffstat (limited to 'doc/development/tutorials/examples')
-rw-r--r-- | doc/development/tutorials/examples/recipe.py | 6 | ||||
-rw-r--r-- | doc/development/tutorials/examples/todo.py | 16 |
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, |