179
|
1 |
# -*- coding: utf-8 -*-
|
|
2 |
"""
|
|
3 |
sphinx.util.compat
|
|
4 |
~~~~~~~~~~~~~~~~~~
|
|
5 |
|
|
6 |
Stuff for docutils compatibility.
|
|
7 |
|
|
8 |
:copyright: 2008 by Georg Brandl.
|
|
9 |
:license: BSD.
|
|
10 |
"""
|
|
11 |
|
|
12 |
from docutils import nodes
|
|
13 |
|
|
14 |
|
|
15 |
# function missing in 0.5 SVN
|
|
16 |
def make_admonition(node_class, name, arguments, options, content, lineno,
|
|
17 |
content_offset, block_text, state, state_machine):
|
|
18 |
#if not content:
|
|
19 |
# error = state_machine.reporter.error(
|
|
20 |
# 'The "%s" admonition is empty; content required.' % (name),
|
|
21 |
# nodes.literal_block(block_text, block_text), line=lineno)
|
|
22 |
# return [error]
|
|
23 |
text = '\n'.join(content)
|
|
24 |
admonition_node = node_class(text)
|
|
25 |
if arguments:
|
|
26 |
title_text = arguments[0]
|
|
27 |
textnodes, messages = state.inline_text(title_text, lineno)
|
|
28 |
admonition_node += nodes.title(title_text, '', *textnodes)
|
|
29 |
admonition_node += messages
|
|
30 |
if options.has_key('class'):
|
|
31 |
classes = options['class']
|
|
32 |
else:
|
|
33 |
classes = ['admonition-' + nodes.make_id(title_text)]
|
|
34 |
admonition_node['classes'] += classes
|
|
35 |
state.nested_parse(content, content_offset, admonition_node)
|
|
36 |
return [admonition_node]
|
|
37 |
|