def format_struct(self, tag): self.m_prototype_uid += 1 template = string.Template("INSERT INTO Types (id, type, name, description, help) VALUES ('%d', 'struct', '${name}', '${desc}', '${help}');\n" % self.m_prototype_uid); html = template_html.template_html_t(self.m_engine, self.m_indexer) # Make sure to inline images in the SQL template html.set_is_inline(True) # Cross references don't currently work in the SQL template so we'll disable them for now html.set_allow_xrefs(False) html.m_wikiword_path_prefix = False help = html.format_struct(tag) obj = tag.contents struct = {} struct["name"] = obj.get_name() struct["desc"] = self.format_textblock(obj.description) struct["help"] = self.sqlize(help) sql = template.substitute(struct) # Add the structure fields if(obj.fields): for field in obj.fields: name = field.get_name() desc = self.format_textblock(field.get_description()) sql += string.Template("INSERT INTO Params (belongs_to, name, type, description) VALUES ('${belongs_to}', '${name}', '', '${desc}');\n").substitute( {"belongs_to" : self.m_prototype_uid, "name" : name, "desc" : desc}) return sql
def format_prototype(self, tag): self.m_prototype_uid += 1 template = string.Template("INSERT INTO Types (id, type, name, description, help) VALUES ('%d', 'method', '${name}', '${desc}', '${help}');\n" % self.m_prototype_uid); html = template_html.template_html_t(self.m_engine, self.m_indexer) # Make sure to inline images in the SQL template html.set_is_inline(True) # Cross references don't currently work in the SQL template so we'll disable them for now html.set_allow_xrefs(False) html.m_show_code_headers["prototype"] = True html.set_template_code_header(sql_template_code_header) html.m_wikiword_path_prefix = False help = html.format_prototype(tag) prototype = tag.contents #print prototype function = {} function["name"] = prototype.get_name() function["desc"] = '' function["help"] = self.sqlize(help) function["desc"] = self.format_textblock(prototype.get_description()) sql = template.substitute(function) if(prototype.has_params()): params = prototype.get_params() for p in params: #print p param = {} param["type"] = p.get_type() param["name"] = p.get_name() if(p.has_description()): param["desc"] = self.format_textblock(p.get_description(textblock=True)) else: param['desc'] = '' sql += string.Template("INSERT INTO Params (belongs_to, name, type, description) VALUES ('%d', '${name}', '${type}', '${desc}');\n" % self.m_prototype_uid).substitute(param); #for val in param["param_desc"]: # if(len(val) == 2): # html_tmp += '<b>%s</b> = %s<br/>' % (val[0], self.format_text(val[1])) # else: # html_tmp += self.format_text(val) #param["param_desc"] = html_tmp #if(param.has_key("param_type")): # param["type"] = '''<td style="vertical-align:text-top;border: 0px;">%s</td>''' % param["param_type"] #else: # param["type"] = '' #output += param_template.substitute(param) return sql
def __init__(self, engine, indexer): template_text_t.__init__(self, engine, indexer) # Instantiante the HTML template so that we can # format advanced objects like structures in a pass-thru # fashion self.html_template = template_html.template_html_t(engine, indexer) self.list_indent_per_level=4 self.m_contents = ''
def format_enum(self, tag): self.m_prototype_uid += 1 template = string.Template("INSERT INTO Types (id, type, name, description, help) VALUES ('%d', 'enum', '${name}', '${desc}', '${help}');\n" % self.m_prototype_uid); html = template_html.template_html_t(self.m_engine, self.m_indexer) # Make sure to inline images in the SQL template html.set_is_inline(True) # Cross references don't currently work in the SQL template so we'll disable them for now html.set_allow_xrefs(False) html.m_wikiword_path_prefix = False help = html.format_enum(tag) #print "HELP [%s]" % help obj = tag.contents enum = {} enum["name"] = obj.name enum["desc"] = '' enum["help"] = self.sqlize(help) enum["desc"] = self.format_textblock(obj.description) sql = template.substitute(enum) # Add the enum values i = 0 for row in obj.values: cols = row["cols"] enum = cols[0]["text"] #print "i = %d, VAL = %s" % (i, cols[1]["text"]) #val = int(cols[1]["text"], 16) desc = self.format_text(cols[2]["text"]) sql += string.Template("INSERT INTO Params (belongs_to, name, type, description) VALUES ('${belongs_to}', '${name}', '', '${desc}');\n").substitute( {"belongs_to" : self.m_prototype_uid, "name" : enum, "desc" : desc}) return sql