<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>プラグインを書く — Bazaar 2.6.0 ドキュメント</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.6.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/translations.js"></script> <link rel="shortcut icon" href="../_static/bzr.ico"/> <link rel="top" title="Bazaar 2.6.0 ドキュメント" href="../index.html" /> <link rel="up" title="Bazaarユーザーガイド" href="index.html" /> <link rel="next" title="Licence" href="licence.html" /> <link rel="prev" title="Apache を使って Bazaar サーバーをたてる" href="http_smart_server.html" /> </head> <body> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="licence.html" title="Licence" accesskey="N">次へ</a></li> <li class="right" > <a href="http_smart_server.html" title="Apache を使って Bazaar サーバーをたてる" accesskey="P">前へ</a> |</li> <li><a href="../index.html">目次 (2.6.0)</a> »</li> <li><a href="index.html" accesskey="U">Bazaarユーザーガイド</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="writing-a-plugin"> <span id="id1"></span><h1>プラグインを書く<a class="headerlink" href="#writing-a-plugin" title="このヘッドラインへのパーマリンク">¶</a></h1> <div class="section" id="id2"> <h2>導入<a class="headerlink" href="#id2" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>プラグインはbzrのコア機能ととてもよく似ています。 これらはbzrlibから何でもインポートできます。 プラグインは標準機能を上書きすることもできますが、大抵プラグインは新しいコマンドを提供します。</p> </div> <div class="section" id="creating-a-new-command"> <span id="id3"></span><h2>新しいコマンドを作る<a class="headerlink" href="#creating-a-new-command" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>コマンドを書くには、 <tt class="docutils literal"><span class="pre">bzrlib.commands.Command</span></tt> を継承する新しいオブジェクトを作り、 <tt class="docutils literal"><span class="pre">cmd_foo</span></tt> と命名します。 fooはコマンドの名前です。 名前にアンダースコアが含まれるコマンドを作ると、UIではアンダースコアはハイフンとして表示されます。 たとえば、 <cite>cmd_baz_import</cite> は <cite>baz-import</cite> として表示されます。 コマンドの書き方の実例に関しては、 <tt class="docutils literal"><span class="pre">builtins.py</span></tt> を参照して頂くようお願いします。</p> <p>コマンドを作成したらファイルがインポートされるときに <tt class="docutils literal"><span class="pre">bzrlib.commands.register_command(cmd_foo)</span></tt> でコマンドを登録しなければなりません。 さもなければbzrはコマンドを見つけることはありません。</p> </div> <div class="section" id="installing-a-hook"> <span id="id4"></span><h2>フックをインストールする<a class="headerlink" href="#installing-a-hook" title="このヘッドラインへのパーマリンク">¶</a></h2> <p><a class="reference external" href="hooks.txt">Using hooks</a> を参照してください。</p> </div> <div class="section" id="specifying-a-plugin-version-number"> <span id="id5"></span><h2>プラグインのバージョン番号を指定する<a class="headerlink" href="#specifying-a-plugin-version-number" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>プラグインのバージョン番号を定義するにはタプルで <tt class="docutils literal"><span class="pre">version_info</span></tt> を定義します。例: <tt class="docutils literal"><span class="pre">version_info</span> <span class="pre">=</span> <span class="pre">(0,</span> <span class="pre">9,</span> <span class="pre">0)</span></tt> <tt class="docutils literal"><span class="pre">version_info</span> <span class="pre">=</span> <span class="pre">(0,</span> <span class="pre">9,</span> <span class="pre">0,</span> <span class="pre">'dev',</span> <span class="pre">0)</span></tt></p> </div> <div class="section" id="plugin-searching-rules"> <span id="id6"></span><h2>プラグインの検索ルール<a class="headerlink" href="#plugin-searching-rules" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>デフォルトではbzrはプラグインを見つけるために <tt class="docutils literal"><span class="pre">~/.bazaar/plugins</span></tt> と <tt class="docutils literal"><span class="pre">bzrlib/plugins</span></tt> をスキャンします。 <tt class="docutils literal"><span class="pre">BZR_PLUGIN_PATH</span></tt> でこれを上書きできます。 (詳細は、 <a class="reference external" href="../user-reference/configuration-help.html#bzr-plugin-path">ユーザーリファレンス</a> を参照してください。)</p> <p>プラグインはモジュールもしくはパッケージの形態をとることができます。 プラグインが単独のファイルであれば、構造をモジュールにできます。 プラグインが複数のファイルを持つ場合やbzrのブランチとして配布したい場合は、 構造をパッケージ、すなわち、ディレクトリの中に <tt class="docutils literal"><span class="pre">__init__.py</span></tt> を含めます。</p> </div> <div class="section" id="id8"> <h2>詳しい情報<a class="headerlink" href="#id8" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>他の人にも役立つと考えましたら、プラグインをBzrToolsにお気軽に寄付してください。</p> <p>Bazaarの開発ガイドラインと方針の詳細に関しては <a class="reference external" href="../developer-guide/HACKING.html">Bazaar開発者ガイド</a> を参照してください。</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">目次</a></h3> <ul> <li><a class="reference internal" href="#">プラグインを書く</a><ul> <li><a class="reference internal" href="#id2">導入</a></li> <li><a class="reference internal" href="#creating-a-new-command">新しいコマンドを作る</a></li> <li><a class="reference internal" href="#installing-a-hook">フックをインストールする</a></li> <li><a class="reference internal" href="#specifying-a-plugin-version-number">プラグインのバージョン番号を指定する</a></li> <li><a class="reference internal" href="#plugin-searching-rules">プラグインの検索ルール</a></li> <li><a class="reference internal" href="#id8">詳しい情報</a></li> </ul> </li> </ul> <h4>前のトピックへ</h4> <p class="topless"><a href="http_smart_server.html" title="前の章へ">Apache を使って Bazaar サーバーをたてる</a></p> <h4>次のトピックへ</h4> <p class="topless"><a href="licence.html" title="次の章へ">Licence</a></p> <h3>このページ</h3> <ul class="this-page-menu"> <li><a href="../_sources/user-guide/writing_a_plugin.txt" rel="nofollow">ソースコードを表示</a></li> </ul> <div id="searchbox" style="display: none"> <h3>クイック検索</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="検索" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> モジュール、クラス、または関数名を入力してください </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="licence.html" title="Licence" >次へ</a></li> <li class="right" > <a href="http_smart_server.html" title="Apache を使って Bazaar サーバーをたてる" >前へ</a> |</li> <li><a href="../index.html">目次 (2.6.0)</a> »</li> <li><a href="index.html" >Bazaarユーザーガイド</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2011 Canonical Ltd. このドキュメントは <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3 で生成しました。 </div> </body> </html>