doc-standard.xhtml   [plain text]


<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>HTML Documentation Standard for Twisted</title>
  </head>

  <body>
    <h1>HTML Documentation Standard for Twisted</h1>

    <h2>Allowable Tags</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>"</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</h2>

    <p>Multi-line code snippets should be delimited with a
    &lt;pre&gt; tag, with a mandatory <q>class</q> attribute. The
    conventionalized classes are <q>python</q>, <q>python-interpreter</q>,
    and <q>shell</q>. For example:</p>

    <h3><q>python</q></h3>
<pre>
    &lt;p&gt;
    For example, this is how one defines a Resource:
    &lt;/p&gt;

    &lt;pre class="python"&gt;
from twisted.web import resource

class MyResource(resource.Resource):
    def render_GET(self, request):
        return "Hello, world!"
    &lt;/pre&gt;
</pre>

    <p>For example, this is how one defines a Resource:</p>
<pre class="python">
from twisted.web import resource

class MyResource(resource.Resource):
    def render_GET(self, request):
        return "Hello, world!"
   
</pre>

    <p>Note that you should never have leading indentation inside a
    &lt;pre&gt; block -- this makes it hard for readers to
    copy/paste the code.</p>

    <h3><q>python-interpreter</q></h3>
<pre>
    &lt;pre class="python-interpreter"&gt;
    &amp;gt;&amp;gt;&amp;gt; from twisted.web import resource
    &amp;gt;&amp;gt;&amp;gt; class MyResource(resource.Resource):
    ...     def render_GET(self, request):
    ...         return "Hello, world!"
    ...
    &amp;gt;&amp;gt;&amp;gt; MyResource().render_GET(None)
    "Hello, world!"
    &lt;/pre&gt;
</pre>

<pre class="python-interpreter">
&gt;&gt;&gt; from twisted.web import resource
&gt;&gt;&gt; class MyResource(resource.Resource):
...     def render_GET(self, request):
...         return "Hello, world!"
...
&gt;&gt;&gt; MyResource().render_GET(None)
"Hello, world!"
</pre>

    <h3><q>shell</q></h3>
<pre>
    &lt;pre class="shell"&gt;
    $ mktap web --path /var/www
    &lt;/pre&gt;
</pre>

<pre class="shell">
$ mktap web --path /var/www
</pre>

    <h2>Code inside paragraph text</h2>

    <p>For single-line code-snippets and attribute, method, class,
    and module names, use the &lt;code&gt; tag, with a class of
    <q>API</q> or <q>python</q>. During processing, module or class-names
    with class <q>API</q> will automatically be looked up in the API
    reference and have a link placed around it referencing the
    actual API documents for that module/classname. If you wish to
    reference an API document, then make sure you at least have a
    single module-name so that the processing code will be able to
    figure out which module or class you're referring to.</p>

    <p>You may also use the <code>base</code> attribute in conjuction
    with a class of <q>API</q> to indicate the module that should be prepended
    to the module or classname.  This is to help keep the documentation
    clearer and less cluttered by allowing links to API docs that don't
    need the module name.</p>
<pre>
        &lt;p&gt;
    To add a &lt;code class="API"&gt;twisted.web.widgets.Widget&lt;/code&gt;
    instance to a &lt;code class="API"
    base="twisted.web.widgets"&gt;Gadget&lt;/code&gt; instance, do 
    &lt;code class="python"&gt;myGadget.putWidget("widgetPath",
    MyWidget())&lt;/code&gt;.  
        &lt;/p&gt;
    
        &lt;p&gt; 
    (implementation note: the widgets are stored in the &lt;code
    class="python"&gt;gadgetInstance.widgets&lt;/code&gt; attribute,
    which is a
    list.)
        &lt;/p&gt;
    
</pre>

<div class="boxed">
        <p>
    To add a <code class="API">twisted.web.widgets.Widget</code>
    instance to a <code class="API" base="twisted.web.widgets">Gadget</code>
    instance, do
    <code class="python">myGadget.putWidget("widgetPath", MyWidget())</code>.
        </p>

        <p>
    (implementation note: the widgets are stored in the <code
    class="python">gadgetInstance.widgets</code> attribute,
    which is a
    list.)
        </p>

</div>

    <h2>Headers</h2>

    <p>It goes without mentioning that you should use &lt;hN&gt; in
    a sane way -- &lt;h1&gt; should only appear once in the
    document, to specify the title. Sections of the document should
    use &lt;h2&gt;, sub-headers &lt;h3&gt;, and so on.</p>

    <h2>XHTML</h2>

    <p>XHTML is mandatory. That means tags that don't have a
    closing tag need a <q>/</q>; for example, <code>&lt;hr /&gt;</code>
    . Also, tags which have <q>optional</q> closing tags in HTML
    <em>need</em> to be closed in XHTML; for example,
    <code>&lt;li&gt;foo&lt;/li&gt;</code></p>

    <h2>Tag Case</h2>

    <p>All tags will be done in lower-case. XHTML demands this, and
    so do I. :-)</p>

    <h2>Footnotes</h2>

    <p>Footnotes are enclosed inside 
    <code>&lt;span class="footnote"&gt;&lt;/span&gt;</code>. They must not
    contain any markup.</p>

    <h2>Suggestions</h2>

    <p>Use <code class="shell">lore -o lint</code> to check your documentation
    is not broken. <code class="shell">lore -o lint</code> will never change
    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__</h2>
    
    <p><code class="python">__all__</code> is a module level list of strings, naming
    objects in the module that are public. Make sure publically exported classes,
    functions and constants are listed here.</p>

  </body>
</html>