summaryrefslogtreecommitdiff
path: root/raw-wiki-dump/WikiRestructuredText.trac
blob: d8020d2a69dc9d9adad3c505f83641e19fbbde95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
= reStructuredText Support in Trac

== Introduction


Trac supports [http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html reStructuredText (RST)] as an alternative to wiki markup where WikiFormatting is used.

From the reStucturedText webpage:
 "reStructuredText is an easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and parser system. It is useful for in-line program documentation (such as Python docstrings), for quickly creating simple web pages, and for standalone documents. reStructuredText is designed for extensibility for specific application domains."

If you want a file from your Subversion repository to be displayed as reStructuredText in the Trac source browser, set `text/x-rst` as the value for the Subversion property `svn:mime-type`, or add the extension `rst` to the filename. See [trac:source:/trunk/INSTALL.rst this example].

The examples will only be rendered as reStructuredText if docutils is installed. If Pygments is installed but docutils is not installed, the examples will be syntax-highlighted rather than rendered as reStructuredText.

=== Requirements

To activate RST support in Trac, install the python docutils package with the command `easy_install docutils`, or through your operating system package manager. If not already available on your operating system, you can download it from [https://pypi.python.org/pypi/docutils PyPI].

=== More information on RST

 * [http://docutils.sourceforge.net/rst.html reStructuredText Website]
 * [http://docutils.sourceforge.net/docs/rst/quickref.html RST Quick Reference]

== Using RST in Trac

To specify that a block of text should be parsed using RST, use the ''rst'' processor. 

=== TracLinks in reStructuredText

 * Trac provides a custom RST directive `trac::` to allow TracLinks from within RST text.
   ||= Wiki Markup ||= Display ||
   {{{#!td
     {{{
     {{{#!rst
     This is a reference to |a ticket|

     .. |a ticket| trac:: #42
     }}}
     }}}
   }}}
   {{{#!td
     {{{#!rst
     This is a reference to |a ticket|

     .. |a ticket| trac:: #42
     }}}
   }}}

 * You can also use the custom `:trac:` role to create TracLinks in RST.
   ||= Wiki Markup ||= Display ||
   {{{#!td
     {{{
     {{{#!rst
     This is a reference to ticket `#12`:trac:

     To learn how to use Trac, see `TracGuide`:trac:
     }}}
     }}}
   }}}
   {{{#!td
     {{{#!rst
     This is a reference to ticket `#12`:trac:

     To learn how to use Trac, see `TracGuide`:trac:
     }}}
   }}}

 For a complete example of all uses of the `:trac:` role, see WikiRestructuredTextLinks. 

=== Syntax highlighting in reStructuredText

There is a directive for doing TracSyntaxColoring in RST as well. The directive is called code-block:

||= Wiki Markup ||= Display ||
{{{#!td
  {{{
  {{{#!rst

  .. code-block:: python

     class Test:

         def TestFunction(self):
             pass
  
  }}}
  }}}
}}}
{{{#!td
  {{{#!rst

  .. code-block:: python

     class Test:

         def TestFunction(self):
             pass

  }}}
}}}
Note the need to indent the code at least one character after the `.. code-block` directive.

=== Wiki Macros in reStructuredText

To enable [WikiMacros Wiki Macros] in RST, you use the same `code-block` directive as for syntax highlighting:

||= Wiki Markup ||= Display ||
{{{#!td
  {{{
  {{{#!rst

  .. code-block:: RecentChanges

     Trac,3

  }}}
  }}}
}}}
{{{#!td
  {{{#!rst

  .. code-block:: RecentChanges

     Trac,3

  }}}
}}}

Or use the `:code-block:` role for a more concise Wiki Macro-like syntax:

||= Wiki Markup ||= Display ||
{{{#!td
  {{{
  {{{
  #!rst

  :code-block:`RecentChanges:Trac,3`
  }}}
  }}}
}}}
{{{#!td
  {{{#!rst

  :code-block:`RecentChanges:Trac,3`
  }}}
}}}

=== Bigger RST Example

The example below should be self-explanatory:

||= Wiki Markup ||= Display ||
{{{#!td
{{{#!html
<pre class="wiki">{{{#!rst
FooBar Header
=============
reStructuredText is **nice**. It has its own webpage_.

A table:

=====  =====  ======
   Inputs     Output
------------  ------
  A      B    A or B
=====  =====  ======
False  False  False
True   False  True
False  True   True
True   True   True
=====  =====  ======

RST TracLinks
-------------

See also ticket `#42`:trac:.

.. _webpage: http://docutils.sourceforge.net/rst.html
}}}</pre>
}}}
}}}
{{{#!td
{{{#!rst
FooBar Header
=============
reStructuredText is **nice**. It has its own webpage_.

A table:

=====  =====  ======
   Inputs     Output
------------  ------
  A      B    A or B
=====  =====  ======
False  False  False
True   False  True
False  True   True
True   True   True
=====  =====  ======

RST TracLinks
-------------

See also ticket `#42`:trac:.

.. _webpage: http://docutils.sourceforge.net/rst.html
}}}
}}}

----
See also: WikiRestructuredTextLinks, WikiProcessors, WikiFormatting