<!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>sphinx.ext.ifconfig – Include content based on configuration — Sphinx 1.1.3 documentation</title> <link rel="stylesheet" href="../_static/sphinxdoc.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.1.3', 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> <link rel="search" type="application/opensearchdescription+xml" title="Search within Sphinx 1.1.3 documentation" href="../_static/opensearch.xml"/> <link rel="top" title="Sphinx 1.1.3 documentation" href="../index.html" /> <link rel="up" title="Sphinx Extensions" href="../extensions.html" /> <link rel="next" title="sphinx.ext.coverage – Collect doc coverage stats" href="coverage.html" /> <link rel="prev" title="sphinx.ext.refcounting – Keep track of reference counting behavior" href="refcounting.html" /> <style type="text/css"> table.right { float: right; margin-left: 20px; } table.right td { border: 1px solid #ccc; } </style> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <img src="../_static/sphinx.png" alt="Sphinx logo" /> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="coverage.html" title="sphinx.ext.coverage – Collect doc coverage stats" accesskey="N">next</a> |</li> <li class="right" > <a href="refcounting.html" title="sphinx.ext.refcounting – Keep track of reference counting behavior" accesskey="P">previous</a> |</li> <li><a href="../index.html">Sphinx home</a> | </li> <li><a href="../contents.html">Documentation</a> »</li> <li><a href="../extensions.html" accesskey="U">Sphinx Extensions</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="refcounting.html" title="previous chapter"><tt class="docutils literal"><span class="pre">sphinx.ext.refcounting</span></tt> – Keep track of reference counting behavior</a></p> <h4>Next topic</h4> <p class="topless"><a href="coverage.html" title="next chapter"><tt class="docutils literal"><span class="pre">sphinx.ext.coverage</span></tt> – Collect doc coverage stats</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/ext/ifconfig.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-sphinx.ext.ifconfig"> <span id="sphinx-ext-ifconfig-include-content-based-on-configuration"></span><h1><a class="reference internal" href="#module-sphinx.ext.ifconfig" title="sphinx.ext.ifconfig: Include documentation content based on configuration values."><tt class="xref py py-mod docutils literal"><span class="pre">sphinx.ext.ifconfig</span></tt></a> – Include content based on configuration<a class="headerlink" href="#module-sphinx.ext.ifconfig" title="Permalink to this headline">¶</a></h1> <p>This extension is quite simple, and features only one directive:</p> <dl class="directive"> <dt id="directive-ifconfig"> <tt class="descname">.. ifconfig::</tt><a class="headerlink" href="#directive-ifconfig" title="Permalink to this definition">¶</a></dt> <dd><p>Include content of the directive only if the Python expression given as an argument is <tt class="docutils literal"><span class="pre">True</span></tt>, evaluated in the namespace of the project’s configuration (that is, all registered variables from <tt class="file docutils literal"><span class="pre">conf.py</span></tt> are available).</p> <p>For example, one could write</p> <div class="highlight-rest"><pre>.. ifconfig:: releaselevel in ('alpha', 'beta', 'rc') This stuff is only included in the built docs for unstable versions.</pre> </div> <p>To make a custom config value known to Sphinx, use <a class="reference internal" href="appapi.html#sphinx.application.Sphinx.add_config_value" title="sphinx.application.Sphinx.add_config_value"><tt class="xref py py-func docutils literal"><span class="pre">add_config_value()</span></tt></a> in the setup function in <tt class="file docutils literal"><span class="pre">conf.py</span></tt>, e.g.:</p> <div class="highlight-rest"><pre>def setup(app): app.add_config_value('releaselevel', '', True)</pre> </div> <p>The second argument is the default value, the third should always be <tt class="docutils literal"><span class="pre">True</span></tt> for such values (it selects if Sphinx re-reads the documents if the value changes).</p> </dd></dl> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="coverage.html" title="sphinx.ext.coverage – Collect doc coverage stats" >next</a> |</li> <li class="right" > <a href="refcounting.html" title="sphinx.ext.refcounting – Keep track of reference counting behavior" >previous</a> |</li> <li><a href="../index.html">Sphinx home</a> | </li> <li><a href="../contents.html">Documentation</a> »</li> <li><a href="../extensions.html" >Sphinx Extensions</a> »</li> </ul> </div> <div class="footer"> © Copyright 2007-2011, Georg Brandl. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>