Fix #1818: sphinx.ext.todo directive generates broken html class attribute as 'admonition-' when :confval:language is specified with non-ASCII linguistic area like 'ru' or 'ja'. To fix this, now `todo directive can use `:class:` option.

This commit is contained in:
shimizukawa 2015-11-29 12:02:02 +09:00
parent 9d0ce7a6c1
commit 47bdbd1655
3 changed files with 15 additions and 1 deletions

View File

@ -67,6 +67,9 @@ Bugs fixed
the page content.
* #1884, #1885: plug-in html themes cannot inherit another plug-in theme. Thanks to
Suzumizaki.
* #1818: `sphinx.ext.todo` directive generates broken html class attribute as
'admonition-' when :confval:`language` is specified with non-ASCII linguistic area like
'ru' or 'ja'. To fix this, now ``todo`` directive can use ```:class:`` option.
Release 1.3.1 (released Mar 17, 2015)
=====================================

View File

@ -16,6 +16,10 @@ There are two additional directives when using this extension:
It will only show up in the output if :confval:`todo_include_todos` is
``True``.
.. versionadded:: 1.3.2
This directive supports an ``class`` option that determines the class attribute
for HTML output. If not given, the class defaults to ``admonition-todo``.
.. rst:directive:: todolist

View File

@ -13,6 +13,7 @@
"""
from docutils import nodes
from docutils.parsers.rst import directives
import sphinx
from sphinx.locale import _
@ -38,13 +39,18 @@ class Todo(Directive):
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = False
option_spec = {}
option_spec = {
'class': directives.class_option,
}
def run(self):
env = self.state.document.settings.env
targetid = 'index-%s' % env.new_serialno('index')
targetnode = nodes.target('', '', ids=[targetid])
if not self.options.get('class'):
self.options['class'] = ['admonition-todo']
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)
@ -165,6 +171,7 @@ def merge_info(app, env, docnames, other):
def visit_todo_node(self, node):
self.visit_admonition(node)
# self.visit_admonition(node, 'todo')
def depart_todo_node(self, node):