~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/development/policy/doc-standard.html

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
 
2
  <head>
 
3
<title>Twisted Documentation: HTML Documentation Standard for Twisted</title>
 
4
<link href="../../howto/stylesheet.css" rel="stylesheet" type="text/css"/>
 
5
  </head>
 
6
 
 
7
  <body bgcolor="white">
 
8
    <h1 class="title">HTML Documentation Standard for Twisted</h1>
 
9
    <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>
 
10
    <div class="content">
 
11
    <span/>
 
12
 
 
13
    <h2>Allowable Tags<a name="auto0"/></h2>
 
14
 
 
15
    <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>
 
16
 
 
17
    <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>
 
18
 
 
19
    <h2>Multi-line Code Snippets<a name="auto1"/></h2>
 
20
 
 
21
    <p>Multi-line code snippets should be delimited with a
 
22
    &lt;pre&gt; tag, with a mandatory <q>class</q> attribute. The
 
23
    conventionalized classes are <q>python</q>, <q>python-interpreter</q>,
 
24
    and <q>shell</q>. For example:</p>
 
25
 
 
26
    <h3><q>python</q><a name="auto2"/></h3>
 
27
<pre xml:space="preserve">
 
28
    &lt;p&gt;
 
29
    For example, this is how one defines a Resource:
 
30
    &lt;/p&gt;
 
31
 
 
32
    &lt;pre class=&quot;python&quot;&gt;
 
33
from twisted.web import resource
 
34
 
 
35
class MyResource(resource.Resource):
 
36
    def render_GET(self, request):
 
37
        return &quot;Hello, world!&quot;
 
38
    &lt;/pre&gt;
 
39
</pre>
 
40
 
 
41
    <p>For example, this is how one defines a Resource:</p>
 
42
<pre class="python"><p class="py-linenumber">1
 
43
2
 
44
3
 
45
4
 
46
5
 
47
</p><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>
 
48
 
 
49
<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>):
 
50
    <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>):
 
51
        <span class="py-src-keyword">return</span> <span class="py-src-string">&quot;Hello, world!&quot;</span>
 
52
</pre>
 
53
 
 
54
    <p>Note that you should never have leading indentation inside a
 
55
    &lt;pre&gt; block -- this makes it hard for readers to
 
56
    copy/paste the code.</p>
 
57
 
 
58
    <h3><q>python-interpreter</q><a name="auto3"/></h3>
 
59
<pre xml:space="preserve">
 
60
    &lt;pre class=&quot;python-interpreter&quot;&gt;
 
61
    &amp;gt;&amp;gt;&amp;gt; from twisted.web import resource
 
62
    &amp;gt;&amp;gt;&amp;gt; class MyResource(resource.Resource):
 
63
    ...     def render_GET(self, request):
 
64
    ...         return &quot;Hello, world!&quot;
 
65
    ...
 
66
    &amp;gt;&amp;gt;&amp;gt; MyResource().render_GET(None)
 
67
    &quot;Hello, world!&quot;
 
68
    &lt;/pre&gt;
 
69
</pre>
 
70
 
 
71
<pre class="python-interpreter" xml:space="preserve">
 
72
&gt;&gt;&gt; from twisted.web import resource
 
73
&gt;&gt;&gt; class MyResource(resource.Resource):
 
74
...     def render_GET(self, request):
 
75
...         return &quot;Hello, world!&quot;
 
76
...
 
77
&gt;&gt;&gt; MyResource().render_GET(None)
 
78
&quot;Hello, world!&quot;
 
79
</pre>
 
80
 
 
81
    <h3><q>shell</q><a name="auto4"/></h3>
 
82
<pre xml:space="preserve">
 
83
    &lt;pre class=&quot;shell&quot;&gt;
 
84
    $ twistd web --path /var/www
 
85
    &lt;/pre&gt;
 
86
</pre>
 
87
 
 
88
<pre class="shell" xml:space="preserve">
 
89
$ twistd web --path /var/www
 
90
</pre>
 
91
 
 
92
    <h2>Code inside paragraph text<a name="auto5"/></h2>
 
93
 
 
94
    <p>For single-line code-snippets and attribute, method, class,
 
95
    and module names, use the &lt;code&gt; tag, with a class of
 
96
    <q>API</q> or <q>python</q>. During processing, module or class-names
 
97
    with class <q>API</q> will automatically be looked up in the API
 
98
    reference and have a link placed around it referencing the
 
99
    actual API documents for that module/classname. If you wish to
 
100
    reference an API document, then make sure you at least have a
 
101
    single module-name so that the processing code will be able to
 
102
    figure out which module or class you're referring to.</p>
 
103
 
 
104
    <p>You may also use the <code>base</code> attribute in conjuction
 
105
    with a class of <q>API</q> to indicate the module that should be prepended
 
106
    to the module or classname.  This is to help keep the documentation
 
107
    clearer and less cluttered by allowing links to API docs that don't
 
108
    need the module name.</p>
 
109
<pre xml:space="preserve">
 
110
        &lt;p&gt;
 
111
    To add a &lt;code class=&quot;API&quot;&gt;twisted.web.widgets.Widget&lt;/code&gt;
 
112
    instance to a &lt;code class=&quot;API&quot;
 
113
    base=&quot;twisted.web.widgets&quot;&gt;Gadget&lt;/code&gt; instance, do 
 
114
    &lt;code class=&quot;python&quot;&gt;myGadget.putWidget(&quot;widgetPath&quot;,
 
115
    MyWidget())&lt;/code&gt;.  
 
116
        &lt;/p&gt;
 
117
    
 
118
        &lt;p&gt; 
 
119
    (implementation note: the widgets are stored in the &lt;code
 
120
    class=&quot;python&quot;&gt;gadgetInstance.widgets&lt;/code&gt; attribute,
 
121
    which is a
 
122
    list.)
 
123
        &lt;/p&gt;
 
124
    
 
125
</pre>
 
126
 
 
127
<div class="boxed">
 
128
        <p>
 
129
    To add a <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.web.widgets.Widget.html" title="twisted.web.widgets.Widget">twisted.web.widgets.Widget</a></code>
 
130
    instance to a <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.web.widgets.Gadget.html" title="twisted.web.widgets.Gadget">Gadget</a></code>
 
131
    instance, do
 
132
    <code class="python">myGadget.putWidget(&quot;widgetPath&quot;, MyWidget())</code>.
 
133
        </p>
 
134
 
 
135
        <p>
 
136
    (implementation note: the widgets are stored in the <code class="python">gadgetInstance.widgets</code> attribute,
 
137
    which is a
 
138
    list.)
 
139
        </p>
 
140
 
 
141
</div>
 
142
 
 
143
    <h2>Headers<a name="auto6"/></h2>
 
144
 
 
145
    <p>It goes without mentioning that you should use &lt;hN&gt; in
 
146
    a sane way -- &lt;h1&gt; should only appear once in the
 
147
    document, to specify the title. Sections of the document should
 
148
    use &lt;h2&gt;, sub-headers &lt;h3&gt;, and so on.</p>
 
149
 
 
150
    <h2>XHTML<a name="auto7"/></h2>
 
151
 
 
152
    <p>XHTML is mandatory. That means tags that don't have a
 
153
    closing tag need a <q>/</q>; for example, <code>&lt;hr /&gt;</code>
 
154
    . Also, tags which have <q>optional</q> closing tags in HTML
 
155
    <em>need</em> to be closed in XHTML; for example,
 
156
    <code>&lt;li&gt;foo&lt;/li&gt;</code></p>
 
157
 
 
158
    <h2>Tag Case<a name="auto8"/></h2>
 
159
 
 
160
    <p>All tags will be done in lower-case. XHTML demands this, and
 
161
    so do I. :-)</p>
 
162
 
 
163
    <h2>Footnotes<a name="auto9"/></h2>
 
164
 
 
165
    <p>Footnotes are enclosed inside 
 
166
    <code>&lt;span class=&quot;footnote&quot;&gt;&lt;/span&gt;</code>. They must not
 
167
    contain any markup.</p>
 
168
 
 
169
    <h2>Suggestions<a name="auto10"/></h2>
 
170
 
 
171
    <p>Use <code class="shell">lore -o lint</code> to check your documentation
 
172
    is not broken. <code class="shell">lore -o lint</code> will never change
 
173
    your HTML, but it will complain if it doesn't like it.</p>
 
174
 
 
175
    <p>Don't use tables for formatting. 'nuff said.</p>
 
176
 
 
177
    <h2>__all__<a name="auto11"/></h2>
 
178
    
 
179
    <p><code class="python">__all__</code> is a module level list of strings, naming
 
180
    objects in the module that are public. Make sure publically exported classes,
 
181
    functions and constants are listed here.</p>
 
182
 
 
183
  </div>
 
184
 
 
185
    <p><a href="../../howto/index.html">Index</a></p>
 
186
    <span class="version">Version: 10.0.0</span>
 
187
  </body>
 
188
</html>
 
 
b'\\ No newline at end of file'