def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef documentation_class = getclass(clazz.compoundname.text) #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.get("kind") == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.get("kind") == 'variable': var = documentation_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable")=="no" var.static = member.get("static") var.clazz = documentation_class.name var.type = member.type.ref.text if hasattr(member.type,'ref') else member.type.text documentation_class.var_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name.text, returns, params) method.static = member.get("static") method.clazz = documentation_class.name method.access = member.get("prot") method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace('<p>','').replace('</p>','').replace('<code>','').replace('</code>','').replace('<pre>','') if method.new: method.version_started = currentversion #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) #f.write( "$$/code\n\n\n\n" ) #f.close() setclass(documentation_class)
def run(): classes = [] directory = "_docs" docs = bf.config.controllers.docs classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) #print clazz.name #print clazz.function_list env = { "clazz": clazz } bf.writer.materialize_template("docs_class.mako", ('docs',clazz.module+"/"+clazz.name+".html"), env ) # process index file indexhtml_file = open("_docs/" + "index.markdown",'r') indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_docs/" + "indexAddons.markdown",'r') indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.writer.materialize_template("docs.mako", ('docs',"index.html"), {'columns':columns,'addons_columns':addons_columns} ) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','docs',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('_site','docs',os.path.basename(root),name))
def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef docs_class = getclass(clazz.compoundname.text) inheritsfrom = [] if clazz.find('derivedcompoundref') != None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef') != None: for section in clazz.sectiondef: for member in section.memberdef: if member.get("kind") == 'enum': pass else: if member.get("kind") == 'variable': var = docs_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable") == "no" var.static = member.get("static") var.clazz = docs_class.name var.type = member.type.ref.text if hasattr( member.type, 'ref') else member.type.text docs_class.var_list.append(var) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = member.type.ref.text if hasattr( member.type, 'ref') else member.type.text returns = ("" if returns is None else returns) method = docs_class.function_by_signature( member.name.text, returns, params) method.static = member.get("static") method.clazz = docs_class.name method.access = member.get("prot") method.returns = returns if method.new: method.version_started = currentversion setclass(docs_class)
def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef documentation_class = getclass(clazz.compoundname.text) inheritsfrom = [] if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: if member.get("kind") == 'enum': pass else: if member.get("kind") == 'variable': var = documentation_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable")=="no" var.static = member.get("static") var.clazz = documentation_class.name var.type = member.type.ref.text if hasattr(member.type,'ref') else member.type.text documentation_class.var_list.append(var) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name.text, returns, params) method.static = member.get("static") method.clazz = documentation_class.name method.access = member.get("prot") method.returns = returns if method.new: method.version_started = currentversion setclass(documentation_class)
#current_class["methods"]=[] else: current_class = {"name":clazz,"visible":True,"advanced":False,"methods":[]} append_class = True if onlyfunctionsfile: functionsfile = markdown_file.getfunctionsfile(clazz) prevfunction = "" for function in functionsfile.function_list: if prevfunction == function.name: continue params = "()" current_class["methods"].append(function.name + params) prevfunction = function.name else: classfile = markdown_file.getclass(clazzname) prevfunction = "" for function in classfile.function_list: if prevfunction == function.name: continue if function.access!='public' or function.advanced or not function.visible: continue params = "()" current_class["methods"].append(function.name + params) prevfunction = function.name if append_class: block.classes.append(current_class) if append_block: block_list.append(block)
def ofReferenceConvert(): method = DocsMethod(0) #from ofReference var = DocsVar(0) clazzmethod = DocsMethod(0) #from markdown for root, dirs, files in os.walk(os.path.join(ofReference_path)): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join(documentation_root,os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join(documentation_root,os.path.basename(root),name)) if file_split[1]=='.markdown': print '###################get_class ' + file_split[0] clazz = getclass(file_split[0]) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = root print os.path.basename(root) f = open(os.path.join(root,name),'r') state = 'clazz' for line in f: if state == 'clazz' and line.find('## Functions')==0: state = 'functions' elif (state == 'clazz' or state=='method' or state=='var' or state=='functions') and line.find('###')==0: element = line.replace("const ### ","const ").split('###')[1].rstrip('#').strip(' ') if element.find('(')!=-1 and element.find(')')!=-1: method = parse_function(element) clazzmethod = clazztosave.function_by_signature(method.name,method.returns,method.parameters) state = 'method' else: state = 'var' elif (state == 'clazz' or state=='method' or state=='var' or state=='functions') and line.find('##')==0: #print 'class: ' + line.strip('\n') clazz_name = line.split('##')[1].rstrip('#').strip(' ').strip('\n') clazz = getclass(clazz_name) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = os.path.basename(root) print clazztosave.module state = 'clazz' print clazz_name + '\n\n' elif state == 'clazz': if line.find("//----------------------")==0: continue line = line.replace('```cpp','$$code(lang=c++)') line = line.replace('```','$$/code') print unicode(line,errors='ignore') clazztosave.reference = clazztosave.reference + unicode(line, errors='ignore') #.decode('cp1252')) elif state == 'method': if line.find("//----------------------")==0: continue line = line.replace('```cpp','$$code(lang=c++)') line = line.replace('```','$$/code') clazzmethod.description = clazzmethod.description + unicode(line, errors='ignore') elif state == 'function': pass elif state == 'functions' and line.find('###')==0: pass f.close() setclass(clazztosave)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation module_lookup = dict() classes = markdown_file.getclass_list() for class_name in classes: module_lookup[class_name] = markdown_file.getclass(class_name,True).module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name,True) methods_to_remove = [] for method in clazz.function_list: if method.name==clazz.name or method.name[0]=="~" or method.name.find("OF_DEPRECATED_MSG")!=-1: methods_to_remove.append(method) for method in methods_to_remove: clazz.function_list.remove(method) clazz.detailed_inline_description = str(clazz.detailed_inline_description.encode('ascii', 'ignore')) for class_name in classes: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.detailed_inline_description) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.detailed_inline_description) clazz.reference = str(clazz.reference.encode('ascii', 'ignore')) for class_name in classes: rep = class_name + "[\s]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.reference) rep = class_name + "[(]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.reference) #print "Going through " + clazz.module + ":" + clazz.name +", replacing " + module_lookup[class_name] + ":" + class_name functions_file = markdown_file.getfunctionsfile(clazz_name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes } bf.template.materialize_template("documentation_class.mako", ('documentation',clazz.module+"/"+clazz.name+".html"), env ) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") functions_to_remove = [] for function in functions_file.function_list: if function.name.find("OF_DEPRECATED_MSG")!=-1: functions_to_remove.append(method) for function in functions_to_remove: functions_file.function_list.remove(method) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file } bf.template.materialize_template("documentation_class.mako", ('documentation',functions_file.module+"/"+functions_file.name+".html"), env ) # process index file indexhtml_file = open("_documentation/" + "index.markdown",'r') indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_documentation/" + "indexAddons.markdown",'r') indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.template.materialize_template("documentation.mako", ('documentation',"index.html"), {'columns':columns,'addons_columns':addons_columns} ) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','documentation',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('_site','documentation',os.path.basename(root),name))
def run(): classes = [] directory = "_docs" docs = bf.config.controllers.docs classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) #print clazz.name #print clazz.function_list env = {"clazz": clazz} bf.writer.materialize_template( "docs_class.mako", ('docs', clazz.module + "/" + clazz.name + ".html"), env) # process index file indexhtml_file = open("_docs/" + "index.markdown", 'r') indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_docs/" + "indexAddons.markdown", 'r') indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.writer.materialize_template("docs.mako", ('docs', "index.html"), { 'columns': columns, 'addons_columns': addons_columns }) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join('_site', 'docs', os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join('_site', 'docs', os.path.basename(root), name))
def serialize_class(cursor, is_addon=False, parent=None, alternative_class_spelling = None): clazz = cursor class_spelling = alternative_class_spelling if alternative_class_spelling is not None else clazz.spelling classname = (parent + "::" if parent is not None else "") + class_spelling documentation_class = getclass(classname) current_variables_list = [] current_methods_list = [] methods_for_fuzzy_search = [] documentation_class.extends = [] for child in clazz.get_children(): if child.kind == CursorKind.CXX_BASE_SPECIFIER: if child.spelling.find("class") == 0: baseclass = child.spelling.split(' ')[1] documentation_class.extends.append(baseclass) else: documentation_class.extends.append(child.spelling) documentation_class.detailed_inline_description = parse_docs(clazz) for member in clazz.get_children(): if member.kind == CursorKind.CLASS_DECL or member.kind == CursorKind.CLASS_TEMPLATE or member.kind == CursorKind.STRUCT_DECL: if member.access_specifier.name.lower() == 'public' and class_spelling + "::" + member.spelling not in visited_classes: for child in member.get_children(): if is_variable(child) or is_method(child): if classname[-1] == '_': serialize_class(member,is_addon,classname[:-1]) visited_classes.append(classname[:-1] + "::" + member.spelling) else: serialize_class(member,is_addon,classname) visited_classes.append(classname + "::" + member.spelling) break elif member.kind == CursorKind.UNION_DECL: for union_member in member.get_children(): if is_variable(union_member): var = parse_variable(documentation_class, clazz, union_member) current_variables_list.append(var) if union_member.kind == CursorKind.STRUCT_DECL: for union_struct_member in union_member.get_children(): if is_variable(union_struct_member): var = parse_variable(documentation_class, clazz, union_struct_member) current_variables_list.append(var) elif is_variable(member): var = parse_variable(documentation_class, clazz, member) current_variables_list.append(var) elif is_method(member): method = parse_function(documentation_class, clazz, member, current_methods_list) if method is not None: current_methods_list.append(method) else: methods_for_fuzzy_search.append(member) for member in methods_for_fuzzy_search: method = parse_function(documentation_class, clazz, member, current_methods_list, True) if method is not None: current_methods_list.append(method) for method in documentation_class.function_list: if not method in current_methods_list: missing_methods.append(method) documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: missing_vars.append(var) documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.syntax) documentation_class.var_list.sort(key=lambda variable: variable.name) if documentation_class.new: new_classes.append(documentation_class) setclass(documentation_class,is_addon)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name, True) methods_to_remove = [] for method in clazz.function_list: if method.name == clazz.name or method.name[ 0] == "~" or method.name.find("OF_DEPRECATED_MSG") != -1: methods_to_remove.append(method) for method in methods_to_remove: clazz.function_list.remove(method) functions_file = markdown_file.getfunctionsfile(clazz_name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file } bf.template.materialize_template( "documentation_class.mako", ('documentation', clazz.module + "/" + clazz.name + ".html"), env) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) functions_to_remove = [] for function in functions_file.function_list: if function.name.find("OF_DEPRECATED_MSG") != -1: functions_to_remove.append(method) for function in functions_to_remove: functions_file.function_list.remove(method) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file } bf.template.materialize_template( "documentation_class.mako", ('documentation', functions_file.module + "/" + functions_file.name + ".html"), env) # process index file indexhtml_file = open("_documentation/" + "index.markdown", 'r') indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_documentation/" + "indexAddons.markdown", 'r') indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.template.materialize_template("documentation.mako", ('documentation', "index.html"), { 'columns': columns, 'addons_columns': addons_columns }) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join('_site', 'documentation', os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join('_site', 'documentation', os.path.basename(root), name))
def serialize_class(filename, is_addon=False): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen_compound.parse(filename).compounddef #doxygen.compounddef documentation_class = getclass(clazz.compoundname) current_variables_list = [] current_methods_list = [] #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] #if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref documentation_class.detailed_inline_description = "" #clazz_for_description = doxygen_compound.parse(filename).compounddef for p in clazz.briefdescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph( p) documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + "\n" for p in clazz.detaileddescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph( p) #if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.kind == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.kind == 'variable': var = documentation_class.var_by_name(member.name) if not var: var = DocsVar(0) var.name = member.name var.access = member.prot var.version_started = currentversion var.version_deprecated = "" var.constant = member.mutable == "no" var.static = member.static != "no" var.clazz = documentation_class.name #member.type.ref.text if hasattr(member.type,'ref') else member.type.text var.type = "" try: for e in member.type_.content_: if type(e.value ) == doxygen_compound.refTextType: var.type = var.type + e.value.valueOf_ else: var.type = var.type + e.value + " " except: pass current_variables_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.kind == 'function' and member.name.find( "OF_DEPRECATED_MSG") == -1: #print member.name argstring = str(member.argsstring) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: returns = returns + e.value.valueOf_ else: returns = returns + e.value except: pass returns = ("" if returns is None else returns) method = documentation_class.function_by_signature( member.name, returns, params) method.static = member.static != "no" method.clazz = documentation_class.name method.access = member.prot method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace( '<p>', '').replace('</p>', '').replace('<code>', '').replace( '</code>', '').replace('<pre>', '') if method.new: print "new method " + method.name + " in " + method.clazz method.version_started = currentversion method.inlined_description = "" for p in member.briefdescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph( p) method.inlined_description = method.inlined_description + "\n" for p in member.detaileddescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph( p) current_methods_list.append(method) #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) """if member.name.text.find("OF_DEPRECATED_MSG")!=-1: print "found deprecated function " + member.name.text print "argstring = " + str(member.argsstring.text) print "params = " + member.argsstring.text[member.argsstring.text.find('(')+1:member.argsstring.text.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text print "returns = " + ("" if returns is None else returns)""" #f.write( "$$/code\n\n\n\n" ) #f.close() deprecated_methods = [] for method in documentation_class.function_list: if method.name.find("OF_DEPRECATED_MSG") != -1: deprecated_methods.append(method) for method in deprecated_methods: documentation_class.function_list.remove(method) class_name_printed = False for method in documentation_class.function_list: if not method in current_methods_list: if method.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "\n\n\n\n" print "removing method " + method.returns + " " + method.name + "(" + method.parameters + ")" print "with description:" print method.description documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: if var.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "removing " + var.name print "with description:" print var.description documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.name) documentation_class.var_list.sort(key=lambda variable: variable.name) setclass(documentation_class, is_addon)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() module_subtitles = dict() # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] clazz.detailed_inline_description = str( clazz.detailed_inline_description.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a> ", clazz.detailed_inline_description) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a>(", clazz.detailed_inline_description) clazz.reference = str(clazz.reference.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.reference = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a> ", clazz.reference) rep = class_name + "[(]" clazz.reference = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a>(", clazz.reference) def gen_link(class_name): return "<a href=\"../" + module_lookup[ class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a> " if class_name in module_lookup else "" def filter_out_empty(class_name): return class_name != "" clazz.extends = list( filter(filter_out_empty, map(gen_link, clazz.extends))) functions_file = markdown_file.getfunctionsfile(clazz.name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } bf.template.materialize_template( "documentation_class.mako", ('documentation', clazz.module + "/" + clazz.name + ".html"), env) if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } bf.template.materialize_template( "documentation_class.mako", ('documentation', functions_file.module + "/" + functions_file.name + ".html"), env) if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) for root, dirs, files in os.walk(directory): """ copy images to their folders """ for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join('_site', 'documentation', os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join('_site', 'documentation', os.path.basename(root), name)) """ create module introductions """ for module in dirs: if module != "addons": module_intro = os.path.join(root, module, "introduction.markdown") if os.path.isfile(module_intro): module_intro_file = open(module_intro) module_intro_content = module_intro_file.read() module_subtitles[module] = module_intro_content.splitlines( )[0].strip('##').strip(' ') if module.find("ofx") == 0: bf.template.materialize_template( "documentation_module_intro.mako", (os.path.join( 'documentation', module), "introduction.html"), { "module": module, "content": module_intro_content, "classes": addons_index[module] }) else: bf.template.materialize_template( "documentation_module_intro.mako", (os.path.join( 'documentation', module), "introduction.html"), { "module": module, "content": module_intro_content, "classes": core_index[module] }) else: module_subtitles[module] = None print "couldn't find " + module_intro # process index file bf.template.materialize_template( "documentation.mako", ('documentation', "index.html"), { 'core': core_index, 'addons': addons_index, 'module_subtitles': module_subtitles })
def ofReferenceConvert(): method = DocsMethod(0) #from ofReference var = DocsVar(0) clazzmethod = DocsMethod(0) #from markdown for root, dirs, files in os.walk(os.path.join(ofReference_path)): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join(documentation_root, os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join(documentation_root, os.path.basename(root), name)) if file_split[1] == '.markdown': print '###################get_class ' + file_split[0] clazz = getclass(file_split[0]) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = root print os.path.basename(root) f = open(os.path.join(root, name), 'r') state = 'clazz' for line in f: if state == 'clazz' and line.find('## Functions') == 0: state = 'functions' elif (state == 'clazz' or state == 'method' or state == 'var' or state == 'functions') and line.find('###') == 0: element = line.replace( "const ### ", "const ").split('###')[1].rstrip('#').strip(' ') if element.find('(') != -1 and element.find(')') != -1: method = parse_function(element) clazzmethod = clazztosave.function_by_signature( method.name, method.returns, method.parameters) state = 'method' else: state = 'var' elif (state == 'clazz' or state == 'method' or state == 'var' or state == 'functions') and line.find('##') == 0: #print 'class: ' + line.strip('\n') clazz_name = line.split('##')[1].rstrip('#').strip( ' ').strip('\n') clazz = getclass(clazz_name) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = os.path.basename(root) print clazztosave.module state = 'clazz' print clazz_name + '\n\n' elif state == 'clazz': if line.find("//----------------------") == 0: continue line = line.replace('```cpp', '$$code(lang=c++)') line = line.replace('```', '$$/code') print unicode(line, errors='ignore') clazztosave.reference = clazztosave.reference + unicode( line, errors='ignore') #.decode('cp1252')) elif state == 'method': if line.find("//----------------------") == 0: continue line = line.replace('```cpp', '$$code(lang=c++)') line = line.replace('```', '$$/code') clazzmethod.description = clazzmethod.description + unicode( line, errors='ignore') elif state == 'function': pass elif state == 'functions' and line.find('###') == 0: pass f.close() setclass(clazztosave)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] methods_to_remove = [] for method in clazz.function_list: if method.name[0]=="~" or method.name.find("OF_DEPRECATED_MSG")!=-1: methods_to_remove.append(method) for method in methods_to_remove: clazz.function_list.remove(method) clazz.detailed_inline_description = str(clazz.detailed_inline_description.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.detailed_inline_description) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.detailed_inline_description) clazz.reference = str(clazz.reference.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.reference) rep = class_name + "[(]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.reference) functions_file = markdown_file.getfunctionsfile(clazz.name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } bf.template.materialize_template("documentation_class.mako", ('documentation',clazz.module+"/"+clazz.name+".html"), env ) if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") functions_to_remove = [] for function in functions_file.function_list: if function.name.find("OF_DEPRECATED_MSG")!=-1: functions_to_remove.append(method) for function in functions_to_remove: functions_file.function_list.remove(method) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } bf.template.materialize_template("documentation_class.mako", ('documentation',functions_file.module+"/"+functions_file.name+".html"), env ) if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) # process index file bf.template.materialize_template("documentation.mako", ('documentation',"index.html"), {'core':core_index,'addons':addons_index} ) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','documentation',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('_site','documentation',os.path.basename(root),name))
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) functions_file = markdown_file.getfunctionsfile(clazz_name) # print clazz.name # print clazz.function_list env = {"modulename": clazz.name, "clazz": clazz, "functions": functions_file} bf.writer.materialize_template( "documentation_class.mako", ("documentation", clazz.module + "/" + clazz.name + ".html"), env ) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) env = {"modulename": functions_file.name, "clazz": None, "functions": functions_file} bf.writer.materialize_template( "documentation_class.mako", ("documentation", functions_file.module + "/" + functions_file.name + ".html"), env, ) # process index file indexhtml_file = open("_documentation/" + "index.markdown", "r") indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split("___column___") for column in columns_src: blocks_src = column.split("//----------------------") blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_documentation/" + "indexAddons.markdown", "r") indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split("___column___") for column in columns_src: blocks_src = column.split("//----------------------") blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.writer.materialize_template( "documentation.mako", ("documentation", "index.html"), {"columns": columns, "addons_columns": addons_columns} ) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if ( file_split[1] == ".jpeg" or file_split[1] == ".jpg" or file_split[1] == ".gif" or file_split[1] == ".png" ): try: os.mkdir(os.path.join("_site", "documentation", os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join("_site", "documentation", os.path.basename(root), name) )
def create_docs(self): tasks = {} classes = [] directory = "documentation" classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() module_subtitles = dict() docs_dir = os.path.join(self.site.original_cwd, "documentation") md_extensions = self.site.config.get("MARKDOWN_EXTENSIONS") # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] clazz.detailed_inline_description = markdown(clazz.detailed_inline_description, md_extensions) # clazz.description = str(markdown(clazz.description, md_extensions).encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub( rep, '<a href="/documentation/' + module_lookup[class_name] + "/" + class_name + '" class="docs_class" >' + class_name + "</a> ", clazz.detailed_inline_description, ) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub( rep, '<a href="/documentation/' + module_lookup[class_name] + "/" + class_name + '" class="docs_class" >' + class_name + "</a>(", clazz.detailed_inline_description, ) clazz.reference = markdown(clazz.reference, md_extensions) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.reference = re.sub( rep, '<a href="/documentation/' + module_lookup[class_name] + "/" + class_name + '" class="docs_class" >' + class_name + "</a> ", clazz.reference, ) rep = class_name + "[(]" clazz.reference = re.sub( rep, '<a href="/documentation/' + module_lookup[class_name] + "/" + class_name + '" class="docs_class" >' + class_name + "</a>(", clazz.reference, ) for function in clazz.function_list: function.description = markdown(function.description, md_extensions) function.inlined_description = markdown(function.inlined_description, md_extensions) def gen_link(class_name): return ( '<a href="/documentation/' + module_lookup[class_name] + "/" + class_name + '" class="docs_class" >' + class_name + "</a> " if class_name in module_lookup else "" ) def filter_out_empty(class_name): return class_name != "" clazz.extends = list(filter(filter_out_empty, map(gen_link, clazz.extends))) functions_file = markdown_file.getfunctionsfile(clazz.name) for function in functions_file.function_list: function.description = markdown(function.description, md_extensions) function.inlined_description = markdown(function.inlined_description, md_extensions) # print clazz.name # print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes), } # print("class " + clazz_name) template_name = "documentation_class.mako" for lang in self.kw["translations"]: env["lang"] = lang env["title"] = clazz.name env["permalink"] = ( self.kw["translations"][lang] + "/documentation/" + clazz.module + "/" + clazz.name + "/" ) short_tdst = os.path.join( self.kw["translations"][lang], "documentation", clazz.module, clazz.name, "index.html" ) tdst = os.path.normpath(os.path.join(self.kw["output_folder"], short_tdst)) self.site.render_template(template_name, tdst, env) if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") for function in functions_file.function_list: function.description = markdown(function.description, md_extensions) function.inlined_description = markdown(function.inlined_description, md_extensions) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes), } template_name = "documentation_class.mako" for lang in self.kw["translations"]: env["lang"] = lang env["title"] = clazz.name env["permalink"] = ( self.kw["translations"][lang] + "/documentation/" + functions_file.module + "/" + functions_file.name + "/" ) short_tdst = os.path.join( self.kw["translations"][lang], "documentation", functions_file.module, functions_file.name, "index.html", ) tdst = os.path.normpath(os.path.join(self.kw["output_folder"], short_tdst)) self.site.render_template(template_name, tdst, env) if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) for root, dirs, files in os.walk(directory): """ copy images to their folders """ for name in files: file_split = os.path.splitext(name) if ( file_split[1] == ".jpeg" or file_split[1] == ".jpg" or file_split[1] == ".gif" or file_split[1] == ".png" ): try: os.mkdir(os.path.join("_site", "documentation", os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join("output", "documentation", os.path.basename(root), name) ) """ create module introductions """ for module in dirs: if module != "addons": module_intro = os.path.join(root, module, "introduction.markdown") if os.path.isfile(module_intro): module_intro_file = open(module_intro) module_intro_content = module_intro_file.read() module_subtitles[module] = module_intro_content.splitlines()[0].strip("##").strip(" ") module_intro_content = markdown(module_intro_content, md_extensions) template_name = "documentation_module_intro.mako" for lang in self.kw["translations"]: context = {} context["lang"] = lang context["title"] = clazz.name context["module"] = module context["intro_content"] = module_intro_content context["permalink"] = ( self.kw["translations"][lang] + "/documentation/" + module + "/introduction.html" ) short_tdst = os.path.join( self.kw["translations"][lang], "documentation", module, "introduction.html" ) tdst = os.path.normpath(os.path.join(self.kw["output_folder"], short_tdst)) if module.find("ofx") == 0: context["classes"] = addons_index[module] self.site.render_template(template_name, tdst, context) else: context["classes"] = core_index[module] self.site.render_template(template_name, tdst, context) else: module_subtitles[module] = None print("couldn't find " + module_intro) # process index file template_name = "documentation.mako" for lang in self.kw["translations"]: # lang_suffix = self.kw['translations'][lang] docs_intro_path = os.path.join(docs_dir, "index.md") if lang != self.site.config["DEFAULT_LANG"]: docs_intro_lang_path = utils.get_translation_candidate(self.site.config, docs_intro_path, lang) p = pathlib.Path(docs_intro_lang_path) if p.exists(): docs_intro_path = docs_intro_lang_path docs_intro = open(docs_intro_path).read() for key in self.site.GLOBAL_CONTEXT.keys(): if isinstance(self.site.GLOBAL_CONTEXT[key], str): docs_intro = docs_intro.replace("${" + key + "}", self.site.GLOBAL_CONTEXT[key]) docs_intro = markdown(docs_intro, md_extensions) context = {} context["lang"] = lang context["title"] = "documentation" context["docs_intro"] = docs_intro context["core"] = core_index context["addons"] = addons_index context["module_subtitles"] = module_subtitles context["permalink"] = self.kw["translations"][lang] + "/documentation/" short_tdst = os.path.join(self.kw["translations"][lang], "documentation", "index.html") tdst = os.path.normpath(os.path.join(self.kw["output_folder"], short_tdst)) self.site.render_template(template_name, tdst, context)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() module_subtitles = dict() # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] clazz.detailed_inline_description = str(clazz.detailed_inline_description.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.detailed_inline_description) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.detailed_inline_description) clazz.reference = str(clazz.reference.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> ", clazz.reference) rep = class_name + "[(]" clazz.reference = re.sub(rep, "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a>(", clazz.reference) def gen_link(class_name): return "<a href=\"../"+module_lookup[class_name]+"/"+class_name+".html\" class=\"docs_class\" >"+class_name+"</a> " if class_name in module_lookup else "" def filter_out_empty(class_name): return class_name!="" clazz.extends = list(filter(filter_out_empty, map(gen_link, clazz.extends))) functions_file = markdown_file.getfunctionsfile(clazz.name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } bf.template.materialize_template("documentation_class.mako", ('documentation',clazz.module+"/"+clazz.name+".html"), env ) if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } bf.template.materialize_template("documentation_class.mako", ('documentation',functions_file.module+"/"+functions_file.name+".html"), env ) if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) for root, dirs, files in os.walk(directory): """ copy images to their folders """ for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','documentation',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('_site','documentation',os.path.basename(root),name)) """ create module introductions """ for module in dirs: if module!="addons": module_intro = os.path.join(root,module,"introduction.markdown") if os.path.isfile(module_intro): module_intro_file = open(module_intro) module_intro_content = module_intro_file.read() module_subtitles[module] = module_intro_content.splitlines()[0].strip('##').strip(' ') if module.find("ofx") == 0: bf.template.materialize_template("documentation_module_intro.mako", (os.path.join('documentation', module),"introduction.html"), {"module": module, "content": module_intro_content, "classes": addons_index[module]} ) else: bf.template.materialize_template("documentation_module_intro.mako", (os.path.join('documentation', module),"introduction.html"), {"module": module, "content": module_intro_content, "classes": core_index[module]} ) else: module_subtitles[module] = None print "couldn't find " + module_intro # process index file bf.template.materialize_template("documentation.mako", ('documentation',"index.html"), {'core':core_index, 'addons':addons_index, 'module_subtitles':module_subtitles} )
"advanced": False, "methods": [] } append_class = True if onlyfunctionsfile: functionsfile = markdown_file.getfunctionsfile(clazz) prevfunction = "" for function in functionsfile.function_list: if prevfunction == function.name: continue params = "()" current_class["methods"].append(function.name + params) prevfunction = function.name else: classfile = markdown_file.getclass(clazzname) prevfunction = "" for function in classfile.function_list: if prevfunction == function.name: continue if function.access != 'public' or function.advanced or not function.visible: continue params = "()" current_class["methods"].append(function.name + params) prevfunction = function.name if append_class: block.classes.append(current_class) block_list.append(block)
def create_docs(self): tasks = {} classes = [] directory = "documentation" classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() module_subtitles = dict() docs_dir = os.path.join(self.site.original_cwd, "documentation") md_extensions = self.site.config.get("MARKDOWN_EXTENSIONS") content_js = {} class_template = "documentation_class.mako" class_template_dep = self.site.template_system.template_deps( class_template) module_template = "documentation_module_intro.mako" # start js string for docs search for lang in self.kw['translations']: content_js[lang] = 'var tipuesearch = {"pages": [' # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module # classes docs for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] clazz.detailed_inline_description = relative_urls( clazz.detailed_inline_description) clazz.detailed_inline_description = markdown( clazz.detailed_inline_description, md_extensions) clazz.detailed_inline_description = of_classes_to_links( clazz.detailed_inline_description, classes_simple_name, module_lookup) clazz.reference = relative_urls(clazz.reference) clazz.reference = markdown(clazz.reference, md_extensions) clazz.reference = of_classes_to_links(clazz.reference, classes_simple_name, module_lookup) # methods in class for function in clazz.function_list: function.description = relative_urls(function.description) function.description = markdown(function.description, md_extensions) function.description = of_classes_to_links( function.description, classes_simple_name, module_lookup) function.inlined_description = relative_urls( function.inlined_description) function.inlined_description = markdown( function.inlined_description, md_extensions) function.inlined_description = of_classes_to_links( function.inlined_description, classes_simple_name, module_lookup) for lang in self.kw['translations']: content_js[lang] += method_to_js(function, clazz, self.site, lang) # inheritance def gen_link(class_name): return "<a href=\"/documentation/" + module_lookup[ class_name] + "/" + class_name + "\" class=\"docs_class\" >" + class_name + "</a> " if class_name in module_lookup else "" def filter_out_empty(class_name): return class_name != "" clazz.extends = list( filter(filter_out_empty, map(gen_link, clazz.extends))) # c functions in the class file functions_file = markdown_file.getfunctionsfile(clazz.name) for function in functions_file.function_list: function.description = relative_urls(function.description) function.description = markdown(function.description, md_extensions) function.description = of_classes_to_links( function.description, classes_simple_name, module_lookup) function.inlined_description = relative_urls( function.inlined_description) function.inlined_description = markdown( function.inlined_description, md_extensions) function.inlined_description = of_classes_to_links( function.inlined_description, classes_simple_name, module_lookup) for lang in self.kw['translations']: content_js[lang] += function_to_js(function, functions_file, self.site, lang) # render template + js for search env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } md_file = "documentation/" + module_lookup[ class_name] + "/" + class_name + ".markdown" for lang in self.kw['translations']: env["lang"] = lang env["title"] = clazz.name env["permalink"] = self.kw['translations'][ lang] + '/documentation/' + clazz.module + "/" + clazz.name + "/" short_tdst = os.path.join(self.kw['translations'][lang], 'documentation', clazz.module, clazz.name, "index.html") tdst = os.path.normpath( os.path.join(self.kw['output_folder'], short_tdst)) """yield utils.apply_filters({ 'basename': self.name, 'name': clazz.name, 'file_dep': class_template_dep + md_file, 'targets': tdst, 'actions': [ (self.site.render_template, (template_name, tdst, env)) ], 'clean': True, 'uptodate': [utils.config_changed({ 1: self.kw, })], }, self.kw['filters'])""" self.site.render_template(class_template, tdst, env) content_js[lang] += class_to_js(clazz, self.site, lang) # add to index core or addons if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) # generate c functions docs function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") for function in functions_file.function_list: function.description = relative_urls(function.description) function.description = markdown(function.description, md_extensions) function.description = of_classes_to_links( function.description, classes_simple_name, module_lookup) function.inlined_description = relative_urls( function.inlined_description) function.inlined_description = markdown( function.inlined_description, md_extensions) function.inlined_description = of_classes_to_links( function.inlined_description, classes_simple_name, module_lookup) for lang in self.kw['translations']: content_js[lang] += function_to_js(function, functions_file, self.site, lang) # render template + js for search env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } for lang in self.kw['translations']: env["lang"] = lang env["title"] = clazz.name env["permalink"] = self.kw['translations'][ lang] + '/documentation/' + functions_file.module + "/" + functions_file.name + "/" short_tdst = os.path.join(self.kw['translations'][lang], 'documentation', functions_file.module, functions_file.name, "index.html") tdst = os.path.normpath( os.path.join(self.kw['output_folder'], short_tdst)) self.site.render_template(class_template, tdst, env) content_js[lang] += functions_file_to_js( functions_file, self.site, lang) # add to index core or addons if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) # copy images and render intros for root, dirs, files in os.walk(directory): """ copy images to their folders """ for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join('_site', 'documentation', os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join('output', 'documentation', os.path.basename(root), name)) """ create module introductions """ for module in dirs: if module != "addons": module_intro = os.path.join(root, module, "introduction.markdown") if os.path.isfile(module_intro): module_intro_file = open(module_intro) module_intro_content = module_intro_file.read() module_subtitles[ module] = module_intro_content.splitlines( )[0].strip('##').strip(' ') module_intro_content = markdown( module_intro_content, md_extensions) for lang in self.kw['translations']: context = {} context["lang"] = lang context["title"] = module context["module"] = module context["intro_content"] = module_intro_content context["permalink"] = self.kw['translations'][ lang] + '/documentation/' + module + "/" if lang == self.site.config['DEFAULT_LANG']: short_tdst = os.path.join( 'documentation', module, "index.html") else: short_tdst = os.path.join( self.kw['translations'][lang], 'documentation', module, "index.html") tdst = os.path.normpath( os.path.join(self.kw['output_folder'], short_tdst)) if module.find("ofx") == 0: context["classes"] = addons_index[module] self.site.render_template( module_template, tdst, context) else: context["classes"] = core_index[module] self.site.render_template( module_template, tdst, context) content_js[lang] += module_to_js( module, module_intro_content, self.site, lang) else: module_subtitles[module] = None # close js for docs search and save per language for lang in self.kw['translations']: content_js[lang] += ']};' content_js_file = open( "output" + lang_prefix(lang, self.site) + "/tipuesearch_content.js", "w") content_js_file.write(content_js[lang]) content_js_file.close() # render index file template_name = "documentation.mako" for lang in self.kw['translations']: #lang_suffix = self.kw['translations'][lang] docs_intro_path = os.path.join(docs_dir, "index.md") if lang != self.site.config['DEFAULT_LANG']: docs_intro_lang_path = utils.get_translation_candidate( self.site.config, docs_intro_path, lang) p = pathlib.Path(docs_intro_lang_path) if p.exists(): docs_intro_path = docs_intro_lang_path docs_intro = open(docs_intro_path).read() for key in self.site.GLOBAL_CONTEXT.keys(): if isinstance(self.site.GLOBAL_CONTEXT[key], str): docs_intro = docs_intro.replace( '${' + key + '}', self.site.GLOBAL_CONTEXT[key]) docs_intro = markdown(docs_intro, md_extensions) context = {} context["lang"] = lang context["title"] = "documentation" context["docs_intro"] = docs_intro context['core'] = core_index context['addons'] = addons_index context['module_subtitles'] = module_subtitles context["permalink"] = self.kw['translations'][ lang] + '/documentation/' short_tdst = os.path.join(self.kw['translations'][lang], "documentation", "index.html") tdst = os.path.normpath( os.path.join(self.kw['output_folder'], short_tdst)) self.site.render_template(template_name, tdst, context)
def create_docs(self): tasks = {} classes = [] directory = "documentation" classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() module_subtitles = dict() docs_dir = os.path.join(self.site.original_cwd, "documentation") md_extensions = self.site.config.get("MARKDOWN_EXTENSIONS") content_js = {} class_template = "documentation_class.mako" class_template_dep = self.site.template_system.template_deps(class_template) module_template = "documentation_module_intro.mako" # start js string for docs search for lang in self.kw['translations']: content_js[lang] = 'var tipuesearch = {"pages": [' # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module # classes docs for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] clazz.detailed_inline_description = relative_urls(clazz.detailed_inline_description) clazz.detailed_inline_description = markdown(clazz.detailed_inline_description, md_extensions) clazz.detailed_inline_description = of_classes_to_links(clazz.detailed_inline_description, classes_simple_name, module_lookup) clazz.reference = relative_urls(clazz.reference) clazz.reference = markdown(clazz.reference, md_extensions) clazz.reference = of_classes_to_links(clazz.reference, classes_simple_name, module_lookup) # methods in class for function in clazz.function_list: function.description = relative_urls(function.description) function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup) function.description = markdown(function.description, md_extensions) function.inlined_description = relative_urls(function.inlined_description) function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup) function.inlined_description = markdown(function.inlined_description, md_extensions) for lang in self.kw['translations']: content_js[lang] += method_to_js(function, clazz, self.site, lang) # inheritance def gen_link(class_name): return "<a href=\"/documentation/" + module_lookup[class_name] + "/" + class_name + "\" class=\"docs_class\" >"+class_name+"</a> " if class_name in module_lookup else "" def filter_out_empty(class_name): return class_name!="" clazz.extends = list(filter(filter_out_empty, map(gen_link, clazz.extends))) # c functions in the class file functions_file = markdown_file.getfunctionsfile(clazz.name) for function in functions_file.function_list: function.description = relative_urls(function.description) function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup) function.description = markdown(function.description, md_extensions) function.inlined_description = relative_urls(function.inlined_description) function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup) function.inlined_description = markdown(function.inlined_description, md_extensions) for lang in self.kw['translations']: content_js[lang] += function_to_js(function, functions_file, self.site, lang) # render template + js for search env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } md_file = "documentation/" + module_lookup[class_name] + "/" + class_name + ".markdown" for lang in self.kw['translations']: env["lang"] = lang env["title"] = clazz.name env["permalink"] = self.kw['translations'][lang] + '/documentation/' + clazz.module + "/" + clazz.name + "/" short_tdst = os.path.join(self.kw['translations'][lang], 'documentation', clazz.module, clazz.name,"index.html") tdst = os.path.normpath(os.path.join(self.kw['output_folder'], short_tdst)) """yield utils.apply_filters({ 'basename': self.name, 'name': clazz.name, 'file_dep': class_template_dep + md_file, 'targets': tdst, 'actions': [ (self.site.render_template, (template_name, tdst, env)) ], 'clean': True, 'uptodate': [utils.config_changed({ 1: self.kw, })], }, self.kw['filters'])""" self.site.render_template(class_template, tdst, env) content_js[lang] += class_to_js(clazz, self.site, lang) # add to index core or addons if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file!=None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) # generate c functions docs function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") for function in functions_file.function_list: function.description = relative_urls(function.description) function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup) function.description = markdown(function.description, md_extensions) function.inlined_description = relative_urls(function.inlined_description) function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup) function.inlined_description = markdown(function.inlined_description, md_extensions) for lang in self.kw['translations']: content_js[lang] += function_to_js(function, functions_file, self.site, lang) # render template + js for search env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } for lang in self.kw['translations']: env["lang"] = lang env["title"] = clazz.name env["permalink"] = self.kw['translations'][lang] + '/documentation/' + functions_file.module + "/" + functions_file.name + "/" short_tdst = os.path.join(self.kw['translations'][lang], 'documentation', functions_file.module, functions_file.name,"index.html") tdst = os.path.normpath(os.path.join(self.kw['output_folder'], short_tdst)) self.site.render_template(class_template, tdst, env) content_js[lang] += functions_file_to_js(functions_file, self.site, lang) # add to index core or addons if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) # copy images and render intros for root, dirs, files in os.walk(directory): """ copy images to their folders """ for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','documentation',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('output','documentation',os.path.basename(root),name)) """ create module introductions """ for module in dirs: if module!="addons": module_intro = os.path.join(root,module,"introduction.markdown") if os.path.isfile(module_intro): module_intro_file = open(module_intro) module_intro_content = module_intro_file.read() module_subtitles[module] = module_intro_content.splitlines()[0].strip('##').strip(' ') module_intro_content = markdown(module_intro_content, md_extensions) for lang in self.kw['translations']: context = {} context["lang"] = lang context["title"] = module context["module"] = module context["intro_content"] = module_intro_content context["permalink"] = self.kw['translations'][lang] + '/documentation/' + module + "/" if lang == self.site.config['DEFAULT_LANG']: short_tdst = os.path.join('documentation', module, "index.html") else: short_tdst = os.path.join(self.kw['translations'][lang], 'documentation', module, "index.html") tdst = os.path.normpath(os.path.join(self.kw['output_folder'], short_tdst)) if module.find("ofx") == 0: context["classes"] = addons_index[module] self.site.render_template(module_template, tdst, context) else: context["classes"] = core_index[module] self.site.render_template(module_template, tdst, context) content_js[lang] += module_to_js(module, module_intro_content, self.site, lang) else: module_subtitles[module] = None # close js for docs search and save per language for lang in self.kw['translations']: content_js[lang] += ']};' content_js_file = open("output" + lang_prefix(lang, self.site) + "/tipuesearch_content.js","w") content_js_file.write(content_js[lang]) content_js_file.close() # render index file template_name = "documentation.mako" for lang in self.kw['translations']: #lang_suffix = self.kw['translations'][lang] docs_intro_path = os.path.join(docs_dir, "index.md") if lang != self.site.config['DEFAULT_LANG']: docs_intro_lang_path = utils.get_translation_candidate(self.site.config, docs_intro_path, lang) p = pathlib.Path(docs_intro_lang_path) if p.exists(): docs_intro_path = docs_intro_lang_path docs_intro = open(docs_intro_path).read() for key in self.site.GLOBAL_CONTEXT.keys(): if isinstance(self.site.GLOBAL_CONTEXT[key], str): docs_intro = docs_intro.replace('${' + key + '}', self.site.GLOBAL_CONTEXT[key]) docs_intro = markdown(docs_intro, md_extensions) context = {} context["lang"] = lang context["title"] = "documentation" context["docs_intro"] = docs_intro context['core'] = core_index context['addons'] = addons_index context['module_subtitles'] = module_subtitles context["permalink"] = self.kw['translations'][lang] + '/documentation/' short_tdst = os.path.join(self.kw['translations'][lang], "documentation", "index.html") tdst = os.path.normpath(os.path.join(self.kw['output_folder'], short_tdst)) self.site.render_template(template_name, tdst, context)
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name,True) methods_to_remove = [] for method in clazz.function_list: if method.name==clazz.name or method.name[0]=="~" or method.name.find("OF_DEPRECATED_MSG")!=-1: methods_to_remove.append(method) for method in methods_to_remove: clazz.function_list.remove(method) functions_file = markdown_file.getfunctionsfile(clazz_name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file } bf.writer.materialize_template("documentation_class.mako", ('documentation',clazz.module+"/"+clazz.name+".html"), env ) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) functions_to_remove = [] for function in functions_file.function_list: if function.name.find("OF_DEPRECATED_MSG")!=-1: functions_to_remove.append(method) for function in functions_to_remove: functions_file.function_list.remove(method) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file } bf.writer.materialize_template("documentation_class.mako", ('documentation',functions_file.module+"/"+functions_file.name+".html"), env ) # process index file indexhtml_file = open("_documentation/" + "index.markdown",'r') indexhtml = indexhtml_file.read() columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) columns.append(blocks) indexhtml_file = open("_documentation/" + "indexAddons.markdown",'r') indexhtml = indexhtml_file.read() addons_columns = [] columns_src = indexhtml.split('___column___') for column in columns_src: blocks_src = column.split('//----------------------') blocks = [] for block in blocks_src: b = Block(block) if b.name is not None and b.name != "": blocks.append(b) addons_columns.append(blocks) bf.writer.materialize_template("documentation.mako", ('documentation',"index.html"), {'columns':columns,'addons_columns':addons_columns} ) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join('_site','documentation',os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join('_site','documentation',os.path.basename(root),name))
def run(): classes = [] directory = "_documentation" documentation = bf.config.controllers.documentation classes = markdown_file.getclass_list() classes_simple_name = markdown_file.getclass_list(False) addon_classes = markdown_file.list_all_addons() module_lookup = dict() core_index = dict() addons_index = dict() # Create an index of which module each class is in for generated links to other classes for class_name in classes: clazz = markdown_file.getclass(class_name) if clazz.istemplated: module_lookup[class_name[:-1]] = clazz.module else: module_lookup[class_name] = clazz.module for clazz_name in classes: clazz = markdown_file.getclass(clazz_name) if clazz.istemplated: clazz.name = clazz.name[:-1] methods_to_remove = [] for method in clazz.function_list: if method.name[0] == "~" or method.name.find( "OF_DEPRECATED_MSG") != -1: methods_to_remove.append(method) for method in methods_to_remove: clazz.function_list.remove(method) clazz.detailed_inline_description = str( clazz.detailed_inline_description.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.detailed_inline_description = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a> ", clazz.detailed_inline_description) rep = class_name + "[(]" clazz.detailed_inline_description = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a>(", clazz.detailed_inline_description) clazz.reference = str(clazz.reference.encode('ascii', 'ignore')) for class_name in classes_simple_name: rep = class_name + "[\s]" clazz.reference = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a> ", clazz.reference) rep = class_name + "[(]" clazz.reference = re.sub( rep, "<a href=\"../" + module_lookup[class_name] + "/" + class_name + ".html\" class=\"docs_class\" >" + class_name + "</a>(", clazz.reference) functions_file = markdown_file.getfunctionsfile(clazz.name) #print clazz.name #print clazz.function_list env = { "modulename": clazz.name, "clazz": clazz, "functions": functions_file, "classes_list": classes, "is_addon": (clazz.name in addon_classes) } bf.template.materialize_template( "documentation_class.mako", ('documentation', clazz.module + "/" + clazz.name + ".html"), env) if not clazz.module in addon_classes: if not clazz.module in core_index.keys(): core_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) core_index[clazz.module].append(clazz) else: if not clazz.module in addons_index.keys(): addons_index[clazz.module] = [] if functions_file != None: for function in functions_file.function_list: clazz.function_list.append(function) addons_index[clazz.module].append(clazz) function_files = markdown_file.getfunctionsfiles_list() for functionfile_name in function_files: if functionfile_name in classes_simple_name: continue functions_file = markdown_file.getfunctionsfile(functionfile_name) # might be needed at some point? # functions_file.reference = str(functions_file.reference) # for func in function_files: # functions_file.reference = str.replace(functions_file.reference, class_name, "<a href=\"../"+clazz.module+"/"+class_name+".html\">"+class_name+"</a>") functions_to_remove = [] for function in functions_file.function_list: if function.name.find("OF_DEPRECATED_MSG") != -1: functions_to_remove.append(method) for function in functions_to_remove: functions_file.function_list.remove(method) env = { "modulename": functions_file.name, "clazz": None, "functions": functions_file, "is_addon": (functions_file.name in addon_classes) } bf.template.materialize_template( "documentation_class.mako", ('documentation', functions_file.module + "/" + functions_file.name + ".html"), env) if not functions_file.module in addon_classes: if not functions_file.module in core_index: core_index[functions_file.module] = [] core_index[functions_file.module].append(functions_file) else: if not functions_file.module in addons_index: addons_index[functions_file.module] = [] addons_index[functions_file.module].append(functions_file) # process index file bf.template.materialize_template("documentation.mako", ('documentation', "index.html"), { 'core': core_index, 'addons': addons_index }) for root, dirs, files in os.walk(directory): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join('_site', 'documentation', os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join('_site', 'documentation', os.path.basename(root), name))
def serialize_class(filename,is_addon=False): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen_compound.parse(filename).compounddef #doxygen.compounddef documentation_class = getclass(clazz.compoundname) current_variables_list = [] current_methods_list = [] #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] #if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref documentation_class.detailed_inline_description = "" #clazz_for_description = doxygen_compound.parse(filename).compounddef for p in clazz.briefdescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph(p) documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + "\n" for p in clazz.detaileddescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph(p) #if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.kind == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.kind == 'variable': var = documentation_class.var_by_name(member.name) if not var: var = DocsVar(0) var.name = member.name var.access = member.prot var.version_started = currentversion var.version_deprecated = "" var.constant = member.mutable=="no" var.static = member.static!="no" var.clazz = documentation_class.name #member.type.ref.text if hasattr(member.type,'ref') else member.type.text var.type = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: var.type = var.type + e.value.valueOf_ else: var.type = var.type + e.value + " " except: pass current_variables_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.kind == 'function' and member.name.find("OF_DEPRECATED_MSG")==-1: #print member.name argstring = str(member.argsstring) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: returns = returns + e.value.valueOf_ else: returns = returns + e.value except: pass returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name, returns, params) method.static = member.static!="no" method.clazz = documentation_class.name method.access = member.prot method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace('<p>','').replace('</p>','').replace('<code>','').replace('</code>','').replace('<pre>','') if method.new: print "new method " + method.name + " in " + method.clazz method.version_started = currentversion method.inlined_description = "" for p in member.briefdescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph(p) method.inlined_description = method.inlined_description + "\n" for p in member.detaileddescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph(p) current_methods_list.append(method) #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) """if member.name.text.find("OF_DEPRECATED_MSG")!=-1: print "found deprecated function " + member.name.text print "argstring = " + str(member.argsstring.text) print "params = " + member.argsstring.text[member.argsstring.text.find('(')+1:member.argsstring.text.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text print "returns = " + ("" if returns is None else returns)""" #f.write( "$$/code\n\n\n\n" ) #f.close() deprecated_methods = [] for method in documentation_class.function_list: if method.name.find("OF_DEPRECATED_MSG")!=-1: deprecated_methods.append(method) for method in deprecated_methods: documentation_class.function_list.remove(method); class_name_printed = False for method in documentation_class.function_list: if not method in current_methods_list: if method.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "\n\n\n\n" print "removing method " + method.returns + " " + method.name + "(" + method.parameters + ")" print "with description:" print method.description documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: if var.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "removing " + var.name print "with description:" print var.description documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.name) documentation_class.var_list.sort(key=lambda variable: variable.name) setclass(documentation_class,is_addon)
import markdown_file addons = markdown_file.list_all_addons() classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name,True) markdown_file.setclass(clazz,clazz.module in addons) function_files = markdown_file.getfunctionsfiles_list() for function_file_name in function_files: functions_file = markdown_file.getfunctionsfile(function_file_name) markdown_file.setfunctionsfile(functions_file, functions_file.module in addons)