def parse_struct(s):
    docs = s['comment']
    code = '<span class="k">struct</span> <span class="gs">%s</span>' % s['name']
    if s['extends']:
        code += ' extends <span class="gs">%s</span>' % s['extends']
    code += ' {\n'
    namelen = 0
    typelen = 0
    for v in s["fields"]:
        tlen = len(format_type(v, includeOptional=False))
        if len(v['name']) > namelen:
            namelen = len(v['name'])
        if tlen > typelen:
          typelen = tlen
    namelen += 1
    typelen += 1
    formatstr = '    <span class="nv">%s</span><span class="kt">%s %s</span>\n'
    i = 0
    for v in s["fields"]:
        if v.has_key('comment') and v['comment']:
            if i > 0: code += "\n"
            for line in v['comment'].split("\n"):
                code += '    <span class="c1">// %s</span>\n' % line
        opt = ""
        if v.has_key('optional') and v['optional'] == True:
          opt = " [optional]"
        code += formatstr % (string.ljust(v['name'], namelen), string.ljust(format_type(v, includeOptional=False), typelen), opt)
        i += 1
    code += "}"
    return to_section(docs, code)