Lore

Lore - A Document Generation System


Rory (Concert Interruptus, season 1) -- Yeah, well I've always thought easy is completely overrated.

Source Format


Alex (I Solemnly Swear, season 3) -- That would've been far too logical.

Output Formats


Madelaine (The Lorelais' First Day at Chilton, season 1) -- You don't know she's going out for the paper.

Minimal Lore Document

<html>
<head><title>Title</title></head>
<body><h1>Title</h1></body>
</html>

Luke (There's the Rub, season 2) -- You said minimal

Minimal Lore Document Explained


Tom (There's the Rub, season 2) -- Hey, this is minimal

External Listings


Kirk (Red Light on the Wedding Night, season 2) -- I include it as an example of the excellence I aspire to.

Using Lore to Generate HTML


Paris (Run Away, Little Boy, season 2) -- I went on the web and found this site

Generating LaTeX


Rory (Christopher Returns, season 1) -- He had already printed like a million

Using Lint


Max (The Deer-Hunters, season 1) -- I know a D seems pretty dismal

Further Reading


Paris (The Bracebridge Dinner, season 2) -- Rereading the Iliad a third time is not not doing anything

Questions?

Lorelai (Forgiveness and Stuff, season 1) -- A person needs details.

Bonus Slides

Miss James (The Lorelais' First Day at Chilton, season 1) -- If you do it in Latin you get extra credit.

Lore Alternatives - LaTeX


Michel (Love, Daisies and Troubadors, season 1) -- It increases my ennui

Lore Alternatives - HTML


Lorelai (Love, Daisies and Troubadors, season 1) -- It was broken [...] I'm not crazy

Lore Alternatives - Docbook


Rory (Hammers and Veils, season 2) -- What do you want me to do it?

Lore Alternatives - Texinfo


Man (Hammers and Veils, season 2) -- There's a ton of hurt that almost happened here.

Lore Alternatives - reST


Emily (Hammers and Veils, season 2) -- And this is what we need to discuss right now?

Lore Alternatives - LyX


Rory (Hammers and Veils, season 2) -- Well, it's just dressed up a little.

Some Standard Tags -- XHTML Primer


Rory (Kiss and Tell, season 1) -- See, even a little information in your hands is dangerous.

More HTML


Max (The Lorelais' First Day at Chilton, season 1) -- Tolstoy's favourite author, for instance, was...

More HTML -- cross references


Christopher (Christopher Returns, season 1) -- It's just a weird reference.

Special Markup


Taylor (Take The Deviled Eggs, season 3) -- Out attention spans are gnat-like tonight

API References


Lorelai (The Road Trip To Harvard, season 2) -- We're just kinda hanging out between classes

API References Explained


Luke (Love and War and Snow, season 1) -- How do you know? Do you have written documentation?

Inline Listings

<pre class="python">
def foo():
    return forbnicate(4)
</pre>

Taylor (Take The Deviled Eggs, season 3) -- That's not even English.

Inline Listings -- short


Rory (Double Date, season 1) -- It's like this weird code thing with her.

Generating HTML -- writing templates


Paris (I Can't Get Started, season 2) -- How's this sound for a template?

Generating HTML -- using commandline


Richard (The Third Lorelai, season 1) -- Your wish is my command.

Generating HTML -- using commandline -- examples


Jackson (A Deep-Fried Korean Thanksgiving, season 3) -- Deep-fried cake!

Generating HTML -- using commandline -- examples (cont'd)


Jackson (A Deep-Fried Korean Thanksgiving, season 3) -- Deep-fried shoe!

Generating HTML -- notes about stylesheets


Miss Patty (Cinnamon's Wake, season 1) -- If you had a better hair style I might consider dating

Generating LaTeX -- examples


Luke (Hammers and Veils, season 2) -- Just an example

Using Lint -- notes


Paris (The Deer-Hunters, season 1) -- That would be cause for concern.

Understanding Lint Warnings


Jess (Teach Me Tonight, season 2) -- I appreciate the warning.

Using Lore For Slides


Emily (Road Trip to Harvard, season 2) -- Why in the world do you insist on taking slides?

Extending Lore


Rory (The Lorelais' First Day at Chilton, season 1) -- Well, add a couple of plaid skirts

Extending Lore -- example


Lorelai (Presenting Lorelai Gilmore, season 2) -- No, no, if you wanna do it, I'll help. It's just weird.

Extending Lore -- example (cont'd)

# blinker/html.py
from twisted.lore import tree
from twisted.web import microdom, domhelpers

def doBlink(document):
    for node in domhelpers.findElementsWithAttribute(document, 'class',
                                                    'blink'):
        newNode = microdom.Element('blink')
        newNode.children = node.children
        node.parentNode.replaceChild(newNode, node)

def doFile(fn, docsdir, ext, url, templ, linkrel=''):
    doc = tree.parseFileAndReport(fn)
    doBlink(doc)
    cn = templ.cloneNode(1)
    tree.munge(doc, cn, linkrel, docsdir, fn, ext, url)
    cn.writexml(open(os.path.splitext(fn)[0]+ext, 'wb'))

Christopher (Presenting Lorelai Gilmore, season 2) -- I can't believe you're letting her do it.

Extending Lore -- example (cont'd 2)

# blinker/latex.py
class BlinkerLatexSpitter(latex.LatexSpitter):

    def visitNode_span_blink(self, node):
        self.writer('{\sc ')
        self.visitNodeDefault(node)
        self.writer('}')

Lorelai (Presenting Lorelai Gilmore, season 2) -- I'm sorry, I meant what scenario on my planet

Extending Lore -- example (cont'd 3)

# blinker/factory.py
from blinker import html, latex
from twisted.lore import default

class ProcessingFunctionFactory(default.ProcessingFunctionFactory):

    doFile = [doFile]

    latexSpitters = {None: latex.BlinkLatexSpitter}

    def getLintChecker(self):
        checker = lint.getDefaultChecker()
        checker.allowedClasses = checker.allowedClasses.copy()
        oldSpan = checker.allowedClasses['span']
        checker.allowedClasses['span'] = (lambda x:oldSpan(x) or
                                                     x=='blink')
        return checker

factory = ProcessingFunctionFactory()
# blinker/plugins.tml
register("Blink-Lore",
         "blinker.factory",
         description="Lore format with blink",
         type="lore",
         tapname="blinklore")

...and that's it!


Rory (Presenting Lorelai Gilmore, season 2) -- Sorry, we haven't tamed my wild ways yet.

Man page support


Lorelai (Concert Interruptus, season 1) -- would you like to write out some sort of instruction manual to go with the dishes?

Man page support


Lorelai (Concert Interruptus, season 1) -- would you like to write out some sort of instruction manual to go with the dishes?