Exemple #1
0
    def run_one_ns(self, namespace, classes, functions, usings):

        # c : AST node of name A::B::C::clsname makes and cd into A/B/C
        def mkchdir_for_one_node(node): 
            mkchdir(* ( CL.fully_qualified_name(node).split('::')[:-1]))

        # First treat the class
        for c in classes:
            if not c.spelling.strip() : 
                print "Skipping a class with an empty name !"
                continue

            # One directory for the class : make it and cd into it
            cur_dir = os.getcwd()
            mkchdir_for_one_node(c)

            # the file for the class
            r = renderers.render_cls(c, c.methods, c.friend_functions)
            safe_write(synopsis.replace_ltgt(c.name), r)
             
            # create a directory with the class name and cd into it
            mkchdir(synopsis.replace_ltgt(c.name))

            # write a file for each function
            def render(message, d) : 
                for f_name, f_overloads in d.items():
                    print " ...... %s [%s]"%(f_name, message)
                    r = renderers.render_fnt(parent_class = c, f_name = f_name, f_overloads = f_overloads)
                    safe_write(f_name, r)

            render('method', c.methods)
            render('non member function', c.friend_functions)

            # Change back to up directory
            os.chdir(cur_dir)

        # Now treat the functions
        functions_by_name = self.regroup_func_by_names(functions)

        docs = dict ( (n, [ProcessedDoc(f) for f in fs]) for (n,fs) in functions_by_name.items())

        for f_name, f_overloads in functions_by_name.items():
            print " ... function " + f_name, "      [", f_overloads[0].location.file.name, ']'
            cur_dir = os.getcwd()
            mkchdir_for_one_node(f_overloads[0])
            r = renderers.render_fnt(parent_class = None, f_name = f_name, f_overloads = f_overloads)
            safe_write(f_name, r)            
            os.chdir(cur_dir)

        # namespace resume function
        cur_dir = os.getcwd()
        mkchdir(*namespace.split('::')[:-1])

        r = renderers.render_ns(namespace, functions_by_name, classes, usings)
        ns = namespace.split('::',1)[-1]
        safe_write(ns, r)

        os.chdir(cur_dir)
Exemple #2
0
    def run_one_ns(self, namespace, classes, functions, usings):

        # c : AST node of name A::B::C::clsname makes and cd into A/B/C
        def mkchdir_for_one_node(node): 
            mkchdir(* ( CL.fully_qualified_name(node).split('::')[:-1]))

        # First treat the class
        for c in classes:
            if not c.spelling.strip() : 
                print "Skipping a class with an empty name !"
                continue

            # One directory for the class : make it and cd into it
            cur_dir = os.getcwd()
            mkchdir_for_one_node(c)

            # the file for the class
            r = renderers.render_cls(c, c.methods, c.friend_functions)
            safe_write(synopsis.replace_ltgt(c.name), r)
             
            # create a directory with the class name and cd into it
            mkchdir(synopsis.replace_ltgt(c.name))

            # write a file for each function
            def render(message, d) : 
                for f_name, f_overloads in d.items():
                    print " ...... %s [%s]"%(f_name, message)
                    r = renderers.render_fnt(parent_class = c, f_name = f_name, f_overloads = f_overloads)
                    safe_write(f_name, r)

            render('method', c.methods)
            render('non member function', c.friend_functions)

            # Change back to up directory
            os.chdir(cur_dir)

        # Now treat the functions
        functions_by_name = self.regroup_func_by_names(functions)

        docs = dict ( (n, [ProcessedDoc(f) for f in fs]) for (n,fs) in functions_by_name.items())

        for f_name, f_overloads in functions_by_name.items():
            print " ... function " + f_name, "      [", f_overloads[0].location.file.name, ']'
            cur_dir = os.getcwd()
            mkchdir_for_one_node(f_overloads[0])
            r = renderers.render_fnt(parent_class = None, f_name = f_name, f_overloads = f_overloads)
            safe_write(f_name, r)            
            os.chdir(cur_dir)

        # namespace resume function
        cur_dir = os.getcwd()
        mkchdir(*namespace.split('::')[:-1])

        r = renderers.render_ns(namespace, functions_by_name, classes, usings)
        ns = namespace.split('::',1)[1]
        safe_write(ns, r)

        os.chdir(cur_dir)
Exemple #3
0
    def make_func_list(all_f, header_name):
        if not all_f: return ''
        R = make_header(header_name)

        # Regroup the function by sub category
        D = OrderedDict()
        for name, flist in all_f.items():
            cat = flist[0].processed_doc.elements.get('category', None)
            D.setdefault(cat, list()).append(
                (":ref:`%s <%s>`" %
                 (escape_lg(name), make_label(cls.name + '_' + name)),
                 flist[0].processed_doc.brief_doc))

        # Make the sub lists
        for cat, list_table_args in D.items():
            if cat: R += make_header(cat, '~')
            R += render_table(list_table_args)

        # the hidden toctree is not regrouped
        R += toctree_hidden
        for f_name in all_f:
            R += "    {cls_name}/{f_name}\n".format(cls_name=replace_ltgt(
                cls.name),
                                                    f_name=f_name)
        return R
Exemple #4
0
def render_ns(ns, all_functions, all_classes, all_usings): 
 
    R = make_header('Reference C++ API for %s'%ns, '#') 
    ns = ns.split('::',1)[1]

    if len(all_usings) > 0:
        R += make_header('Type aliases')
        R += render_table([(t.spelling, t.underlying_typedef_type.spelling, replace_latex(clean_doc_string(t.raw_comment)) if t.raw_comment else '') for t in all_usings])

    if all_classes:
        R += make_header('Classes')
        R += ".. table::\n   :width: 50% 50%\n\n"
        #R += render_table([(":ref:`%s <_%s_%s>`"%(cls.spelling,escape_lg(ns), escape_lg(cls.spelling)), cls.processed_doc.brief_doc) for cls in all_classes ])
        R += render_table([(":ref:`%s <%s>`"%(escape_lg(cls.name), cls.name_for_label), cls.processed_doc.brief_doc) for cls in all_classes ])
        R += toctree_hidden
        for cls in all_classes:
            R += "    {ns}/{filename}\n".format(ns = ns, filename = replace_ltgt(cls.name))


    if all_functions:
        R += make_header('Functions')
        R += render_table([(":ref:`%s <%s>`"%(name, escape_lg(name)), f_list[0].processed_doc.brief_doc) for (name, f_list) in all_functions.items() ])
        #R += render_table([(":ref:`%s <%s_%s>`"%(name,escape_lg(ns), escape_lg(name)), f_list[0].processed_doc.brief_doc) for (name, f_list) in all_functions.items() ])
        R += toctree_hidden
        for f_name in all_functions:
           R += "    {ns}/{f_name}\n".format(ns = ns, f_name = f_name)
   
    return R
Exemple #5
0
def render_ns(ns, all_functions, all_classes, all_usings):

    R = make_header(ns, '#')
    ns = ns.split('::', 1)[-1]

    if len(all_usings) > 0:
        R += make_header('Type aliases')
        R += render_table([(t.spelling,
                            re.sub(ns + '::', '',
                                   t.underlying_typedef_type.spelling),
                            replace_latex(clean_doc_string(t.raw_comment))
                            if t.raw_comment else '') for t in all_usings])

    if all_classes:
        R += make_header('Classes')
        R += ".. table::\n   :width: 50% 50%\n\n"
        #R += render_table([(":ref:`%s <_%s_%s>`"%(cls.spelling,escape_lg(ns), escape_lg(cls.spelling)), cls.processed_doc.elements['brief']) for cls in all_classes ])
        R += render_table([
            (":ref:`%s <%s>`" % (escape_lg(cls.name), cls.name_for_label),
             cls.processed_doc.elements['brief']) for cls in all_classes
        ])
        R += toctree_hidden
        for cls in all_classes:
            R += "    {ns}/{filename}\n".format(ns=ns,
                                                filename=replace_ltgt(
                                                    cls.name))

    if all_functions:
        R += make_header('Functions')
        R += render_table([
            (":ref:`%s <%s>`" %
             (name, make_label(CL.fully_qualified_name(f_list[0]))),
             f_list[0].processed_doc.elements['brief'])
            for (name, f_list) in all_functions.items()
        ])
        #R += render_table([(":ref:`%s <%s>`"%(name, escape_lg(name)), f_list[0].processed_doc.elements['brief']) for (name, f_list) in all_functions.items() ])
        #R += render_table([(":ref:`%s <%s_%s>`"%(name,escape_lg(ns), escape_lg(name)), f_list[0].processed_doc.elements['brief']) for (name, f_list) in all_functions.items() ])
        R += toctree_hidden
        for f_name in all_functions:
            R += "    {ns}/{f_name}\n".format(ns=ns, f_name=f_name)

    return R
Exemple #6
0
 def make_func_list(all_f, header_name):
     if not all_f : return ''
     R = make_header(header_name)
     
     # Regroup the function by sub category
     D = OrderedDict()
     for name, flist in all_f.items():
         cat =flist[0].processed_doc.elements.get('category', None) 
         D.setdefault(cat, list()).append((":ref:`%s <%s>`"%(escape_lg(name),make_label(cls.name + '_' + name)), flist[0].processed_doc.brief_doc))
     
     # Make the sub lists
     for cat, list_table_args in D.items() : 
         if cat : R += make_header(cat, '~')
         R += render_table(list_table_args)
     
     # the hidden toctree is not regrouped
     R += toctree_hidden
     for f_name in all_f:
        R += "    {cls_name}/{f_name}\n".format(cls_name = replace_ltgt(cls.name), f_name = f_name)
     return R