From 7b09f95cfa863ba77c5ec7ed8ebf8ed7f227fecc Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 3 Jan 2010 12:20:54 +0100 Subject: [PATCH 1/3] #294: do not ignore an explicit ``today`` config value in a LaTeX build. --- CHANGES | 3 +++ sphinx/writers/latex.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 590b91d9c..5d7c9fcac 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.4 (in development) ============================== +* #294: do not ignore an explicit ``today`` config value in a + LaTeX build. + * The ``alt`` text of inheritance diagrams is now much cleaner. * Ignore images in section titles when generating link captions. diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index c194833f5..8a8285ecf 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -178,8 +178,6 @@ class LaTeXTranslator(nodes.NodeVisitor): 'pointsize': builder.config.latex_font_size, # if empty, the title is set to the first section title 'title': document.settings.title, - 'date': ustrftime(builder.config.today_fmt - or _('%B %d, %Y')), 'release': builder.config.release, 'author': document.settings.author, 'releasename': _('Release'), @@ -187,6 +185,11 @@ class LaTeXTranslator(nodes.NodeVisitor): 'modindexname': _('Module Index'), 'indexname': _('Index'), }) + if builder.config.today: + self.elements['date'] = builder.config.today + else: + self.elements['date'] = ustrftime(builder.config.today_fmt + or _('%B %d, %Y')) if builder.config.latex_logo: self.elements['logo'] = '\\includegraphics{%s}\\par' % \ path.basename(builder.config.latex_logo) From dcabce9f78f68b76b32b477712ec67334ff32a01 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 3 Jan 2010 12:36:21 +0100 Subject: [PATCH 2/3] #286: collect todo nodes after the whole document has been read; this allows placing substitution references in todo items. --- CHANGES | 3 +++ sphinx/ext/todo.py | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 5d7c9fcac..8aa1ca0d6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.4 (in development) ============================== +* #286: collect todo nodes after the whole document has been read; + this allows placing substitution references in todo items. + * #294: do not ignore an explicit ``today`` config value in a LaTeX build. diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index 2910451d3..95246af38 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -42,20 +42,31 @@ class Todo(Directive): ad = make_admonition(todo_node, self.name, [_('Todo')], self.options, self.content, self.lineno, self.content_offset, self.block_text, self.state, self.state_machine) + ad[0].line = self.lineno + return [targetnode] + ad - # Attach a list of all todos to the environment, - # the todolist works with the collected todo nodes - if not hasattr(env, 'todo_all_todos'): - env.todo_all_todos = [] + +def process_todos(app, doctree): + # collect all todos in the environment + # this is not done in the directive itself because it some transformations + # must have already been run, e.g. substitutions + env = app.builder.env + if not hasattr(env, 'todo_all_todos'): + env.todo_all_todos = [] + for node in doctree.traverse(todo_node): + try: + targetnode = node.parent[node.parent.index(node) - 1] + if not isinstance(targetnode, nodes.target): + raise IndexError + except IndexError: + targetnode = None env.todo_all_todos.append({ 'docname': env.docname, - 'lineno': self.lineno, - 'todo': ad[0].deepcopy(), + 'lineno': node.line, + 'todo': node.deepcopy(), 'target': targetnode, }) - return [targetnode] + ad - class TodoList(Directive): """ @@ -152,6 +163,7 @@ def setup(app): app.add_directive('todo', Todo) app.add_directive('todolist', TodoList) + app.connect('doctree-read', process_todos) app.connect('doctree-resolved', process_todo_nodes) app.connect('env-purge-doc', purge_todos) From 3b1fd1fe2cb3c8d9aa747fae6acb3367eda2a7df Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 3 Jan 2010 12:39:55 +0100 Subject: [PATCH 3/3] Add tests for todo extension. --- tests/root/contents.txt | 1 + tests/root/extensions.txt | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/root/extensions.txt diff --git a/tests/root/contents.txt b/tests/root/contents.txt index aeca6a587..503cb5e1e 100644 --- a/tests/root/contents.txt +++ b/tests/root/contents.txt @@ -22,6 +22,7 @@ Contents: autodoc autosummary doctest + extensions Python diff --git a/tests/root/extensions.txt b/tests/root/extensions.txt new file mode 100644 index 000000000..70c8959fa --- /dev/null +++ b/tests/root/extensions.txt @@ -0,0 +1,22 @@ +Test for diverse extensions +=========================== + +todo +---- + +.. todo:: + + Test the todo extension. + +.. todo:: + + Test with |sub| (see #286). + +.. |sub| replace:: substitution references + + +list of all todos +^^^^^^^^^^^^^^^^^ + +.. todolist:: +