pytest2/py/doc/_build/html/coding-style.html

153 lines
7.1 KiB
HTML

<!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>12. Coding Style for the Py lib and friendly applications &mdash; py lib v1.0.0b1 documentation</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: '1.0.0b1',
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/doctools.js"></script>
<link rel="top" title="py lib v1.0.0b1 documentation" href="index.html" />
</head>
<body>
<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><a href="index.html">py lib v1.0.0b1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="coding-style-for-the-py-lib-and-friendly-applications">
<h1>12. Coding Style for the Py lib and friendly applications<a class="headerlink" href="#coding-style-for-the-py-lib-and-friendly-applications" title="Permalink to this headline"></a></h1>
<div class="section" id="honour-pep-8-style-guide-for-python-code">
<h2>12.1. Honour PEP 8: Style Guide for Python Code<a class="headerlink" href="#honour-pep-8-style-guide-for-python-code" title="Permalink to this headline"></a></h2>
<p>First of all, if you haven&#8217;t already read it, read the <a class="reference external" href="http://www.python.org/peps/pep-0008.html">PEP 8
Style Guide for Python Code</a> which, if in doubt, serves as
the default coding-style for the py lib.</p>
</div>
<div class="section" id="documentation-and-testing">
<h2>12.2. Documentation and Testing<a class="headerlink" href="#documentation-and-testing" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>generally we want to drive and interweave coding of
documentation, tests and real code as much as possible.
Without good documentation others may never know about
your latest and greatest feature.</li>
</ul>
</div>
<div class="section" id="naming">
<h2>12.3. naming<a class="headerlink" href="#naming" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>directories, modules and namespaces are always <strong>lowercase</strong></li>
<li>classes and especially Exceptions are most often <strong>CamelCase</strong></li>
<li>types, i.e. very widely usable classes like the <tt class="docutils literal"><span class="pre">py.path</span></tt>
family are all lower case.</li>
<li>never use plural names in directory and file names</li>
<li>functions/methods are lowercase and <tt class="docutils literal"><span class="pre">_</span></tt> - separated if
you really need to separate at all</li>
<li>it&#8217;s appreciated if you manage to name files in a directory
so that tab-completion on the shell level is as easy as possible.</li>
</ul>
</div>
<div class="section" id="committing">
<h2>12.4. committing<a class="headerlink" href="#committing" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>adding features requires adding appropriate tests.</li>
<li>bug fixes should be encoded in a test before being fixed.</li>
<li>write telling log messages because several people
will read your diffs, and we plan to have a search facility
over the py lib&#8217;s subversion repository.</li>
<li>if you add <tt class="docutils literal"><span class="pre">.txt</span></tt> or <tt class="docutils literal"><span class="pre">.py</span></tt> files to the repository then
please make sure you have <tt class="docutils literal"><span class="pre">svn:eol-style</span></tt> set to native.
which allows checkin/checkout in native line-ending format.</li>
</ul>
</div>
<div class="section" id="miscellaneous">
<h2>12.5. Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>Tests are the insurance that your code will be maintained
further and survives major releases.</li>
<li>Try to put the tests close to the tested code, don&#8217;t
overload directories with names.</li>
<li>If you think of exporting new py lib APIs, discuss it first on the
<a class="reference external" href="http://codespeak.net/mailman/listinfo/py-dev">py-dev mailing list</a> and possibly write a chapter in our
<cite>future_</cite> book. Communication is considered a key here to make
sure that the py lib develops in a consistent way.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="">12. Coding Style for the Py lib and friendly applications</a><ul>
<li><a class="reference external" href="#honour-pep-8-style-guide-for-python-code">12.1. Honour PEP 8: Style Guide for Python Code</a></li>
<li><a class="reference external" href="#documentation-and-testing">12.2. Documentation and Testing</a></li>
<li><a class="reference external" href="#naming">12.3. naming</a></li>
<li><a class="reference external" href="#committing">12.4. committing</a></li>
<li><a class="reference external" href="#miscellaneous">12.5. Miscellaneous</a></li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/coding-style.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" size="18" />
<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="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><a href="index.html">py lib v1.0.0b1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2009, Holger Krekel.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.7.
</div>
</body>
</html>