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/todo.py | |
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/todo.py')
-rw-r--r-- | doc/development/tutorials/examples/todo.py | 16 |
1 files changed, 8 insertions, 8 deletions
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, |