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><html></code>, <code><title></code>, <code><head></code>, <code><body></code>, <code><h1></code>, <code><h2</code>, <code><h3></code>, <code><ol></code>, <code><ul></code>, <code><dl></code>, <code><li></code>, <code><dt></code>, <code><dd></code>, <code><p></code>, <code><code></code>, <code><img></code>, <code><blockquote></code>, <code><a></code>, <code><cite></code>, <code><div></code>, <code><span></code>, <code><strong></code>, <code><em></code>, <code><pre></code>, <code><q></code>, <code><table></code>,<code><tr></code>, <code><td></code> and <code><th></code>.</p>
<p>Please avoid using the quote sign (<code>"</code>) for quoting, and use the relevant html tags (<code><q></q></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
<pre> 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>
<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>
</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
<pre> block -- this makes it hard for readers to
copy/paste the code.</p>
<h3><q>python-interpreter</q></h3>
<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>
</pre>
<pre class="python-interpreter">
>>> from twisted.web import resource
>>> class MyResource(resource.Resource):
... def render_GET(self, request):
... return "Hello, world!"
...
>>> MyResource().render_GET(None)
"Hello, world!"
</pre>
<h3><q>shell</q></h3>
<pre>
<pre class="shell">
$ mktap web --path /var/www
</pre>
</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 <code> 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>
<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>
</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 <hN> in
a sane way -- <h1> should only appear once in the
document, to specify the title. Sections of the document should
use <h2>, sub-headers <h3>, 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><hr /></code>
. Also, tags which have <q>optional</q> closing tags in HTML
<em>need</em> to be closed in XHTML; for example,
<code><li>foo</li></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><span class="footnote"></span></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>