root/galaxy-central/eggs/docutils-0.4-py2.6.egg/docutils/parsers/rst/directives/admonitions.py

リビジョン 3, 2.3 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# Author: David Goodger
2# Contact: goodger@users.sourceforge.net
3# Revision: $Revision: 3155 $
4# Date: $Date: 2005-04-02 23:57:06 +0200 (Sat, 02 Apr 2005) $
5# Copyright: This module has been placed in the public domain.
6
7"""
8Admonition directives.
9"""
10
11__docformat__ = 'reStructuredText'
12
13
14from docutils.parsers.rst import states, directives
15from docutils import nodes
16
17
18def make_admonition(node_class, name, arguments, options, content, lineno,
19                       content_offset, block_text, state, state_machine):
20    if not content:
21        error = state_machine.reporter.error(
22            'The "%s" admonition is empty; content required.' % (name),
23            nodes.literal_block(block_text, block_text), line=lineno)
24        return [error]
25    text = '\n'.join(content)
26    admonition_node = node_class(text)
27    if arguments:
28        title_text = arguments[0]
29        textnodes, messages = state.inline_text(title_text, lineno)
30        admonition_node += nodes.title(title_text, '', *textnodes)
31        admonition_node += messages
32        if options.has_key('class'):
33            classes = options['class']
34        else:
35            classes = ['admonition-' + nodes.make_id(title_text)]
36        admonition_node['classes'] += classes
37    state.nested_parse(content, content_offset, admonition_node)
38    return [admonition_node]
39
40def admonition(*args):
41    return make_admonition(nodes.admonition, *args)
42
43admonition.arguments = (1, 0, 1)
44admonition.options = {'class': directives.class_option}
45admonition.content = 1
46
47def attention(*args):
48    return make_admonition(nodes.attention, *args)
49
50attention.content = 1
51
52def caution(*args):
53    return make_admonition(nodes.caution, *args)
54
55caution.content = 1
56
57def danger(*args):
58    return make_admonition(nodes.danger, *args)
59
60danger.content = 1
61
62def error(*args):
63    return make_admonition(nodes.error, *args)
64
65error.content = 1
66
67def hint(*args):
68    return make_admonition(nodes.hint, *args)
69
70hint.content = 1
71
72def important(*args):
73    return make_admonition(nodes.important, *args)
74
75important.content = 1
76
77def note(*args):
78    return make_admonition(nodes.note, *args)
79
80note.content = 1
81
82def tip(*args):
83    return make_admonition(nodes.tip, *args)
84
85tip.content = 1
86
87def warning(*args):
88    return make_admonition(nodes.warning, *args)
89
90warning.content = 1
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。