Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 388a191dbad6b966fd8a7add43a4053b > files > 60

apiextractor-devel-0.10.0-1.fc14.x86_64.rpm

<!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>API Extractor &mdash; 3.6. Using Code Templates</title>
    <link rel="stylesheet" href="_static/pysidedocs.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
    var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '#',
        VERSION:     '0.10.0',
        COLLAPSE_MODINDEX: 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>
    <!--[if lt IE 7]>
    <style media="screen" type="text/css">
    #container {
        height:100%;
    }
    </style>
    <![endif]-->
    <link rel="top" title="API Extractor v0.10.0 documentation" href="index.html" />
    <link rel="up" title="3. The API Extractor Type System" href="typesystem.html" />
    <link rel="next" title="3.7. Manipulating Documentation" href="typesystem_documentation.html" />
    <link rel="prev" title="3.5. Solving compilation problems" href="typesystem_solving_compilation.html" /> 
  </head>
  <body id="typesystem_templates">

<div id="container">
<div id="header">
    <div id="header_container">
        <div id="logo"><a href="http://www.pyside.org"><img alt="PySide" src="_static/pysidelogo.png" width="199" height="102" /></a></div>
        <ul id="relbar">
            <li class="right">
            <a href="typesystem_documentation.html" title="3.7. Manipulating Documentation"
                accesskey="N">next</a></li>
            <li class="right">
            <a href="typesystem_solving_compilation.html" title="3.5. Solving compilation problems"
                accesskey="P">previous</a> |</li>
            <li><a href="contents.html">API Extractor v0.10.0 documentation</a> &raquo;</li>
            <li><a href="typesystem.html" accesskey="U">3. The API Extractor Type System</a> &raquo;</li> 
        </ul>
    </div>
</div>

<div id="body" >
    <div id="sidebar">
            <h3><a href="contents.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference internal" href="#">3.6. Using Code Templates</a><ul>
<li><a class="reference internal" href="#template">3.6.1. template</a></li>
<li><a class="reference internal" href="#insert-template">3.6.2. insert-template</a></li>
<li><a class="reference internal" href="#replace">3.6.3. replace</a></li>
</ul>
</li>
</ul>

            <h3>Previous topic</h3>
            <p class="topless"><a href="typesystem_solving_compilation.html"
                                  title="previous chapter">3.5. Solving compilation problems</a></p>
            <h3>Next topic</h3>
            <p class="topless"><a href="typesystem_documentation.html"
                                  title="next chapter">3.7. Manipulating Documentation</a></p>

        <div id="search_box">
        <h3>Quick search</h3>
        <form action="search.html" method="get">
        <input type="text" name="q" id="q" />
        <input type="submit" value="Go" id="search_button" />
        <input type="hidden" name="check_keywords" value="yes" />
        <input type="hidden" name="area" value="default" />
        </form>
        </div>

    </div>
    
  <div class="section" id="using-code-templates">
<span id="id1"></span><h1>3.6. Using Code Templates</h1>
<div class="section" id="template">
<h2>3.6.1. template</h2>
<blockquote>
<div><p>The template node registers a template that can be used to avoid duplicate
code when extending the generated code, and it is a child of the typesystem
node.</p>
<div class="highlight-xml"><div class="highlight"><pre><span class="nt">&lt;typesystem&gt;</span>
    <span class="nt">&lt;template</span> <span class="na">name=</span><span class="s">&quot;my_template&quot;</span><span class="nt">&gt;</span>
        // the code
    <span class="nt">&lt;/template&gt;</span>
<span class="nt">&lt;/typesystem&gt;</span>
</pre></div>
</div>
<p>Use the insert-template node to insert the template code (identified by the
template&#8217;s <tt class="docutils literal"><span class="pre">name</span></tt> attribute) into the generated code base.</p>
</div></blockquote>
</div>
<div class="section" id="insert-template">
<h2>3.6.2. insert-template</h2>
<blockquote>
<div><p>The insert-template node includes the code template identified by the name
attribute, and it can be a child of the inject-code, conversion-rule, template,
custom-constructor and custom-destructor nodes.</p>
<div class="highlight-xml"><div class="highlight"><pre><span class="nt">&lt;inject-code</span> <span class="na">class=</span><span class="s">&quot;target&quot;</span> <span class="na">position=</span><span class="s">&quot;beginning&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;insert-template</span> <span class="na">name=</span><span class="s">&quot;my_template&quot;</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/inject-code&gt;</span>
</pre></div>
</div>
<p>Use the replace node to modify the template code.</p>
</div></blockquote>
</div>
<div class="section" id="replace">
<h2>3.6.3. replace</h2>
<blockquote>
<div><p>The replace node allows you to modify template code before inserting it into
the generated code, and it can be a child of the insert-template node.</p>
<div class="highlight-xml"><div class="highlight"><pre><span class="nt">&lt;insert-template</span> <span class="na">name=</span><span class="s">&quot;my_template&quot;</span><span class="nt">&gt;</span>
   <span class="nt">&lt;replace</span> <span class="na">from=</span><span class="s">&quot;...&quot;</span> <span class="na">to=</span><span class="s">&quot;...&quot;</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/insert-template&gt;</span>
</pre></div>
</div>
<p>This node will replace the attribute <tt class="docutils literal"><span class="pre">from</span></tt> with the value pointed by
<tt class="docutils literal"><span class="pre">to</span></tt>.</p>
</div></blockquote>
</div>
</div>


</div> <!-- container    -->
<div id="footer">
    <a href="http://www.indt.org.br"><img src="_static/logo_indt.jpg" alt="Indt" border="0" /></a>
    <a href="http://www.openbossa.org"><img src="_static/logo_openbossa.png" alt="Openbossa" border="0" /></a>
    <a href="http://qt.nokia.com/"><img src="_static/logo_qt.png" alt="Qt" border="0" /></a>
    <a href="http://www.python.org"><img src="_static/logo_python.jpg" alt="Python" border="0" /></a>
</div>
</div>
</body>
</html>