\section{HTML Documentation Standard for Twisted\label{doc/howto/policy/doc-standard.xhtml}}


\subsection{Allowable Tags}


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): \texttt{<html>}, \texttt{<title>}, \texttt{<head>}, \texttt{<body>}, \texttt{<h1>}, \texttt{<h2}, \texttt{<h3>}, \texttt{<ol>}, \texttt{<ul>}, \texttt{<dl>}, \texttt{<li>},   \texttt{<dt>}, \texttt{<dd>}, \texttt{<p>}, \texttt{<code>},  \texttt{<img>},  \texttt{<blockquote>},  \texttt{<a>},  \texttt{<cite>}, \texttt{<div>}, \texttt{<span>}, \texttt{<strong>}, \texttt{<em>}, \texttt{<pre>}, \texttt{<q>}, \texttt{<table>},\texttt{<tr>}, \texttt{<td>} and \texttt{<th>}.

Please avoid using the quote sign (\texttt{"}) for quoting, and use the relevant html tags (\texttt{<q></q>}) -- it is impossible to distinguish right and left quotes with the quote sign, and some more sophisticated output methods work better with that distinction.

\subsection{Multi-line Code Snippets}


Multi-line code snippets should be delimited with a     $<$pre$>$ tag, with a mandatory ``class'' attribute. The     conventionalized classes are ``python'', ``python-interpreter'',     and ``shell''. For example:

\subsubsection{``python''}
\begin{verbatim}
    <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>
\end{verbatim}


For example, this is how one defines a Resource:\begin{verbatim}
from twisted.web import resource

class MyResource(resource.Resource):
    def render_GET(self, request):
        return "Hello, world!"
\end{verbatim}


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

\subsubsection{``python-interpreter''}
\begin{verbatim}
    <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>
\end{verbatim}
\begin{verbatim}
>>> from twisted.web import resource
>>> class MyResource(resource.Resource):
...     def render_GET(self, request):
...         return "Hello, world!"
...
>>> MyResource().render_GET(None)
"Hello, world!"
\end{verbatim}


\subsubsection{``shell''}
\begin{verbatim}
    <pre class="shell">
    $ mktap web --path /var/www
    </pre>
\end{verbatim}
\begin{verbatim}
$ mktap web --path /var/www
\end{verbatim}


\subsection{Code inside paragraph text}


For single-line code-snippets and attribute, method, class,     and module names, use the $<$code$>$ tag, with a class of     ``API'' or ``python''. During processing, module or class-names     with class ``API'' 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.

You may also use the \texttt{base} attribute in conjuction     with a class of ``API'' 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.\begin{verbatim}
        <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>
\end{verbatim}


     To add a \texttt{twisted.\linebreak[1]web.\linebreak[1]widgets.\linebreak[1]Widget}     instance to a \texttt{Gadget}     instance, do     \texttt{my\linebreak[1]Gadget.\linebreak[1]put\linebreak[1]Widget("widget\linebreak[1]Path", My\linebreak[1]Widget())}.         

     (implementation note: the widgets are stored in the \texttt{gadget\linebreak[1]Instance.\linebreak[1]widgets} attribute,     which is a     list.)         

\subsection{Headers}


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.

\subsection{XHTML}


XHTML is mandatory. That means tags that don't have a     closing tag need a ``/''; for example, \texttt{<hr />}     . Also, tags which have ``optional'' closing tags in HTML     \begin{em}need\end{em} to be closed in XHTML; for example,     \texttt{<li>foo</li>}

\subsection{Tag Case}


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

\subsection{Footnotes}


Footnotes are enclosed inside      \texttt{<span class="footnote"></span>}. They must not     contain any markup.

\subsection{Suggestions}


Use \texttt{lore -o lint} to check your documentation     is not broken. \texttt{lore -o lint} will never change     your HTML, but it will complain if it doesn't like it.

Don't use tables for formatting. 'nuff said.

\subsection{\_\_all\_\_}


\texttt{\_\_all\_\_} 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.