コード例 #1
0
ファイル: page.py プロジェクト: dskvr/doxybook
def generate_page(index_path: str, output_path: str, refid: str, cache: Cache):
    output_file = os.path.join(output_path, refid + '.md')
    print('Generating ' + output_file)
    document = MdDocument()

    # Load XML
    xml_root = xml.etree.ElementTree.parse(os.path.join(index_path, refid + '.xml')).getroot()
    if xml_root is None:
        IndexError('Root xml not found!')
    compounddef = xml_root.find('compounddef')
    if compounddef is None:
        IndexError('compounddef not found in xml!')

    title = compounddef.find('title').text

    # Add title
    document.append(MdHeader(1, [Text(title)]))

    document.append(MdParagraph(convert_xml_para(compounddef.find('detaileddescription'), cache)))

    document.set_title(title)
    
    # Save
    with open(output_file, 'w+') as f:
        document.render(MdRenderer(f))

    return title
コード例 #2
0
def generatePages(indexDir: str, outputDir: str, node: Node,
                  cache: Cache) -> dict:
    outputFile = os.path.join(outputDir, 'pages.md')
    print('Generating ' + outputFile)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text('Related Pages')]))

    document.append(
        MdParagraph(
            [Text('Here is a list of all related documentation pages:')]))

    lst = MdList([])

    modules = {}

    # List through all groups
    for child in node.members:
        if child.kind == Kind.PAGE:
            path = os.path.join(indexDir, child.refid + '.xml')
            xmlRoot = xml.etree.ElementTree.parse(path).getroot()
            compounddef = xmlRoot.find('compounddef')
            if compounddef is not None:
                briefdescription = compounddef.find('briefdescription')
                briefdescriptionParas = []
                if briefdescription is not None:
                    briefdescriptionParas = compounddef.find(
                        'briefdescription').findall('para')
                p = MdParagraph([])

                name = compounddef.find('title').text
                refid = compounddef.get('id')
                p.append(MdBold([MdLink([Text(name)], refid + '.md')]))

                modules[refid] = name

                p.append(Text(' '))
                for para in briefdescriptionParas:
                    p.extend(convertXmlPara(para, cache))
                lst.append(p)

    document.append(lst)

    # Save
    with open(outputFile, 'w') as f:
        document.render(MdRenderer(f))

    return modules
コード例 #3
0
ファイル: files.py プロジェクト: RDCH106/doxybook
def generateFiles(indexDir: str, outputDir: str, node: Node,
                  cache: Cache) -> dict:
    outputFile = os.path.join(outputDir, 'files.md')
    print('Generating ' + outputFile)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text('File List')]))
    document.append(
        MdParagraph([
            Text(
                'Here is a list of all documented files with brief descriptions:'
            )
        ]))

    directory = {}

    # List through all directories
    for child in node.members:
        if child.kind == Kind.DIR:
            tokens = child.name.split('/')
            found = findPlace(directory, tokens, child.refid)

            # Load XML
            xmlRoot = xml.etree.ElementTree.parse(
                os.path.join(indexDir, child.refid + '.xml')).getroot()
            if xmlRoot is None:
                IndexError('Root xml not found!')
            compounddef = xmlRoot.find('compounddef')
            if compounddef is None:
                IndexError('compounddef not found in xml!')

            for innerfile in compounddef.findall('innerfile'):
                found[innerfile.text] = innerfile.get('refid')

    lst = generateListRecursive(directory)
    document.append(lst)

    # Save
    with open(outputFile, 'w') as f:
        document.render(MdRenderer(f))

    return directory
コード例 #4
0
ファイル: dir.py プロジェクト: RDCH106/doxybook
def generateDir(indexDir: str, outputDir: str, node: Node,
                cache: Cache) -> dict:
    outputFile = os.path.join(outputDir, node.refid + '.md')
    print('Generating ' + outputFile)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text(node.name + ' Directory Reference')]))

    # Load XML
    xmlRoot = xml.etree.ElementTree.parse(
        os.path.join(indexDir, node.refid + '.xml')).getroot()
    if xmlRoot is None:
        IndexError('Root xml not found!')
    compounddef = xmlRoot.find('compounddef')
    if compounddef is None:
        IndexError('compounddef not found in xml!')

    document.append(MdHeader(2, [Text('Files')]))

    lst = MdList([])
    for innerdir in compounddef.findall('innerdir'):
        lst.append(
            MdParagraph([
                MdBold([
                    MdLink([Text(innerdir.text + '/')],
                           innerdir.get('refid') + '.md')
                ])
            ]))
    for innerfile in compounddef.findall('innerfile'):
        lst.append(
            MdParagraph([
                MdBold([
                    MdLink([Text(innerfile.text)],
                           innerfile.get('refid') + '.md')
                ])
            ]))
    document.append(lst)

    # Save
    with open(outputFile, 'w') as f:
        document.render(MdRenderer(f))
コード例 #5
0
def generateAnnotated(outputDir: str, root: Node):
    outputFile = os.path.join(outputDir, 'annotated.md')
    print('Generating ' + outputFile)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text('Class List')]))

    # Add description
    document.append(
        MdParagraph([
            Text(
                'Here are the classes, structs, unions and interfaces with brief descriptions:'
            )
        ]))

    # Recursively add all members
    mdl = MdList([])
    recursiveHierarchy(root, mdl)
    document.append(mdl)

    # Save
    with open(outputFile, 'w+') as f:
        document.render(MdRenderer(f))
コード例 #6
0
def generateMember(indexDir: str, outputDir: str, refid: str, cache: Cache,
                   noindex: bool):
    outputFile = os.path.join(outputDir, refid + '.md')
    print('Generating ' + outputFile)
    document = MdDocument()
    keywords = []

    # Load XML
    xmlRoot = xml.etree.ElementTree.parse(
        os.path.join(indexDir, refid + '.xml')).getroot()
    if xmlRoot is None:
        IndexError('Root xml not found!')
    compounddef = xmlRoot.find('compounddef')
    if compounddef is None:
        IndexError('compounddef not found in xml!')

    compoundname = compounddef.find('compoundname').text
    keywords.append(compoundname)

    # Add title
    document.append(
        MdHeader(1, [Text(compounddef.get('kind') + ' ' + compoundname)]))

    if compounddef.get('kind') == 'file':
        document.append(
            MdParagraph([
                MdBold([
                    MdLink([Text('Go to the source code of this file.')],
                           refid + '_source.md')
                ])
            ]))

    # Add brief description
    detaileddescriptionParas = compounddef.find('detaileddescription').findall(
        'para')
    briefdescriptionParas = compounddef.find('briefdescription').findall(
        'para')

    if len(briefdescriptionParas) > 0:
        p = MdParagraph([])
        for para in briefdescriptionParas:
            p.extend(convertXmlPara(para, cache))
        if len(detaileddescriptionParas) > 0:
            p.append(MdLink([Text('More...')], '#detailed-description'))
        document.append(p)

    # Add inheriance
    inheritanceRefids: List[str] = []
    basecompoundrefs = compounddef.findall('basecompoundref')
    if len(basecompoundrefs) > 0:
        document.append(Br())
        document.append(Text('Inherits the following classes: '))
        isFirst = True
        for basecompoundref in basecompoundrefs:
            refid = basecompoundref.get('refid')

            if not isFirst:
                document.append(Text(', '))
            isFirst = False

            if refid is not None:
                document.append(
                    MdBold([
                        MdLink([Text(basecompoundref.text)],
                               basecompoundref.get('refid') + '.md')
                    ]))
                inheritanceRefids.append(basecompoundref.get('refid'))
            else:
                document.append(MdBold([Text(basecompoundref.text)]))
        document.append(Br())

    # Add derivations
    derivedcompoundrefs = compounddef.findall('derivedcompoundref')
    if len(derivedcompoundrefs) > 0:
        document.append(Br())
        document.append(Text('Inherited by the following classes: '))
        isFirst = True
        for derivedcompoundref in derivedcompoundrefs:
            refid = derivedcompoundref.get('refid')

            if not isFirst:
                document.append(Text(', '))
            isFirst = False

            if refid is not None:
                document.append(
                    MdBold([
                        MdLink([Text(derivedcompoundref.text)],
                               derivedcompoundref.get('refid') + '.md')
                    ]))
            else:
                document.append(MdBold([Text(derivedcompoundref.text)]))
        document.append(Br())

    # Find all inherited classes
    inheritanceCompounddefs: List[xml.etree.ElementTree.Element] = []
    findInheritedClassesRecursively(inheritanceCompounddefs, indexDir,
                                    inheritanceRefids)
    #for refid in inheritanceRefids:
    #    inheritanceCompounddefs.append(xml.etree.ElementTree.parse(os.path.join(indexDir, refid + '.xml')).getroot().find('compounddef'))

    # Add inner classes
    innerclasses = compounddef.findall('innerclass')
    if len(innerclasses) > 0:
        document.append(MdHeader(2, [Text('Classes')]))

        table = MdTable()
        header = MdTableRow([Text('Type'), Text('Name')])
        table.append(header)

        for innerclass in innerclasses:
            typ = 'class'
            refid = innerclass.get('refid')
            if refid.startswith('struct'):
                typ = 'struct'

            if innerclass.text.startswith(compoundname):
                name = innerclass.text[len(compoundname) + 2:]
            else:
                name = innerclass.text
            keywords.append(name)

            row = MdTableRow(
                [Text(typ),
                 MdLink([MdBold([Text(name)])], refid + '.md')])
            table.append(row)

        document.append(table)

    # We will record which sections to skip
    skipSections = {}

    # We will also record which functions have been overwritten
    reimplemented = []

    # Add sections
    sectiondefs = compounddef.findall('sectiondef')
    for sectiondef in sectiondefs:
        sectionKind = sectiondef.get('kind')

        if sectionKind.startswith('private'):
            continue

        document.append(MdHeader(2, [Text(SECTION_DEFS[sectionKind])]))

        table = makeSection(sectiondef, cache, reimplemented, [])
        document.append(table)

        for memberdef in sectiondef.findall('memberdef'):
            name = memberdef.find('name')
            if name is not None and name.text is not None:
                keywords.append(name.text)

        # Find inherited stuff
        for inheritanceCompounddef in inheritanceCompounddefs:
            inheritedSectiondefs = inheritanceCompounddef.findall('sectiondef')
            refid = inheritanceCompounddef.get('id')
            for sec in inheritedSectiondefs:
                if sec.get('kind') == sectionKind:
                    inheritedName = inheritanceCompounddef.find(
                        'compoundname').text

                    tmp = []
                    table = makeSection(sec, cache, tmp, reimplemented)
                    if table is not None:
                        document.append(
                            MdHeader(4, [
                                Text(SECTION_DEFS[sectionKind] +
                                     ' inherited from '),
                                MdLink([Text(inheritedName)], refid + '.md')
                            ]))
                        document.append(table)
                    reimplemented.extend(tmp)

                    for memberdef in sec.findall('memberdef'):
                        name = memberdef.find('name')
                        if name is not None and name.text is not None:
                            keywords.append(name.text)

                    if not refid in skipSections:
                        skipSections[refid] = [sectionKind]
                    else:
                        skipSections[refid].append(sectionKind)

    missingSections = {}

    # Calculate if we need to create "Additional Inherited Members" section
    for inheritanceCompounddef in inheritanceCompounddefs:
        refid = inheritanceCompounddef.get('id')
        inheritedSectiondefs = inheritanceCompounddef.findall('sectiondef')
        for sec in inheritedSectiondefs:
            sectionKind = sec.get('kind')

            if sectionKind.startswith('private'):
                continue

            if refid in skipSections:
                if not sectionKind in skipSections[refid]:
                    if not refid in missingSections:
                        missingSections[refid] = [sectionKind]
                    else:
                        missingSections[refid].append(sectionKind)
            else:
                if not refid in missingSections:
                    missingSections[refid] = [sectionKind]
                else:
                    missingSections[refid].append(sectionKind)

    if missingSections:
        document.append(MdHeader(2, [Text('Additional Inherited Members')]))
        for inheritanceCompounddef in inheritanceCompounddefs:
            refid = inheritanceCompounddef.get('id')
            if refid in missingSections:
                inheritedSectiondefs = inheritanceCompounddef.findall(
                    'sectiondef')
                for sec in inheritedSectiondefs:
                    sectionKind = sec.get('kind')

                    if sectionKind.startswith('private'):
                        continue

                    if sectionKind in missingSections[refid]:
                        inheritedName = inheritanceCompounddef.find(
                            'compoundname').text

                        tmp = []
                        table = makeSection(sec, cache, tmp, reimplemented)
                        if table is not None:
                            document.append(
                                MdHeader(4, [
                                    Text(SECTION_DEFS[sectionKind] +
                                         ' inherited from '),
                                    MdLink([Text(inheritedName)],
                                           refid + '.md')
                                ]))
                            document.append(table)
                        reimplemented.extend(tmp)

    # Add detailed description
    if len(detaileddescriptionParas) > 0:
        document.append(MdHeader(2, [Text('Detailed Description')]))
        document.extend(
            generateParagraph(
                compounddef.find('detaileddescription').findall('para'),
                cache))

    # Add detailed sections
    sectiondefs = compounddef.findall('sectiondef')
    for sectiondef in sectiondefs:
        sectionKind = sectiondef.get('kind')
        if sectionKind.startswith('private'):
            continue

        document.append(
            MdHeader(2, [Text(SECTION_DEFS[sectionKind] + ' Documentation')]))

        for memberdef in sectiondef.findall('memberdef'):
            kind = memberdef.get('kind')
            document.append(
                MdHeader(3, [
                    Text(kind + ' <a id=\"' + memberdef.get('id')[-34:] +
                         '\" href=\"#' + memberdef.get('id')[-34:] + '\">' +
                         memberdef.find('name').text + '</a>')
                ]))

            code = []
            if kind == 'function':
                code.extend(makeFunctionCode(compoundname, memberdef, False))

            elif kind == 'friend':
                argsstring = memberdef.find('argsstring')
                if argsstring is not None and argsstring.text is not None and len(
                        argsstring.text) > 0:
                    code.extend(makeFunctionCode(compoundname, memberdef,
                                                 True))
                else:
                    code.append(memberdef.find('definition').text + ';')

            elif kind == 'enum':
                code.append('enum ' + compoundname + '::' +
                            memberdef.find('name').text + ' {')
                for enumvalue in memberdef.findall('enumvalue'):
                    value = enumvalue.find('name').text
                    initializer = enumvalue.find('initializer')
                    if initializer is not None:
                        value += ' ' + initializer.text
                    code.append('    ' + value + ',')
                code.append('};')

            else:
                definition = memberdef.find('definition')
                if definition is None:
                    code.append(
                        memberdef.get('kind') + ' ' +
                        memberdef.find('name').text + ';')
                else:
                    code.append(definition.text + ';')

            document.append(MdCodeBlock(code))

            # Add overrides
            reimplements = memberdef.find('reimplements')
            if reimplements is not None:
                try:
                    found = cache.get(reimplements.get('refid'))
                    document.append(
                        MdParagraph([
                            Text('Overrides '),
                            MdBold([
                                MdLink([Text(found.getFullName())], found.url)
                            ])
                        ]))
                except:
                    pass

            # Add descriptions
            detaileddescriptionParas = memberdef.find(
                'detaileddescription').findall('para')
            briefdescriptionParas = memberdef.find('briefdescription').findall(
                'para')
            document.extend(generateParagraph(briefdescriptionParas, cache))
            document.append(Text('\n'))
            document.extend(generateParagraph(detaileddescriptionParas, cache))
            document.append(Text('\n'))

    # Add location
    location = compounddef.find('location')
    if location is not None:
        document.append(Text('\n'))
        document.append(MdLine())
        document.append(
            MdParagraph([
                Text(
                    'The documentation for this class was generated from the following file: '
                ),
                MdCode([Text(location.get('file'))])
            ]))

    # Save
    if not noindex:
        document.setKeywords(keywords)
    with open(outputFile, 'w+') as f:
        document.render(MdRenderer(f))
コード例 #7
0
def generate_file(index_path: str, output_path: str, node: Node,
                  cache: Cache) -> dict:
    output_file = os.path.join(output_path, node.refid + '_source.md')
    print('Generating ' + output_file)
    document = MdDocument()

    # Add title
    title = node.name + ' File Reference'
    document.append(MdHeader(1, [Text(title)]))

    # Load XML
    xml_root = xml.etree.ElementTree.parse(
        os.path.join(index_path, node.refid + '.xml')).getroot()
    if xml_root is None:
        IndexError('Root xml not found!')
    compounddef = xml_root.find('compounddef')
    if compounddef is None:
        IndexError('compounddef not found in xml!')

    document.append(
        MdParagraph([
            MdBold([
                MdLink([Text('Go to the documentation of this file.')],
                       node.refid + '.md')
            ])
        ]))

    location = compounddef.find('location')
    if location is not None:
        document.append(
            MdParagraph(
                [Text('Source: '),
                 MdCode([Text(location.get('file'))])]))

    programlisting = compounddef.find('programlisting')
    if programlisting is None:
        return

    document.append(MdParagraph(convert_xml_para(compounddef, cache)))

    if not config.noindex:
        document.set_keywords([node.name, 'file'])
    document.set_title(title)

    # Save
    with open(output_file, 'w') as f:
        document.render(MdRenderer(f))
コード例 #8
0
ファイル: member.py プロジェクト: dskvr/doxybook
def generate_member(index_path: str, output_path: str, refid: str, cache: Cache):
    output_file = os.path.join(output_path, refid + '.md')
    print('Generating ' + output_file)
    document = MdDocument()
    keywords = []
    node = cache.get(refid)

    # Load XML
    xml_root = xml.etree.ElementTree.parse(os.path.join(index_path, refid + '.xml')).getroot()
    if xml_root is None:
        IndexError('Root xml not found!')
    compounddef = xml_root.find('compounddef')
    if compounddef is None:
        IndexError('compounddef not found in xml!')

    compoundname = compounddef.find('compoundname').text
    keywords.append(compoundname)

    # Add title
    title = compounddef.get('kind') + ' ' + compoundname
    document.append(MdHeader(1, [Text(title)]))

    if node.kind.is_parent():
        document.append(generate_breadcrubs(node))

    if compounddef.get('kind') == 'file':
        document.append(MdParagraph([MdBold([MdLink([Text('Go to the source code of this file.')], refid + '_source.md')])]))

    # Add brief description
    detaileddescription_paras = compounddef.find('detaileddescription').findall('para')
    briefdescription_paras = compounddef.find('briefdescription').findall('para')

    if len(briefdescription_paras) > 0:
        p = MdParagraph([])
        for para in briefdescription_paras:
            p.extend(convert_xml_para(para, cache))
        if len(detaileddescription_paras) > 0:
            p.append(MdLink([Text('More...')], '#detailed-description'))
        document.append(p)

    # Add inheriance
    inheritance_refids:List[str] = []
    basecompoundrefs = compounddef.findall('basecompoundref')
    if len(basecompoundrefs) > 0:
        document.append(Br())
        document.append(Text('Inherits the following classes: '))
        is_first = True
        for basecompoundref in basecompoundrefs:
            refid = basecompoundref.get('refid')

            if not is_first:
                document.append(Text(', '))
            is_first = False

            if refid is not None:
                document.append(MdBold([MdLink([Text(basecompoundref.text)], basecompoundref.get('refid') + '.md')]))
                inheritance_refids.append(basecompoundref.get('refid'))
            else:
                document.append(MdBold([Text(basecompoundref.text)]))
        document.append(Br())

    # Add derivations
    derivedcompoundrefs = compounddef.findall('derivedcompoundref')
    if len(derivedcompoundrefs) > 0:
        document.append(Br())
        document.append(Text('Inherited by the following classes: '))
        is_first = True
        for derivedcompoundref in derivedcompoundrefs:
            refid = derivedcompoundref.get('refid')

            if not is_first:
                document.append(Text(', '))
            is_first = False

            if refid is not None:
                document.append(MdBold([MdLink([Text(derivedcompoundref.text)], derivedcompoundref.get('refid') + '.md')]))
            else:
                document.append(MdBold([Text(derivedcompoundref.text)]))
        document.append(Br())

    # Find all inherited classes
    inheritance_compounddefs:List[xml.etree.ElementTree.Element] = []
    find_inherited_classes_recursively(inheritance_compounddefs, index_path, inheritance_refids)

    # Add inner groups
    innergroups = compounddef.findall('innergroup')
    if len(innergroups) > 0:
        document.append(MdHeader(2, [Text('Modules')]))

        lst = MdList([])

        for innergroup in innergroups:
            refid = innergroup.get('refid')
            innergroup_root = xml.etree.ElementTree.parse(os.path.join(index_path, refid + '.xml')).getroot()
            compounddef = innergroup_root.find('compounddef')
            name = compounddef.find('title').text

            briefdescription_paras = compounddef.find('briefdescription').findall('para')

            link = MdLink([MdBold([Text(name)])], refid + '.md')
            link_with_brief = MdParagraph([link, Text(' ')])
            link_with_brief.extend(generate_paragraph(briefdescription_paras, cache))
            
            lst.append(link_with_brief)

        document.append(lst)
        document.append(Br())

    # Add inner classes
    innerclasses = compounddef.findall('innerclass')
    if len(innerclasses) > 0:
        document.append(MdHeader(2, [Text('Classes')]))

        table = MdTable()
        header = MdTableRow([
            Text('Type'),
            Text('Name')
        ])
        table.append(header)

        for innerclass in innerclasses:
            typ = 'class'
            refid = innerclass.get('refid')
            if refid.startswith('struct'):
                typ = 'struct'

            if innerclass.text.startswith(compoundname):
                name = innerclass.text[len(compoundname)+2:]
            else:
                name = innerclass.text
            keywords.append(name)

            row = MdTableRow([
                Text(typ),
                MdLink([MdBold([Text(name)])], refid + '.md')
            ])
            table.append(row)

        document.append(table)

    # We will record which sections to skip
    skip_sections = {}

    # We will also record which functions have been overwritten
    reimplemented = []

    # Add sections
    sectiondefs = compounddef.findall('sectiondef')
    for sectiondef in sectiondefs:
        section_kind = sectiondef.get('kind')

        if section_kind.startswith('private'):
            continue

        # Seems to work incorrectly, would print an empty "Functions" section, and then a populated "Functions Documentation" section below it. Only useful for classes.
        if section_kind not in "func" and section_kind not in "typedef":
            document.append(MdHeader(2, [Text(SECTION_DEFS[section_kind])]))

        table = make_section(sectiondef, cache, reimplemented, [])
        document.append(table)

        for memberdef in sectiondef.findall('memberdef'):
            name = memberdef.find('name')
            if name is not None and name.text is not None:
                keywords.append(name.text)

        # Find inherited stuff
        for inheritance_compounddefs in inheritance_compounddefs:
            inherited_sectiondefs = inheritance_compounddefs.findall('sectiondef')
            refid = inheritance_compounddefs.get('id')
            for sec in inherited_sectiondefs:
                if sec.get('kind') == skip_sections:
                    inherited_name = inheritance_compounddefs.find('compoundname').text

                    tmp = []
                    table = make_section(sec, cache, tmp, reimplemented)
                    if table is not None:
                        document.append(MdHeader(4, [Text(SECTION_DEFS[skip_sections] + ' inherited from '), MdLink([Text(inherited_name)], refid + '.md')]))
                        document.append(table)
                    reimplemented.extend(tmp)

                    for memberdef in sec.findall('memberdef'):
                        name = memberdef.find('name')
                        if name is not None and name.text is not None:
                            keywords.append(name.text)

                    if not refid in skip_sections:
                        skip_sections[refid] = [skip_sections]
                    else:
                        skip_sections[refid].append(skip_sections)

    missing_sections = {}

    # Calculate if we need to create "Additional Inherited Members" section
    for inheritance_compounddef in inheritance_compounddefs:
        refid = inheritance_compounddef.get('id')
        inherited_sectiondefs = inheritance_compounddef.findall('sectiondef')
        for sec in inherited_sectiondefs:
            section_kind = sec.get('kind')

            if section_kind.startswith('private'):
                continue

            if refid in skip_sections:
                if not section_kind in skip_sections[refid]:
                    if not refid in missing_sections:
                        missing_sections[refid] = [section_kind]
                    else:
                        missing_sections[refid].append(section_kind)
            else:
                if not refid in missing_sections:
                    missing_sections[refid] = [section_kind]
                else:
                    missing_sections[refid].append(section_kind)

    if missing_sections:
        document.append(MdHeader(2, [Text('Additional Inherited Members')]))
        for inheritance_compounddef in inheritance_compounddefs:
            refid = inheritance_compounddef.get('id')
            if refid in missing_sections:
                inherited_sectiondefs = inheritance_compounddef.findall('sectiondef')
                for sec in inherited_sectiondefs:
                    section_kind = sec.get('kind')

                    if section_kind.startswith('private'):
                        continue

                    if section_kind in missing_sections[refid]:
                        inherited_name = inheritance_compounddef.find('compoundname').text

                        tmp = []
                        table = make_section(sec, cache, tmp, reimplemented)
                        if table is not None:
                            document.append(MdHeader(4, [Text(SECTION_DEFS[section_kind] + ' inherited from '), MdLink([Text(inherited_name)], refid + '.md')]))
                            document.append(table)
                        reimplemented.extend(tmp)

    # Add detailed description
    if len(detaileddescription_paras) > 0:
        document.append(MdHeader(2, [Text('Detailed Description')]))
        document.extend(generate_paragraph(compounddef.find('detaileddescription').findall('para'), cache))

    # Add detailed sections
    sectiondefs = compounddef.findall('sectiondef')
    for sectiondef in sectiondefs:
        section_kind = sectiondef.get('kind')
        if section_kind.startswith('private'):
            continue

        document.append(MdHeader(2, [Text(SECTION_DEFS[section_kind] + ' Documentation')]))

        memberdefs = sectiondef.findall('memberdef')

        for memberdef in memberdefs:
            kind = memberdef.get('kind')
            refid = memberdef.get('id')
            node = None
            try:
                node = cache.get(refid)
            except:
                pass
            name = memberdef.find('name').text

            if config.target == 'gitbook':
                if node is not None and node.overloaded:
                    document.append(MdHeader(3, [Text(kind + ' <a id=\"' + refid[-34:] + '\" href=\"#' + refid[-34:] + '\">' + name + ' (' + str(node.overload_num) + '/' + str(node.overload_total) + ')</a>')]))
                else:
                    document.append(MdHeader(3, [Text(kind + ' <a id=\"' + refid[-34:] + '\" href=\"#' + refid[-34:] + '\">' + name + '</a>')]))
            else:
                if node is not None and node.overloaded:
                    document.append(MdHeader(3, [Text(kind + ' ' + name + ' (' + str(node.overload_num) + '/' + str(node.overload_total) + ')')]))
                else:
                    document.append(MdHeader(3, [Text(kind + ' ' + name)]))

            code = []
            if kind == 'function':
                code.extend(make_function_code(compoundname, memberdef, False))

            elif kind == 'friend':
                argsstring = memberdef.find('argsstring')
                if argsstring is not None and argsstring.text is not None and len(argsstring.text) > 0:
                    code.extend(make_function_code(compoundname, memberdef, True))
                else:
                    code.append(memberdef.find('definition').text + ';')

            elif kind == 'enum':
                code.append('enum ' + compoundname + '::' + memberdef.find('name').text + ' {')
                for enumvalue in memberdef.findall('enumvalue'):
                    value = enumvalue.find('name').text
                    initializer = enumvalue.find('initializer')
                    if initializer is not None:
                        value += ' ' + initializer.text
                    code.append('    ' + value + ',')
                code.append('};')

            else:
                definition = memberdef.find('definition')
                if definition is None:
                    code.append(memberdef.get('kind') + ' ' + memberdef.find('name').text + ';')
                else:
                    code.append(definition.text + ';')

            document.append(MdCodeBlock(code))

            # Add descriptions
            detaileddescription_paras = memberdef.find('detaileddescription').findall('para')
            briefdescription_paras = memberdef.find('briefdescription').findall('para')
            document.extend(generate_paragraph(briefdescription_paras, cache))
            document.append(Text('\n'))
            document.extend(generate_paragraph(detaileddescription_paras, cache))
            document.append(Text('\n'))

            # Add overrides
            reimplements = memberdef.find('reimplements')
            if reimplements is not None:
                try:
                    found = cache.get(reimplements.get('refid'))
                    document.append(MdParagraph([Text('Implements '), MdBold([MdLink([Text(found.get_full_name())], found.url)])]))
                    document.append(Br())
                except:
                    pass
    # Add location
    location = compounddef.find('location')
    if location is not None:
        document.append(Text('\n'))
        document.append(MdLine())
        document.append(MdParagraph([
            Text('The documentation for this class was generated from the following file: '),
            MdCode([Text(location.get('file'))])
        ]))

    # Save
    if not config.noindex:
        document.set_keywords(keywords)
    document.set_title(title)

    with open(output_file, 'w+') as f:
        document.render(MdRenderer(f))
コード例 #9
0
ファイル: functions.py プロジェクト: dskvr/doxybook
def generate(path: str, root: Node, kind: Kind, filename: str, title: str,
             subtitle: str):
    output_file = os.path.join(path, filename + '.md')
    print('Generating ' + output_file)
    document = MdDocument()
    keywords = []

    # Add title
    document.append(MdHeader(1, [Text(title)]))
    document.append(MdParagraph([Text(subtitle)]))

    # Sort
    dictionary = {}
    recursive_dictionary(kind, root, dictionary)

    for key in list(sorted(dictionary.keys())):
        document.append(MdHeader(2, [Text(key)]))

        mdl = MdList([])

        # Remove overloads and sort into columns of classes
        class_dictionary = {}
        for member in dictionary[key]:
            if member.name not in class_dictionary:
                class_dictionary[member.name] = []

            if len(class_dictionary[member.name]) > 0:
                if class_dictionary[member.name][-1].parent == member.parent:
                    continue
            class_dictionary[member.name].append(member)

        for dict_key in list(sorted(class_dictionary.keys())):
            p = MdParagraph([])
            first = class_dictionary[dict_key][-1]

            full_name = first.get_full_name(False)
            keywords.append(full_name)
            p.append(MdBold([Text(first.name)]))

            p.append(Text(' ('))
            for member, has_next in lookahead(class_dictionary[dict_key]):
                parent = member.parent
                p.append(
                    MdLink([MdBold([Text(parent.get_full_name(True))])],
                           parent.url + '#' + member.get_anchor_hash()))
                if has_next:
                    p.append(Text(', '))
            p.append(Text(')'))

            mdl.append(p)

        document.append(mdl)
        document.append(Br())

    if not config.noindex:
        document.set_keywords(keywords)
    document.set_title(title)

    # Save
    with open(output_file, 'w') as f:
        document.render(MdRenderer(f))
コード例 #10
0
ファイル: modules.py プロジェクト: dskvr/doxybook
def generate_modules(index_path: str, output_path: str, node: Node, cache: Cache) -> dict:
    output_file = os.path.join(output_path, 'modules.md')
    print('Generating ' + output_file)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text('Modules')]))

    document.append(MdParagraph([Text('Here is a list of all modules:')]))
    
    lst = MdList([])
    modules = {}
    keywords = []

    lst = make_groups_list(index_path, node, keywords, modules, cache)
    if lst is not None:
        document.append(lst)

    if not config.noindex:
        document.set_keywords(keywords)
    document.set_title('Modules')

    # Save
    with open(output_file, 'w') as f:
        document.render(MdRenderer(f))

    return modules
コード例 #11
0
def generateClassIndex(outputDir: str, root: Node):
    outputFile = os.path.join(outputDir, 'classes.md')
    print('Generating ' + outputFile)
    document = MdDocument()

    # Add title
    document.append(MdHeader(1, [Text('Class Index')]))

    # Sort
    dictionary = {}
    recursiveDictionary(root, dictionary)

    for key in list(sorted(dictionary.keys())):
        document.append(MdHeader(2, [Text(key)]))

        mdl = MdList([])
        for member in dictionary[key]:
            p = MdParagraph([])
            p.append(
                MdLink([MdBold([Text(member.getFullName(False))])],
                       member.url))

            namespace = member.getNamespace()
            if namespace is not None:
                p.append(Text(' ('))
                p.append(
                    MdLink([MdBold([Text(namespace.getFullName(False))])],
                           namespace.url))
                p.append(Text(')'))
            mdl.append(p)

        document.append(mdl)
        document.append(Br())

    # Save
    with open(outputFile, 'w') as f:
        document.render(MdRenderer(f))
コード例 #12
0
def generate_annotated(path: str, root: Node):
    output_file = os.path.join(path, 'annotated.md')
    print('Generating ' + output_file)
    document = MdDocument()
    keywords = []

    # Add title
    document.append(MdHeader(1, [Text('Class List')]))

    # Add description
    document.append(
        MdParagraph([
            Text(
                'Here are the classes, structs, unions and interfaces with brief descriptions:'
            )
        ]))

    # Recursively add all members
    mdl = MdList([])
    recursive_hierarchy(root, mdl, keywords)
    document.append(mdl)

    if not config.noindex:
        document.set_keywords(keywords)
    document.set_title('Annotated')

    # Save
    with open(output_file, 'w+') as f:
        document.render(MdRenderer(f))