def process_identifier(out, redirects, root, link, item_ident, item_type, opts, debug=DDGDebug()): # get the name by extracting the unqualified identifier name = get_unqualified_name(item_ident) debug_verbose = False if debug.enabled and debug.ident_match is not None: debug_verbose = True try: if item_type == ITEM_TYPE_CLASS: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, opts.max_paren_chars, debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) elif item_type in [ ITEM_TYPE_FUNCTION, ITEM_TYPE_CONSTRUCTOR, ITEM_TYPE_DESTRUCTOR ]: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, opts.max_paren_chars, debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) elif item_type in [ ITEM_TYPE_FUNCTION_INLINEMEM, ITEM_TYPE_CONSTRUCTOR_INLINEMEM, ITEM_TYPE_DESTRUCTOR_INLINEMEM ]: ''' Implementation notes: * the declarations are possibly versioned * declaration is selected from the member table * the member table is found according to the identifier (last part after :: is enough, hopefully) ''' raise DdgException("INLINEMEM") # not implemented elif item_type in [ ITEM_TYPE_VARIABLE, ITEM_TYPE_VARIABLE_INLINEMEM, ITEM_TYPE_ENUM ]: ''' Implementation notes: * the declarations are possibly versioned ''' raise DdgException("ENUM") # not implemented elif item_type == ITEM_TYPE_ENUM_CONST: ''' Implementation notes: * the abstract will come from the const -> definition table, which is always put before the first heading. * the declaration will come from the dcl template. We need to split the content at ';' and ',', then search for the name of the enum. If we find duplicates, signal an error. ''' raise DdgException("ENUM_CONST") # not implemented if debug.enabled: debug.debug_abstracts_file.write("--------------\n") debug.debug_abstracts_file.write(item_ident + '\n') debug.debug_abstracts_file.write(abstract + '\n') # title line = item_ident + '\t' # type line += 'A\t' # redirect, otheruses, categories, references, see_also, # further_reading, external links, disambiguation, images line += '\t\t\t\t\t\t\t\t\t' # abstract abstract = abstract.replace('\n', '\\n') line += abstract + '\t' # source url line += 'https://ja.cppreference.com/w/' + link + '\n' out.write(line) build_redirects(redirects, item_ident, item_type) except DdgException as err: if debug.enabled: line = '# error ({0}): {1}: {2}\n'.format(str(err), link, item_ident) out.write(line)
def process_identifier(out, redirects, root, link, item_ident, item_type, opts, debug=DDGDebug()): # get the name by extracting the unqualified identifier name = get_unqualified_name(item_ident) debug_verbose = True if debug.enabled and debug.ident_match is not None else False try: if item_type == ITEM_TYPE_CLASS: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, opts.max_paren_chars, debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) elif item_type in [ ITEM_TYPE_FUNCTION, ITEM_TYPE_CONSTRUCTOR, ITEM_TYPE_DESTRUCTOR ]: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, opts.max_paren_chars, debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) elif item_type in [ ITEM_TYPE_FUNCTION_INLINEMEM, ITEM_TYPE_CONSTRUCTOR_INLINEMEM, ITEM_TYPE_DESTRUCTOR_INLINEMEM ]: raise DdgException("INLINEMEM") # not implemented ''' Implementation notes: * the declarations are possibly versioned * declaration is selected from the member table * the member table is found according to the identifier (last part after :: is enough, hopefully) ''' elif item_type in [ ITEM_TYPE_VARIABLE, ITEM_TYPE_VARIABLE_INLINEMEM, ITEM_TYPE_ENUM ]: raise DdgException("ENUM") # not implemented ''' Implementation notes: * the declarations are possibly versioned ''' elif item_type == ITEM_TYPE_ENUM_CONST: raise DdgException("ENUM_CONST") # not implemented ''' Implementation notes: * the abstract will come from the const -> definition table, which is always put before the first heading. * the declaration will come from the dcl template. We need to split the content at ';' and ',', then search for the name of the enum. If we find duplicates, signal an error. ''' if debug.enabled: debug.debug_abstracts_file.write("--------------\n") debug.debug_abstracts_file.write(item_ident + '\n') debug.debug_abstracts_file.write(abstract + '\n') # title line = item_ident + '\t' # type line += 'A\t' # redirect, otheruses, categories, references, see_also, # further_reading, external links, disambiguation, images line += '\t\t\t\t\t\t\t\t\t' # abstract abstract = abstract.replace('\n','\\n') line += abstract + '\t' # source url line += 'http://en.cppreference.com/w/' + link + '\n' out.write(line) build_redirects(redirects, item_ident, item_type) except DdgException as err: if debug.enabled: line = '# error (' + str(err) + "): " + link + ": " + item_ident + "\n" out.write(line)
#i+=1 root = e.parse('reference/'+fn, parser=html.HTMLParser()) for ident in idents: item_ident = ident['ident'] item_type = ident['type'] # get the name by extracting the unqualified identifier name = get_name(item_ident) try: debug_verbose = True if debug and debug_ident != None else False if item_type == ITEM_TYPE_CLASS: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), debug=debug_verbose) abstract = build_abstract(decls, desc) elif item_type in [ ITEM_TYPE_FUNCTION, ITEM_TYPE_CONSTRUCTOR, ITEM_TYPE_DESTRUCTOR ]: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), debug=debug_verbose) abstract = build_abstract(decls, desc) elif item_type in [ ITEM_TYPE_FUNCTION_INLINEMEM, ITEM_TYPE_CONSTRUCTOR_INLINEMEM, ITEM_TYPE_DESTRUCTOR_INLINEMEM ]: raise DdgException("INLINEMEM") # not implemented ''' Implementation notes: * the declarations are possibly versioned
root = e.parse('reference/' + fn, parser=html.HTMLParser()) for ident in idents: item_ident = ident['ident'] item_type = ident['type'] # get the name by extracting the unqualified identifier name = get_name(item_ident) try: debug_verbose = True if debug and debug_ident != None else False if item_type == ITEM_TYPE_CLASS: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), debug=debug_verbose) abstract = build_abstract(decls, desc) elif item_type in [ ITEM_TYPE_FUNCTION, ITEM_TYPE_CONSTRUCTOR, ITEM_TYPE_DESTRUCTOR ]: decls = get_declarations(root, name) desc = get_short_description(root, get_version(decls), debug=debug_verbose) abstract = build_abstract(decls, desc) elif item_type in [ ITEM_TYPE_FUNCTION_INLINEMEM,