Ejemplo n.º 1
0
def _writeClass(destPath, upThing, klass, nav, index, ns, toppath = ''):
    out = writer(open(destPath + '/m.%s%s.%s.html' % (
        upThing.name, toppath, klass.name), 'w'))
    nav = nav.newPlusAlter(up = 'm.%s%s.html' % (upThing.name, toppath),
                           upText = '%s <code>%s</code>' % (
                               upThing.__class__.__name__,
                               upThing.name))
    out('<HTML><HEAD><TITLE>Class %s</TITLE></HEAD>\n' % klass.name)
    out('<BODY BGCOLOR=WHITE FGCOLOR=BLACK>')
    out('<H2>Class %s</H2>' % common.plainEscape(klass.name))
    out(nav.render(1))
    out('<HR><TABLE CELLSPACING=10 BORDER=0 width=100%><TR>')
    out('<TD COLSPAN=2 BGCOLOR=%s>' % CLASS_COLOR)
    out('<H2>Class <code>%s</code></H2>' % klass.name)
    _writeInherits(upThing, klass, out, index, ns)
    out('<font size=-1>%s</font>' % renderDocString(klass.docString))
    _writeItemToc(klass, out, '%s%s.' % (toppath, upThing.name))
    out('</TD></TR>')
    out('<TR><TD BGCOLOR=%s><FONT COLOR=%s>---</font></TD><TD>' % (
        CLASS_COLOR, CLASS_COLOR))

    for item in klass.funcClasses:
        if item.__class__.__name__ == 'Function':
            _writeFunction(item, out)
        else: #it's a class
            out('<B>Class <A HREF="m.%s%s.%s.html">%s</A></B><BR>' % (
                toppath, klass.name, item.name, item.name))
            _writeClass(destPath, klass, item, nav, index, ns,
                        '%s%s.' % (toppath, klass.name))

    
    out('</TD></TR></TABLE><BR><HR>')
    out(nav.render(0))
    out('</BODY></HTML>')
Ejemplo n.º 2
0
def _writeModule(destPath, module, index, nav, ns):
    out = writer(open(destPath + '/m.%s.html' % module.name, 'w'))
    out('<HTML><HEAD><TITLE>Module %s</TITLE></HEAD>\n' % module.name)
    out('<BODY BGCOLOR=WHITE FGCOLOR=BLACK>')
    out('<H2>Module %s</H2>' % common.plainEscape(module.name))
    out(nav.render(1))
    out('<TD COLSPAN=2 BGCOLOR=%s>' % MODULE_COLOR)
    out('<HR><TABLE CELLSPACING=10 BORDER=0 width=100%><TR>')
    out('<TD COLSPAN=2 BGCOLOR=%s>' % MODULE_COLOR)
    out('<H2>Module <code>%s</code></H2>' % module.name)
    out('<font size=-1>%s</font>' % renderDocString(module.docString))
    _writeItemToc(module, out)
    out('</TD></TR>')
    out('<TR><TD BGCOLOR=%s><FONT COLOR=%s>----</font></TD><TD>' % (
        MODULE_COLOR, MODULE_COLOR))

    for item in module.funcClasses:
        if item.__class__.__name__ == 'Function':
            _writeFunction(item, out)
        else: #it's a class
            out('<B>Class <A HREF="m.%s.%s.html">%s</A></B><BR>' % (
                module.name, item.name, item.name))
            _writeClass(destPath, module, item, nav, index, ns)

    out('</TD></TR></TABLE><HR>')
    out(nav.render(0))
    out('</BODY></HTML>')
def _renderDocString( item ):
    '''**takes the parse node that represents the doc string and renders
    it into HTML'''
    s = []
    for subItem in item:
        if type( subItem ) == type( '' ): #'tis a string
            s.append( subItem )
        elif isinstance( subItem, ParseSkunkDoc.EntityContainer ):
            beginTag, endTag = getMarkup( subItem.tag, subItem.attributes )
            if subItem.tag == 'codeblock':
                s.append( '%s%s%s' % (
                    beginTag, common.plainEscape(subItem.getText())
                    , endTag))
            else:
                s.append( '%s%s%s' % (beginTag, _renderDocString( subItem ),
                          endTag ))

    #convert blank lines to <p>
    ns = string.join( s, '' )
    ns = string.replace(ns, '\r\n', '\n')
    return string.replace(ns, '\n\n', '\n<p>\n')
Ejemplo n.º 4
0
def _renderDocString( item ):
    '''**takes the parse node that represents the doc string and renders
    it into HTML'''
    s = []
    for subItem in item:
        if type( subItem ) == type( '' ): #'tis a string
            s.append( subItem )
        elif isinstance( subItem, ParseSkunkDoc.EntityContainer ):
            beginTag, endTag = getMarkup( subItem.tag, subItem.attributes )
            if subItem.tag == 'codeblock':
                s.append( '%s%s%s' % (
                    beginTag, common.plainEscape(subItem.getText())
                    , endTag))
            else:
                s.append( '%s%s%s' % (beginTag, _renderDocString( subItem ),
                          endTag ))

    #convert blank lines to <p>
    ns = string.join( s, '' )
    ns = string.replace(ns, '\r\n', '\n')
    return string.replace(ns, '\n\n', '\n<p>\n')
Ejemplo n.º 5
0
def _colorizeTagArgs(tagString):
    from DT.DTLexer import pcre, wsmatch, tagContentsRe
    #restolen from DT.DTLexer.processTag

    s = []
    tagname = ''
    off = 0

    tnmatch = None
    while not tnmatch:
        wsmatch = wsre.match(tagString, off, len(tagString), pcre.ANCHORED)
        if not wsmatch:
            tnmatch = plainre.match(tagString, off, len(tagString),
                                    pcre.ANCHORED)
            if not tnmatch:
                raise LexicalError('invalid tag name', tagString[off:off + 10])
            else:
                break
        off = wsmatch[0][1]

    tagname = tagString[tnmatch[0][0]:tnmatch[0][1]]

    off = tnmatch[0][1]
    lts = len(tagString)
    while off < lts:
        match = tagContentsRe.match(tagString, off, lts, pcre.ANCHORED)
        if match is None:
            raise LexicalError('invalid tag text name',
                               tagString[off:off + 10])
        if match[WHITESPACE] != (-1, -1):
            mb, me = match[WHITESPACE]
            s.append(tagString[mb:me])
            off = me
        elif match[PLAIN] != (-1, -1):
            mb, me = match[PLAIN]
            s.append('<FONT COLOR=PURPLE>%s</FONT>' %
                     plainEscape(tagString[mb:me]))
            off = me
        elif match[PLAINEQ] != (-1, -1):
            mb, me = match[PLAINEQ]
            tmb, tme = match[PLAINEQVAL]

            vvv = tagString[mb:tme]
            if vvv[0] == "`":
                s.append('<FONT COLOR=GREEN>')
            else:
                s.append('<FONT COLOR=PURPLE>')
            s.append(plainEscape(vvv))
            s.append('</FONT>')
            off = tme
        elif match[PLAINEQQ] != (-1, -1):
            mb, me = match[PLAINEQQ]
            tmb, tme = match[PLAINEQQVAL]
            if tagString[tmb] == "`":
                s.append('<FONT COLOR=GREEN>')
            else:
                s.append('<FONT COLOR=PURPLE>')
            s.append(plainEscape(tagString[mb:tme]))
            s.append('</FONT>')
            off = tme
        elif match[QUOTONLY] != (-1, -1):
            mb, me = match[QUOTONLY]

            vvv = tagString[mb:me]
            if vvv[0] == "`":
                s.append('<FONT COLOR=GREEN>')
            else:
                s.append('<FONT COLOR=PURPLE>')
            s.append(plainEscape(vvv))
            s.append('</FONT>')

            off = me
        else:
            raise LexicalError('unknown text in tag', tagString[off:off + 10])

    return string.join(s, '')
Ejemplo n.º 6
0
def _colorizeTagArgs(tagString):
    from DT.DTLexer import pcre, wsmatch, tagContentsRe

    # restolen from DT.DTLexer.processTag

    s = []
    tagname = ""
    off = 0

    tnmatch = None
    while not tnmatch:
        wsmatch = wsre.match(tagString, off, len(tagString), pcre.ANCHORED)
        if not wsmatch:
            tnmatch = plainre.match(tagString, off, len(tagString), pcre.ANCHORED)
            if not tnmatch:
                raise LexicalError("invalid tag name", tagString[off : off + 10])
            else:
                break
        off = wsmatch[0][1]

    tagname = tagString[tnmatch[0][0] : tnmatch[0][1]]

    off = tnmatch[0][1]
    lts = len(tagString)
    while off < lts:
        match = tagContentsRe.match(tagString, off, lts, pcre.ANCHORED)
        if match is None:
            raise LexicalError("invalid tag text name", tagString[off : off + 10])
        if match[WHITESPACE] != (-1, -1):
            mb, me = match[WHITESPACE]
            s.append(tagString[mb:me])
            off = me
        elif match[PLAIN] != (-1, -1):
            mb, me = match[PLAIN]
            s.append("<FONT COLOR=PURPLE>%s</FONT>" % plainEscape(tagString[mb:me]))
            off = me
        elif match[PLAINEQ] != (-1, -1):
            mb, me = match[PLAINEQ]
            tmb, tme = match[PLAINEQVAL]

            vvv = tagString[mb:tme]
            if vvv[0] == "`":
                s.append("<FONT COLOR=GREEN>")
            else:
                s.append("<FONT COLOR=PURPLE>")
            s.append(plainEscape(vvv))
            s.append("</FONT>")
            off = tme
        elif match[PLAINEQQ] != (-1, -1):
            mb, me = match[PLAINEQQ]
            tmb, tme = match[PLAINEQQVAL]
            if tagString[tmb] == "`":
                s.append("<FONT COLOR=GREEN>")
            else:
                s.append("<FONT COLOR=PURPLE>")
            s.append(plainEscape(tagString[mb:tme]))
            s.append("</FONT>")
            off = tme
        elif match[QUOTONLY] != (-1, -1):
            mb, me = match[QUOTONLY]

            vvv = tagString[mb:me]
            if vvv[0] == "`":
                s.append("<FONT COLOR=GREEN>")
            else:
                s.append("<FONT COLOR=PURPLE>")
            s.append(plainEscape(vvv))
            s.append("</FONT>")

            off = me
        else:
            raise LexicalError("unknown text in tag", tagString[off : off + 10])

    return string.join(s, "")