def update_moved_functions(filename,is_addon=False): xml = objectify.parse(filename) doxygen = xml.getroot() xmlfunctionsfile = doxygen.compounddef if xmlfunctionsfile.find('sectiondef')!=None: if len([ s for s in xmlfunctionsfile.sectiondef if s.get('kind')=='func'])>0: file_split = os.path.splitext(xmlfunctionsfile.compoundname.text) functionsfile = getfunctionsfile(file_split[0]) for section in xmlfunctionsfile.sectiondef: if section.get('kind')=='func': for xmlfunction in section.memberdef: for function in missing_functions: if function.name == xmlfunction.name.text: argstring = str(xmlfunction.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = xmlfunction.type.ref.text if hasattr(xmlfunction.type,'ref') else xmlfunction.type.text moved_function = functionsfile.function_by_signature(xmlfunction.name.text, returns, params) moved_function.returns = returns moved_function.description = moved_function.description + '\n\n' + function.description print "moved function: " + function.name setfunctionsfile(functionsfile,is_addon)
def serialize_functionsfile(cursor, filename, is_addon=False): functionsfile = getfunctionsfile(filename) functions_fromcode = [] functions_for_fuzzy_search = [] for member in cursor.get_children(): if is_function(member) and str( member.location.file) == cursor.spelling: function = parse_function(functionsfile, None, member, functions_fromcode) if function is not None: functions_fromcode.append(function) else: functions_for_fuzzy_search.append(member) for member in functions_for_fuzzy_search: function = parse_function(functionsfile, None, member, functions_fromcode, True) if function is not None: functions_fromcode.append(function) thisfile_missing_functions = [] for function in functionsfile.function_list: if not function in functions_fromcode: missing_functions.append(function) thisfile_missing_functions.append(function) for function in thisfile_missing_functions: functionsfile.function_list.remove(function) functionsfile.function_list.sort(key=lambda function: function.name) if len(functionsfile.function_list) > 0: setfunctionsfile(functionsfile, is_addon)
def serialize_functionsfile(cursor,filename,is_addon=False): functionsfile = getfunctionsfile(filename) functions_fromcode = [] functions_for_fuzzy_search = [] for member in cursor.get_children(): if is_function(member) and str(member.location.file) == cursor.spelling: function = parse_function(functionsfile, None, member, functions_fromcode) if function is not None: functions_fromcode.append(function) else: functions_for_fuzzy_search.append(member) for member in functions_for_fuzzy_search: function = parse_function(functionsfile, None, member, functions_fromcode, True) if function is not None: functions_fromcode.append(function) thisfile_missing_functions = [] for function in functionsfile.function_list: if not function in functions_fromcode: missing_functions.append(function) thisfile_missing_functions.append(function) for function in thisfile_missing_functions: functionsfile.function_list.remove(function) functionsfile.function_list.sort(key=lambda function: function.name) if len(functionsfile.function_list)>0: setfunctionsfile(functionsfile,is_addon)
def update_moved_functions(filename): xml = objectify.parse(filename) doxygen = xml.getroot() xmlfunctionsfile = doxygen.compounddef if xmlfunctionsfile.find('sectiondef') != None: if len([ s for s in xmlfunctionsfile.sectiondef if s.get('kind') == 'func' ]) > 0: file_split = os.path.splitext(xmlfunctionsfile.compoundname.text) functionsfile = getfunctionsfile(file_split[0]) for section in xmlfunctionsfile.sectiondef: if section.get('kind') == 'func': for xmlfunction in section.memberdef: for function in missing_functions: if function.name == xmlfunction.name.text: argstring = str(xmlfunction.argsstring.text) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = xmlfunction.type.ref.text if hasattr( xmlfunction.type, 'ref') else xmlfunction.type.text moved_function = functionsfile.function_by_signature( xmlfunction.name.text, returns, params) moved_function.returns = returns moved_function.description = moved_function.description + '\n\n' + function.description print "moved function: " + function.name setfunctionsfile(functionsfile)
def serialize_functionsfile(filename): xml = objectify.parse(filename) doxygen = xml.getroot() xmlfunctionsfile = doxygen.compounddef if xmlfunctionsfile.find('sectiondef') != None: if len([ s for s in xmlfunctionsfile.sectiondef if s.get('kind') == 'func' ]) > 0: print '\n' file_split = os.path.splitext(xmlfunctionsfile.compoundname.text) print file_split[0] functionsfile = getfunctionsfile(file_split[0]) print 'new: ' + str(functionsfile.new) functions_fromxml = [] for section in xmlfunctionsfile.sectiondef: if section.get('kind') == 'func': for xmlfunction in section.memberdef: argstring = str(xmlfunction.argsstring.text) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = xmlfunction.type.ref.text if hasattr( xmlfunction.type, 'ref') else xmlfunction.type.text function = functionsfile.function_by_signature( xmlfunction.name.text, returns, params) #function.description = function.description.replace("~~~~{.brush cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") function.description = function.description.replace( '<p>', '').replace('</p>', '').replace( '<code>', '').replace('</code>', '').replace('<pre>', '') function.returns = returns functions_fromxml.append(function.name) #print function.returns + " " + function.name + xmlfunction.argsstring.text + " new: " + str(function.new) print "missing functions" thisfile_missing_functions = [] #[f for f in functionsfile.function_list if f not in functions_fromxml.function_list] for function in functionsfile.function_list: if not function.name in functions_fromxml: print function.name + "(" + function.parameters + ")" missing_functions.append(function) thisfile_missing_functions.append(function) for function in thisfile_missing_functions: functionsfile.function_list.remove(function) deprecated_functions = [] for function in functionsfile.function_list: if function.name.find("OF_DEPRECATED_MSG") != -1: deprecated_functions.append(function) for function in deprecated_functions: functionsfile.function_list.remove(function) functionsfile.function_list.sort( key=lambda function: function.name) setfunctionsfile(functionsfile)
def serialize_functionsfile(filename): xml = objectify.parse(filename) doxygen = xml.getroot() xmlfunctionsfile = doxygen.compounddef if xmlfunctionsfile.find('sectiondef')!=None: if len([ s for s in xmlfunctionsfile.sectiondef if s.get('kind')=='func'])>0: print '\n' file_split = os.path.splitext(xmlfunctionsfile.compoundname.text) print file_split[0] functionsfile = getfunctionsfile(file_split[0]) print 'new: ' + str(functionsfile.new) functions_fromxml = [] for section in xmlfunctionsfile.sectiondef: if section.get('kind')=='func': for xmlfunction in section.memberdef: argstring = str(xmlfunction.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = xmlfunction.type.ref.text if hasattr(xmlfunction.type,'ref') else xmlfunction.type.text function = functionsfile.function_by_signature(xmlfunction.name.text, returns, params) #function.description = function.description.replace("~~~~{.brush cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") function.description = function.description.replace('<p>','').replace('</p>','').replace('<code>','').replace('</code>','').replace('<pre>','') function.returns = returns functions_fromxml.append(function.name) #print function.returns + " " + function.name + xmlfunction.argsstring.text + " new: " + str(function.new) print "missing functions" thisfile_missing_functions = [] #[f for f in functionsfile.function_list if f not in functions_fromxml.function_list] for function in functionsfile.function_list: if not function.name in functions_fromxml: print function.name+"("+function.parameters+")" missing_functions.append(function) thisfile_missing_functions.append(function) for function in thisfile_missing_functions: functionsfile.function_list.remove(function) deprecated_functions = [] for function in functionsfile.function_list: if function.name.find("OF_DEPRECATED_MSG")!=-1: deprecated_functions.append(function) for function in deprecated_functions: functionsfile.function_list.remove(function); functionsfile.function_list.sort(key=lambda function: function.name) setfunctionsfile(functionsfile)
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, 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 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 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)
modules = markdown_file.list_all_modules() for module in modules: print '//----------------------\n\n' print "##" + module + "##\n\n" files = markdown_file.list_all_files(module) for f in files: onlyfunctionsfile = False if f.endswith("_functions"): if f[:-10] in files: continue else: f = f[:-10] onlyfunctionsfile = True print "###" + f + "###\n" print "__visible: true__\n" print "__advanced: false__\n" if onlyfunctionsfile: functionsfile = markdown_file.getfunctionsfile(f) prevfunction = "" print '__functions__' for function in functionsfile.function_list: if prevfunction == function.name: continue params = "()" if function.parameters == "" else "(...)" print function.name + params + '\n' prevfunction = function.name print '\n\n\n'
clazzname = clazz if clazz.endswith("_"): clazz = clazz[:-1] if clazz in files: continue current_class = get_class(clazz,block_list) append_class = False if current_class!=None: pass #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
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 parse_folder(root, base, files, is_addon=False, is_glm = False): file_count=0 prefix = "" if root != base: prefix = os.path.relpath(root, base) + "_" for name in files: file_count+=1 filename = os.path.join(root, name) if (name.find('of')==0 and os.path.splitext(name)[1]=='.h') or os.path.splitext(name)[1]=='.hpp': tu = clang_utils.get_tu_from_file(filename, of_root) num_functions = 0 # filter so it only parses elements from this unit not includes def f(child): return str(child.location.file) == str(tu.spelling) for child in filter(f, tu.cursor.get_children()): if child.spelling.find("glm") != -1 and child.kind == CursorKind.NAMESPACE: for ns_child in child.get_children(): if is_glm_class(ns_child): i=0 for c in ns_child.get_children(): if is_variable(c) or is_method(c) or c.kind == CursorKind.CXX_BASE_SPECIFIER: i+=1 if i>0 and ns_child.spelling not in visited_classes: serialize_class(ns_child, is_addon, "glm", substitute_glm_spelling(ns_child.spelling)) visited_classes.append(ns_child.spelling) if is_function(ns_child): num_functions+=1 if is_class(child) and child.spelling.find('of')==0: i=0 for c in child.get_children(): if is_variable(c) or is_method(c) or c.kind == CursorKind.CXX_BASE_SPECIFIER: i+=1 if i>0 and child.spelling not in visited_classes: serialize_class(child, is_addon) visited_classes.append(child.spelling) if is_function(child) and child.spelling.find('of')==0: num_functions+=1 functions_fromcode = [] functions_name = os.path.splitext(name)[0] functionsfile = getfunctionsfile(prefix + functions_name) if num_functions>0 and functions_name not in visited_function_files and functions_name != "ofMain": if is_glm: for child in tu.cursor.get_children(): if child.spelling == "glm" and child.kind == CursorKind.NAMESPACE: functions_fromcode += serialize_functionsfile(child, functionsfile, is_addon, str(tu.cursor.spelling), False, "glm") if len(functions_fromcode) > 0: visited_function_files.append(functions_name) else: functions_fromcode = serialize_functionsfile(tu.cursor, functionsfile, is_addon) visited_function_files.append(functions_name) # We need to do this check outside of serialize_functionsfile cause glm is calling it several times per function thisfile_missing_functions = [] for function in functionsfile.function_list: if not function in functions_fromcode: missing_functions.append(function) thisfile_missing_functions.append(function) for function in thisfile_missing_functions: functionsfile.function_list.remove(function) functionsfile.function_list.sort(key=lambda function: function.syntax) if len(functionsfile.function_list)>0: setfunctionsfile(functionsfile, is_addon) else: remove_functionsfile(functionsfile, is_addon) return file_count
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 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)
current_class = get_class(clazz, block_list) append_class = False if current_class != None: pass #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
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() 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 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))
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)
for module in modules: print '//----------------------\n\n' print "##" + module + "##\n\n" files = markdown_file.list_all_files(module) for f in files: onlyfunctionsfile = False if f.endswith("_functions"): if f[:-10] in files: continue else: f = f[:-10] onlyfunctionsfile = True print "###" + f + "###\n" print "__visible: true__\n" print "__advanced: false__\n" if onlyfunctionsfile: functionsfile = markdown_file.getfunctionsfile(f) prevfunction = "" print '__functions__' for function in functionsfile.function_list: if prevfunction == function.name: continue params = "()" if function.parameters=="" else "(...)" print function.name + params + '\n' prevfunction = function.name print '\n\n\n'
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))