| 1 | | = Trac での reStructuredText 対応 = #reStructuredTextSupportinTrac |
| 2 | | |
| 3 | | Trac は WikiFormatting を使用できるすべての箇所で、 Wiki マークアップの代わりに ''reStructuredText'' を使用することができます。 |
| 4 | | |
| 5 | | reStructuredText の Web ページより: |
| 6 | | "''reStructuredText は読みやすく、 WYSIWYG なプレーンテキストへのマークアップ文法と、そのパーサシステムです。 (Python の docstring のような) プログラムへのインラインドキュメンテーションや、シンプルな Web ページの素早い作成、スタンドアロンのドキュメントの記述に役立ちます。 reStructuredText は個別のアプリケーション向けに拡張ができるように設計されています。''" |
| 7 | | |
| 8 | | Subversion リポジトリのファイルを reStructuredText として Trac のソースブラウザに表示したい場合、 Subversion の `svn:mime-type` 属性に `text/x-rst` を設定してください。 [http://trac.edgewall.org/browser/trunk/INSTALL この例] が参考になります。 |
| 9 | | |
| 10 | | === 必須条件 === #Requirements |
| 11 | | Trac で RST を使うためには、 Python の docutils パッケージがインストールされていなければなりません。 |
| 12 | | あなたのオペレーティングシステムでまだ使用できない場合は、 [http://docutils.sourceforge.net/rst.html RST Website] からダウンロードすることができます。 |
| 13 | | |
| 14 | | docutils のインストールには `easy_install docutils` を使用してください。 Trac が docutils パッケージを探すことが出来ない可能性があるので、 (`apt-get install python-docutils` などの) OS のパッケージマネージャは使わないでください。('''訳注:''' docutils が提供している `setup.py` では `setuptools` を使用していないため、 OS のパッケージでは `docutils-*.egg-info` が作成されない場合があることを指しています。 egg-info さえ作成されていれば OS のパッケージマネージャを使用しても問題ないと思われます。) |
| 15 | | |
| 16 | | === さらなる RST に関する情報 === #MoreinformationonRST |
| 17 | | |
| 18 | | * reStructuredText Web サイト -- http://docutils.sourceforge.net/rst.html |
| 19 | | * RST クイックリファレンス -- http://docutils.sourceforge.net/docs/rst/quickref.html |
| 20 | | |
| 21 | | ---- |
| 22 | | |
| 23 | | == RST を Trac で使用する == #UsingRSTinTrac |
| 24 | | テキストブロックが RST でパースされるようにするには、 ''rst'' プロセッサを使用してください。 |
| 25 | | |
| 26 | | === reStructuredText における TracLinks === #TracLinksinreStructuredText |
| 27 | | |
| 28 | | * Trac は RST テキストの中で TracLinks が可能になる、 RST のディレクティブ 'trac' を提供しています |
| 29 | | ||= Wiki マークアップ ||= 表示 || |
| | 1 | = reStructuredText Support in Trac |
| | 2 | |
| | 3 | == Introduction |
| | 4 | |
| | 5 | |
| | 6 | Trac supports [http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html reStructuredText (RST)] as an alternative to wiki markup where WikiFormatting is used. |
| | 7 | |
| | 8 | From the reStucturedText webpage: |
| | 9 | "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." |
| | 10 | |
| | 11 | 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:branches/1.2-stable/INSTALL.rst this example]. |
| | 12 | |
| | 13 | 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. |
| | 14 | |
| | 15 | === Requirements |
| | 16 | |
| | 17 | 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]. |
| | 18 | |
| | 19 | === More information on RST |
| | 20 | |
| | 21 | * [http://docutils.sourceforge.net/rst.html reStructuredText Website] |
| | 22 | * [http://docutils.sourceforge.net/docs/rst/quickref.html RST Quick Reference] |
| | 23 | |
| | 24 | == Using RST in Trac |
| | 25 | |
| | 26 | To specify that a block of text should be parsed using RST, use the ''rst'' processor. |
| | 27 | |
| | 28 | === TracLinks in reStructuredText |
| | 29 | |
| | 30 | * Trac provides a custom RST directive `trac::` to allow TracLinks from within RST text. |
| | 31 | ||= Wiki Markup ||= Display || |
| 33 | | #!rst |
| 34 | | これは |チケット| へのリンクです。 |
| 35 | | |
| 36 | | .. |チケット| trac:: #42 |
| 37 | | }}} |
| 38 | | }}} |
| 39 | | }}} |
| 40 | | {{{#!td |
| 41 | | {{{ |
| 42 | | #!rst |
| 43 | | これは |チケット| へのリンクです。 |
| 44 | | |
| 45 | | .. |チケット| trac:: #42 |
| 46 | | }}} |
| 47 | | }}} |
| 48 | | |
| 49 | | * Trac は RST で TracLinks を簡単に作成できるように、 `:trac:` というロールを予約しています |
| 50 | | ||= Wiki マークアップ ||= 表示 || |
| 51 | | {{{#!td |
| 52 | | {{{ |
| 53 | | {{{ |
| 54 | | #!rst |
| 55 | | これはチケット `#12`:trac: へのリンクです。 |
| 56 | | |
| 57 | | Trac の使い方を学ぶためには、 `TracGuide`:trac: を参照して下さい。 |
| 58 | | }}} |
| 59 | | }}} |
| 60 | | }}} |
| 61 | | {{{#!td |
| 62 | | {{{ |
| 63 | | #!rst |
| 64 | | これはチケット `#12`:trac: へのリンクです。 |
| 65 | | |
| 66 | | Trac の使い方を学ぶためには、 `TracGuide`:trac: を参照して下さい。 |
| 67 | | }}} |
| 68 | | }}} |
| 69 | | |
| 70 | | `:trac:` ロールのすべての使用例の一覧は、 WikiRestructuredTextLinks を見てください。 |
| 71 | | |
| 72 | | |
| 73 | | === reStructuredText におけるシンタックスハイライト === #SyntaxhighlightinginreStructuredText |
| 74 | | |
| 75 | | 同様に、 RST において TracSyntaxColoring を行なうディレクティブがあります。 |
| 76 | | ディレクティブは code-block と呼ばれます。 |
| 77 | | |
| 78 | | ||= Wiki マークアップ ||= 表示 || |
| 79 | | {{{#!td |
| 80 | | {{{ |
| 81 | | {{{ |
| 82 | | #!rst |
| | 53 | {{{#!rst |
| | 54 | This is a reference to ticket `#12`:trac: |
| | 55 | |
| | 56 | To learn how to use Trac, see `TracGuide`:trac: |
| | 57 | }}} |
| | 58 | }}} |
| | 59 | }}} |
| | 60 | {{{#!td |
| | 61 | {{{#!rst |
| | 62 | This is a reference to ticket `#12`:trac: |
| | 63 | |
| | 64 | To learn how to use Trac, see `TracGuide`:trac: |
| | 65 | }}} |
| | 66 | }}} |
| | 67 | |
| | 68 | For a complete example of all uses of the `:trac:` role, see WikiRestructuredTextLinks. |
| | 69 | |
| | 70 | === Syntax highlighting in reStructuredText |
| | 71 | |
| | 72 | There is a directive for doing TracSyntaxColoring in RST as well. The directive is called code-block: |
| | 73 | |
| | 74 | ||= Wiki Markup ||= Display || |
| | 75 | {{{#!td |
| | 76 | {{{ |
| | 77 | {{{#!rst |
| 107 | | `.. code-block` ディレクティブの後のコードは少なくとも1文字インデントする必要があります。 |
| 108 | | |
| 109 | | === reStructuredText の中における Wiki Macros === #WikiMacrosinreStructuredText |
| 110 | | |
| 111 | | [WikiMacros Wiki マクロ] を RST の中で使用するには、 code-block のようなシンタックスハイライトと同様のディレクティブを使用します。 |
| 112 | | |
| 113 | | ||= Wiki マークアップ ||= 表示 || |
| | 101 | Note the need to indent the code at least one character after the `.. code-block` directive. |
| | 102 | |
| | 103 | === Wiki Macros in reStructuredText |
| | 104 | |
| | 105 | To enable [WikiMacros Wiki Macros] in RST, you use the same `code-block` directive as for syntax highlighting: |
| | 106 | |
| | 107 | ||= Wiki Markup ||= Display || |
| | 108 | {{{#!td |
| | 109 | {{{ |
| | 110 | {{{#!rst |
| | 111 | |
| | 112 | .. code-block:: RecentChanges |
| | 113 | |
| | 114 | Trac,3 |
| | 115 | |
| | 116 | }}} |
| | 117 | }}} |
| | 118 | }}} |
| | 119 | {{{#!td |
| | 120 | {{{#!rst |
| | 121 | |
| | 122 | .. code-block:: RecentChanges |
| | 123 | |
| | 124 | Trac,3 |
| | 125 | |
| | 126 | }}} |
| | 127 | }}} |
| | 128 | |
| | 129 | Or use the `:code-block:` role for a more concise Wiki Macro-like syntax: |
| | 130 | |
| | 131 | ||= Wiki Markup ||= Display || |
| 157 | | === より大きい RST の例 === #BiggerRSTExample |
| 158 | | この例のように書くと、とても分かりやすくなります: |
| 159 | | |
| 160 | | ||= Wiki マークアップ ||= 表示 || |
| 161 | | {{{#!td |
| 162 | | {{{ |
| 163 | | #!html |
| 164 | | <pre class="wiki">{{{ |
| 165 | | #!rst |
| 166 | | ほげほげヘッダ |
| 167 | | ============== |
| 168 | | reStructuredText は **素敵** 。この続きは webpage_ で。 |
| 169 | | |
| 170 | | 表: |
| 171 | | |
| 172 | | == == ====== |
| 173 | | 入力 出力 |
| 174 | | ------ ------ |
| 175 | | A B A or B |
| 176 | | == == ====== |
| 177 | | 偽 偽 偽 |
| 178 | | 真 偽 真 |
| 179 | | 偽 真 真 |
| 180 | | 真 真 真 |
| 181 | | == == ====== |
| 182 | | |
| 183 | | RST での TracLinks |
| 184 | | ------------------ |
| 185 | | |
| 186 | | チケット `[trac:#42]`:trac: のように使用します。 |
| | 148 | === Bigger RST Example |
| | 149 | |
| | 150 | The example below should be self-explanatory: |
| | 151 | |
| | 152 | ||= Wiki Markup ||= Display || |
| | 153 | {{{#!td |
| | 154 | {{{#!html |
| | 155 | <pre class="wiki">{{{#!rst |
| | 156 | FooBar Header |
| | 157 | ============= |
| | 158 | reStructuredText is **nice**. It has its own webpage_. |
| | 159 | |
| | 160 | A table: |
| | 161 | |
| | 162 | ===== ===== ====== |
| | 163 | Inputs Output |
| | 164 | ------------ ------ |
| | 165 | A B A or B |
| | 166 | ===== ===== ====== |
| | 167 | False False False |
| | 168 | True False True |
| | 169 | False True True |
| | 170 | True True True |
| | 171 | ===== ===== ====== |
| | 172 | |
| | 173 | RST TracLinks |
| | 174 | ------------- |
| | 175 | |
| | 176 | See also ticket `#42`:trac:. |