~lvh/twisted/finger-tutorial-4679

« back to all changes in this revision

Viewing changes to doc/lore/howto/extend-lore.xhtml

  • Committer: exarkun
  • Date: 2010-09-18 12:33:49 UTC
  • Revision ID: svn-v4:bbbe8e31-12d6-0310-92fd-ac37d47ddeeb:trunk:30030
Merge sphinx-lore-4571

Author: jdb
Reviewer: exarkun
Fixes: #4571

Tweaks to the Lore markup in the Lore documentation to make it
more amenable to conversion to Sphinx.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
<h2>Inputs and Outputs</h2>
26
26
 
27
 
<p>Lore works by reading the HTML source of your document, and producing
28
 
whatever output the user specifies on the command line.  If the HTML document
29
 
is well-formed XML that meets a certain minimum standard, Lore will be able to
30
 
to produce some output.  All Lore extensions will be written to redefine the
31
 
<em>input</em>, and most will redefine the output in some way.  The name of
32
 
the default input is <q>lore</q>.  When you write your extension, you will
33
 
come up with a new name for your input, telling Lore what rules to use to
34
 
process the file.</p>
 
27
<p>Lore works by reading the HTML source of your document, and
 
28
producing whatever output the user specifies on the command line.  If
 
29
the HTML document is well-formed XML that meets a certain minimum
 
30
standard, Lore will be able to to produce some output.  All Lore
 
31
extensions will be written to redefine the <em>input</em>, and most
 
32
will redefine the output in some way.  The name of the default input
 
33
is <q>lore</q>.  When you write your extension, you will come up with
 
34
a new name for your input, telling Lore what rules to use to process
 
35
the file.</p>
35
36
 
36
37
<p>Lore can produce XHTML, LaTeX, and DocBook document formats, which can be
37
38
displayed directly if you have a user agent capable of viewing them, or
91
92
<a href="listings/lore/factory.py-1" class="py-listing">Listing 2: The Input
92
93
  Factory</a>
93
94
 
94
 
<p>In Listing 2, we create a subclass of ProcessingFunctionFactory.  This
95
 
class provides a hook for you, a class variable named
96
 
<code>latexSpitters</code>.  This variable tells Lore
97
 
what new class will be generating LaTeX from your input format.  We redefine
98
 
<code>latexSpitters</code> to <code>MyLatexSpitter</code> in the subclass
99
 
because this
100
 
class knows what to do with the new input we have already defined.  Last, you
101
 
must define the module-level variable <code
102
 
    class="py-src-identifier">factory</code>.  It should be an instance with
103
 
  the same
104
 
interface as <code class="py-src-identifier">ProcessingFunctionFactory</code>
105
 
(e.g. an instance of a subclass, in this case, <code
106
 
    class="py-src-identifier">MyProcessingFunctionFactory</code>).</p>
 
95
<p>In Listing 2, we create a subclass of ProcessingFunctionFactory.
 
96
This class provides a hook for you, a class variable
 
97
named <code>latexSpitters</code>.  This variable tells Lore what new
 
98
class will be generating LaTeX from your input format.  We
 
99
redefine <code>latexSpitters</code> to <code>MyLatexSpitter</code> in
 
100
the subclass because this class knows what to do with the new input we
 
101
have already defined.  Last, you must define the module-level
 
102
variable <code class="py-src-identifier">factory</code>.  It should be
 
103
an instance with the same interface
 
104
as <code class="py-src-identifier">ProcessingFunctionFactory</code>
 
105
(e.g. an instance of a subclass, in this
 
106
case, <code class="py-src-identifier">MyProcessingFunctionFactory</code>).</p>
107
107
 
108
108
<p>Now let's actually write some code to generate the LaTeX.  Doing this
109
109
requires at least a familiarity with the LaTeX language.  Search Google for
113
113
<a href="listings/lore/spitters.py-1" class="py-listing">Listing 3:
114
114
  spitters.py</a>
115
115
 
116
 
<p>The method <code>visitNode_span_productname</code> is
117
 
our handler for &lt;span&gt; tags with the <code>class="productname"</code>
118
 
identifier.  Lore knows to try methods <code>visitNode_span_*</code> and
119
 
<code>visitNode_div_*</code> whenever it encounters a new
120
 
class in one of these tags.  This is why the class names have to be valid
 
116
<p>The method <code>visitNode_span_productname</code> is our handler
 
117
for &lt;span&gt; tags with the <code>class="productname"</code>
 
118
identifier.  Lore knows to try methods <code>visitNode_span_*</code>
 
119
and <code>visitNode_div_*</code> whenever it encounters a new class in
 
120
one of these tags.  This is why the class names have to be valid
121
121
Python identifiers.</p>
122
122
 
123
123
<p>Now let's see what Lore does with these new classes with the following