~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to doc/development/policy/doc-standard.html

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>Twisted Documentation: HTML Documentation Standard for Twisted</title><link href="../howto/stylesheet.css" type="text/css" rel="stylesheet" /></head><body bgcolor="white"><h1 class="title">HTML Documentation Standard for Twisted</h1><div class="toc"><ol><li><a href="#auto0">Allowable Tags</a></li><li><a href="#auto1">Multi-line Code Snippets</a></li><ul><li><a href="#auto2">python</a></li><li><a href="#auto3">python-interpreter</a></li><li><a href="#auto4">shell</a></li></ul><li><a href="#auto5">Code inside paragraph text</a></li><li><a href="#auto6">Headers</a></li><li><a href="#auto7">XHTML</a></li><li><a href="#auto8">Tag Case</a></li><li><a href="#auto9">Footnotes</a></li><li><a href="#auto10">Suggestions</a></li><li><a href="#auto11">__all__</a></li></ol></div><div class="content"><span></span><h2>Allowable Tags<a name="auto0"></a></h2><p>Please try to restrict your HTML usage to the following tags (all only for the original logical purpose, and not whatever visual effect you see): <code>&lt;html&gt;</code>, <code>&lt;title&gt;</code>, <code>&lt;head&gt;</code>, <code>&lt;body&gt;</code>, <code>&lt;h1&gt;</code>, <code>&lt;h2</code>, <code>&lt;h3&gt;</code>, <code>&lt;ol&gt;</code>, <code>&lt;ul&gt;</code>, <code>&lt;dl&gt;</code>, <code>&lt;li&gt;</code>,   <code>&lt;dt&gt;</code>, <code>&lt;dd&gt;</code>, <code>&lt;p&gt;</code>, <code>&lt;code&gt;</code>,  <code>&lt;img&gt;</code>,  <code>&lt;blockquote&gt;</code>,  <code>&lt;a&gt;</code>,  <code>&lt;cite&gt;</code>, <code>&lt;div&gt;</code>, <code>&lt;span&gt;</code>, <code>&lt;strong&gt;</code>, <code>&lt;em&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;q&gt;</code>, <code>&lt;table&gt;</code>,<code>&lt;tr&gt;</code>, <code>&lt;td&gt;</code> and <code>&lt;th&gt;</code>.</p><p>Please avoid using the quote sign (<code>&quot;</code>) for quoting, and use the relevant html tags (<code>&lt;q&gt;&lt;/q&gt;</code>) -- it is impossible to distinguish right and left quotes with the quote sign, and some more sophisticated output methods work better with that distinction.</p><h2>Multi-line Code Snippets<a name="auto1"></a></h2><p>Multi-line code snippets should be delimited with a
 
3
    &lt;pre&gt; tag, with a mandatory <q>class</q> attribute. The
 
4
    conventionalized classes are <q>python</q>, <q>python-interpreter</q>,
 
5
    and <q>shell</q>. For example:</p><h3><q>python</q><a name="auto2"></a></h3><pre>
 
6
    &lt;p&gt;
 
7
    For example, this is how one defines a Resource:
 
8
    &lt;/p&gt;
 
9
 
 
10
    &lt;pre class=&quot;python&quot;&gt;
 
11
from twisted.web import resource
 
12
 
 
13
class MyResource(resource.Resource):
 
14
    def render_GET(self, request):
 
15
        return &quot;Hello, world!&quot;
 
16
    &lt;/pre&gt;
 
17
</pre><p>For example, this is how one defines a Resource:</p><pre class="python">
 
18
<span class="py-src-keyword">from</span> <span class="py-src-variable">twisted</span>.<span class="py-src-variable">web</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">resource</span>
 
19
 
 
20
<span class="py-src-keyword">class</span> <span class="py-src-identifier">MyResource</span>(<span class="py-src-parameter">resource</span>.<span class="py-src-parameter">Resource</span>):
 
21
    <span class="py-src-keyword">def</span> <span class="py-src-identifier">render_GET</span>(<span class="py-src-parameter">self</span>, <span class="py-src-parameter">request</span>):
 
22
        <span class="py-src-keyword">return</span> <span class="py-src-string">&quot;Hello, world!&quot;</span>
 
23
</pre><p>Note that you should never have leading indentation inside a
 
24
    &lt;pre&gt; block -- this makes it hard for readers to
 
25
    copy/paste the code.</p><h3><q>python-interpreter</q><a name="auto3"></a></h3><pre>
 
26
    &lt;pre class=&quot;python-interpreter&quot;&gt;
 
27
    &amp;gt;&amp;gt;&amp;gt; from twisted.web import resource
 
28
    &amp;gt;&amp;gt;&amp;gt; class MyResource(resource.Resource):
 
29
    ...     def render_GET(self, request):
 
30
    ...         return &quot;Hello, world!&quot;
 
31
    ...
 
32
    &amp;gt;&amp;gt;&amp;gt; MyResource().render_GET(None)
 
33
    &quot;Hello, world!&quot;
 
34
    &lt;/pre&gt;
 
35
</pre><pre class="python-interpreter">
 
36
&gt;&gt;&gt; from twisted.web import resource
 
37
&gt;&gt;&gt; class MyResource(resource.Resource):
 
38
...     def render_GET(self, request):
 
39
...         return &quot;Hello, world!&quot;
 
40
...
 
41
&gt;&gt;&gt; MyResource().render_GET(None)
 
42
&quot;Hello, world!&quot;
 
43
</pre><h3><q>shell</q><a name="auto4"></a></h3><pre>
 
44
    &lt;pre class=&quot;shell&quot;&gt;
 
45
    $ mktap web --path /var/www
 
46
    &lt;/pre&gt;
 
47
</pre><pre class="shell">
 
48
$ mktap web --path /var/www
 
49
</pre><h2>Code inside paragraph text<a name="auto5"></a></h2><p>For single-line code-snippets and attribute, method, class,
 
50
    and module names, use the &lt;code&gt; tag, with a class of
 
51
    <q>API</q> or <q>python</q>. During processing, module or class-names
 
52
    with class <q>API</q> will automatically be looked up in the API
 
53
    reference and have a link placed around it referencing the
 
54
    actual API documents for that module/classname. If you wish to
 
55
    reference an API document, then make sure you at least have a
 
56
    single module-name so that the processing code will be able to
 
57
    figure out which module or class you're referring to.</p><p>You may also use the <code>base</code> attribute in conjuction
 
58
    with a class of <q>API</q> to indicate the module that should be prepended
 
59
    to the module or classname.  This is to help keep the documentation
 
60
    clearer and less cluttered by allowing links to API docs that don't
 
61
    need the module name.</p><pre>
 
62
        &lt;p&gt;
 
63
    To add a &lt;code class=&quot;API&quot;&gt;twisted.web.widgets.Widget&lt;/code&gt;
 
64
    instance to a &lt;code class=&quot;API&quot;
 
65
    base=&quot;twisted.web.widgets&quot;&gt;Gadget&lt;/code&gt; instance, do 
 
66
    &lt;code class=&quot;python&quot;&gt;myGadget.putWidget(&quot;widgetPath&quot;,
 
67
    MyWidget())&lt;/code&gt;.  
 
68
        &lt;/p&gt;
 
69
    
 
70
        &lt;p&gt; 
 
71
    (implementation note: the widgets are stored in the &lt;code
 
72
    class=&quot;python&quot;&gt;gadgetInstance.widgets&lt;/code&gt; attribute,
 
73
    which is a
 
74
    list.)
 
75
        &lt;/p&gt;
 
76
    
 
77
</pre><div class="boxed"><p>
 
78
    To add a <code class="API">twisted.web.widgets.Widget</code>
 
79
    instance to a <code base="twisted.web.widgets" class="API">Gadget</code>
 
80
    instance, do
 
81
    <code class="python">myGadget.putWidget(&quot;widgetPath&quot;, MyWidget())</code>.
 
82
        </p><p>
 
83
    (implementation note: the widgets are stored in the <code class="python">gadgetInstance.widgets</code> attribute,
 
84
    which is a
 
85
    list.)
 
86
        </p></div><h2>Headers<a name="auto6"></a></h2><p>It goes without mentioning that you should use &lt;hN&gt; in
 
87
    a sane way -- &lt;h1&gt; should only appear once in the
 
88
    document, to specify the title. Sections of the document should
 
89
    use &lt;h2&gt;, sub-headers &lt;h3&gt;, and so on.</p><h2>XHTML<a name="auto7"></a></h2><p>XHTML is mandatory. That means tags that don't have a
 
90
    closing tag need a <q>/</q>; for example, <code>&lt;hr /&gt;</code>
 
91
    . Also, tags which have <q>optional</q> closing tags in HTML
 
92
    <em>need</em> to be closed in XHTML; for example,
 
93
    <code>&lt;li&gt;foo&lt;/li&gt;</code></p><h2>Tag Case<a name="auto8"></a></h2><p>All tags will be done in lower-case. XHTML demands this, and
 
94
    so do I. :-)</p><h2>Footnotes<a name="auto9"></a></h2><p>Footnotes are enclosed inside 
 
95
    <code>&lt;span class=&quot;footnote&quot;&gt;&lt;/span&gt;</code>. They must not
 
96
    contain any markup.</p><h2>Suggestions<a name="auto10"></a></h2><p>Use <code class="shell">lore -o lint</code> to check your documentation
 
97
    is not broken. <code class="shell">lore -o lint</code> will never change
 
98
    your HTML, but it will complain if it doesn't like it.</p><p>Don't use tables for formatting. 'nuff said.</p><h2>__all__<a name="auto11"></a></h2><p><code class="python">__all__</code> is a module level list of strings, naming
 
99
    objects in the module that are public. Make sure publically exported classes,
 
100
    functions and constants are listed here.</p></div><p><a href="../howto/index.html">Index</a></p><span class="version">Version: 2.5.0</span></body></html>
 
 
b'\\ No newline at end of file'