Exemple #1
0
def setup(app):

    parser_factory = DoxygenParserFactory()
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(
        parser_factory, matcher_factory)
    index_parser = DoxygenIndexParser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes)
    renderer_factory_creator = DoxygenToRstRendererFactoryCreator(
        node_factory, parser_factory)
    builder_factory = BuilderFactory(RstBuilder, renderer_factory_creator)

    project_info_factory = ProjectInfoFactory()
    directive_factory = DoxygenDirectiveFactory(builder_factory,
                                                finder_factory,
                                                matcher_factory,
                                                project_info_factory)

    app.add_directive(
        "doxygenindex",
        directive_factory.create_index_directive_container(),
    )

    app.add_directive(
        "doxygenfunction",
        directive_factory.create_function_directive_container(),
    )

    app.add_directive(
        "doxygenstruct",
        directive_factory.create_struct_directive_container(),
    )

    app.add_directive(
        "doxygenenum",
        directive_factory.create_enum_directive_container(),
    )

    app.add_directive(
        "doxygentypedef",
        directive_factory.create_typedef_directive_container(),
    )

    app.add_directive(
        "doxygenclass",
        directive_factory.create_class_directive_container(),
    )

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)

    app.connect("builder-inited", directive_factory.get_config_values)
    def __init__(self, app):
        from breathe.project import ProjectInfoFactory
        from breathe.parser import DoxygenParserFactory

        env = sphinx.environment.BuildEnvironment(app)
        env.setup(app)
        env.temp_data["docname"] = "mock-doc"
        env.temp_data["breathe_project_info_factory"] = ProjectInfoFactory(app)
        env.temp_data["breathe_parser_factory"] = DoxygenParserFactory(app)
        settings = frontend.OptionParser(components=(parsers.rst.Parser,)).get_default_values()
        settings.env = env
        self.document = utils.new_document("", settings)
Exemple #3
0
def test_resolve_function(app):
    from breathe.directives import DoxygenFunctionDirective
    from breathe.project import ProjectInfoFactory
    from breathe.parser import DoxygenParserFactory
    from breathe.parser.compoundsuper import sectiondefType
    from breathe.finder.factory import FinderFactory
    from docutils.statemachine import StringList
    from xml.dom import minidom

    app.config.breathe_separate_member_pages = False
    app.config.breathe_default_project = 'test_project'
    app.config.breathe_domain_by_extension = {}
    app.config.breathe_domain_by_file_pattern = {}
    app.config.breathe_use_project_refids = False
    project_info_factory = ProjectInfoFactory(app)
    parser_factory = DoxygenParserFactory(app)
    finder_factory = FinderFactory(app, parser_factory)
    cls_args = ('doxygenclass', ['at::Tensor'],
                {'members': '', 'protected-members': None, 'undoc-members': None},
                StringList([], items=[]),
                20, 24,
                ('.. doxygenclass:: at::Tensor\n   :members:\n'
                        '   :protected-members:\n   :undoc-members:'),
                MockState(app),
                MockStateMachine(),
               )
    cls = DoxygenFunctionDirective(finder_factory, project_info_factory, parser_factory, *cls_args)

    argsstrings = []
    with open(os.path.join(os.path.dirname(__file__), 'data', 'arange.xml')) as fid:
        xml = fid.read()
    doc = minidom.parseString(xml)

    sectiondef = sectiondefType.factory()
    for child in doc.documentElement.childNodes:
        sectiondef.buildChildren(child, 'memberdef')
        if getattr(child, 'tagName', None) == 'memberdef':
            # Get the argsstring function declaration
            argsstrings.append(child.getElementsByTagName('argsstring')[0].childNodes[0].data)

    # Verify that parsing the exact same argument works
    matches = [[m, sectiondef] for m in sectiondef.memberdef]
    for args in argsstrings:
        ast_param = cls.parse_args(args)
        ret = cls.resolve_function(matches, ast_param, None)
Exemple #4
0
def get_directive(app):
    from breathe.directives import DoxygenFunctionDirective
    from breathe.project import ProjectInfoFactory
    from breathe.parser import DoxygenParserFactory
    from breathe.finder.factory import FinderFactory
    from docutils.statemachine import StringList
    app.config.breathe_separate_member_pages = False
    app.config.breathe_default_project = 'test_project'
    app.config.breathe_domain_by_extension = {}
    app.config.breathe_domain_by_file_pattern = {}
    app.config.breathe_use_project_refids = False
    project_info_factory = ProjectInfoFactory(app)
    parser_factory = DoxygenParserFactory(app)
    finder_factory = FinderFactory(app, parser_factory)
    cls_args = ('doxygenclass', ['at::Tensor'],
                {'members': '', 'protected-members': None, 'undoc-members': None},
                StringList([], items=[]),
                20, 24,
                ('.. doxygenclass:: at::Tensor\n   :members:\n'
                        '   :protected-members:\n   :undoc-members:'),
                MockState(app),
                MockStateMachine(),
               )
    return DoxygenFunctionDirective(finder_factory, project_info_factory, parser_factory, *cls_args)
Exemple #5
0
def setup(app):

    cache_factory = CacheFactory()
    cache = cache_factory.create_cache()
    path_handler = PathHandler(os.sep, os.path.basename, os.path.join)
    mtimer = MTimer(os.path.getmtime)
    file_state_cache = FileStateCache(mtimer, app)
    parser_factory = DoxygenParserFactory(cache, path_handler, file_state_cache)
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(parser_factory, matcher_factory)
    index_parser = parser_factory.create_index_parser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    # Create a math_nodes object with a displaymath member for the displaymath
    # node so that we can treat it in the same way as the nodes & addnodes
    # modules in the NodeFactory
    math_nodes = collections.namedtuple("MathNodes", ["displaymath"])
    math_nodes.displaymath = sphinx.ext.mathbase.displaymath
    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes, math_nodes)

    cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
    c_domain_helper = CDomainHelper()
    domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
    domain_handler_factory_creator = DomainHandlerFactoryCreator(node_factory, domain_helpers)

    rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
    default_domain_handler = NullDomainHandler()
    renderer_factory_creator_constructor = DoxygenToRstRendererFactoryCreatorConstructor(
            node_factory,
            parser_factory,
            default_domain_handler,
            domain_handler_factory_creator,
            rst_content_creator
            )

    project_info_factory = ProjectInfoFactory(fnmatch.fnmatch)
    glob_factory = GlobFactory(fnmatch.fnmatch)
    filter_factory = FilterFactory(glob_factory, path_handler)
    target_handler_factory = TargetHandlerFactory(node_factory)

    root_data_object = RootDataObject()

    directive_factory = DoxygenDirectiveFactory(
            root_data_object,
            renderer_factory_creator_constructor,
            finder_factory,
            matcher_factory,
            project_info_factory,
            filter_factory,
            target_handler_factory
            )

    app.add_directive(
            "doxygenindex",
            directive_factory.create_index_directive_container(),
            )

    app.add_directive(
            "doxygenfunction",
            directive_factory.create_function_directive_container(),
            )

    app.add_directive(
            "doxygenstruct",
            directive_factory.create_struct_directive_container(),
            )

    app.add_directive(
            "doxygenenum",
            directive_factory.create_enum_directive_container(),
            )

    app.add_directive(
            "doxygentypedef",
            directive_factory.create_typedef_directive_container(),
            )

    app.add_directive(
            "doxygenclass",
            directive_factory.create_class_directive_container(),
            )

    app.add_directive(
            "doxygenfile",
            directive_factory.create_file_directive_container(),
            )

    app.add_directive(
            "doxygenvariable",
            directive_factory.create_variable_directive_container(),
            )

    app.add_directive(
            "doxygendefine",
            directive_factory.create_define_directive_container(),
            )

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)
    app.add_config_value("breathe_domain_by_extension", {}, True)
    app.add_config_value("breathe_domain_by_file_pattern", {}, True)

    app.add_stylesheet("breathe.css")

    app.connect("builder-inited", directive_factory.get_config_values)

    app.connect("env-get-outdated", file_state_cache.get_outdated)

    app.connect("env-purge-doc", file_state_cache.purge_doc)
Exemple #6
0
def setup(app: Sphinx) -> None:
    directives = {
        "doxygenindex": DoxygenIndexDirective,
        "autodoxygenindex": AutoDoxygenIndexDirective,
        "doxygenfunction": DoxygenFunctionDirective,
        "doxygenstruct": DoxygenStructDirective,
        "doxygenclass": DoxygenClassDirective,
        "doxygeninterface": DoxygenInterfaceDirective,
        "doxygenvariable": DoxygenVariableDirective,
        "doxygendefine": DoxygenDefineDirective,
        "doxygenenum": DoxygenEnumDirective,
        "doxygenenumvalue": DoxygenEnumValueDirective,
        "doxygentypedef": DoxygenTypedefDirective,
        "doxygenunion": DoxygenUnionDirective,
        "doxygennamespace": DoxygenNamespaceDirective,
        "doxygengroup": DoxygenGroupDirective,
        "doxygenfile": DoxygenFileDirective,
        "autodoxygenfile": AutoDoxygenFileDirective,
    }

    # note: the parser factory contains a cache of the parsed XML
    # note: the project_info_factory also contains some caching stuff
    # TODO: is that actually safe for when reading in parallel?
    project_info_factory = ProjectInfoFactory(app)
    parser_factory = DoxygenParserFactory(app)
    finder_factory = FinderFactory(app, parser_factory)
    for name, directive in directives.items():
        # ordinarily app.add_directive takes a class it self, but we need to inject extra arguments
        # so we give a DirectiveContainer object which has an overloaded __call__ operator.
        app.add_directive(
            name,
            DirectiveContainer(  # type: ignore
                app, directive, finder_factory, project_info_factory,
                parser_factory))

    app.add_config_value("breathe_projects", {}, True)  # Dict[str, str]
    app.add_config_value("breathe_default_project", "", True)  # str
    # Provide reasonable defaults for domain_by_extension mapping. Can be overridden by users.
    app.add_config_value("breathe_domain_by_extension", {'py': 'py'},
                         True)  # Dict[str, str]
    app.add_config_value("breathe_domain_by_file_pattern", {},
                         True)  # Dict[str, str]
    app.add_config_value("breathe_projects_source", {}, True)
    app.add_config_value("breathe_build_directory", '', True)
    app.add_config_value("breathe_default_members", (), True)
    app.add_config_value("breathe_show_define_initializer", False, 'env')
    app.add_config_value("breathe_implementation_filename_extensions",
                         ['.c', '.cc', '.cpp'], True)
    app.add_config_value("breathe_doxygen_config_options", {}, True)
    app.add_config_value("breathe_use_project_refids", False, "env")
    app.add_config_value("breathe_order_parameters_first", False, 'env')

    breathe_css = "breathe.css"
    if (os.path.exists(os.path.join(app.confdir, "_static", breathe_css))):
        app.add_stylesheet(breathe_css)

    def write_file(directory, filename, content):
        # Check the directory exists
        if not os.path.exists(directory):
            os.makedirs(directory)

        # Write the file with the provided contents
        with open(os.path.join(directory, filename), "w") as f:
            f.write(content)

    doxygen_handle = AutoDoxygenProcessHandle(subprocess.check_call,
                                              write_file, project_info_factory)

    def doxygen_hook(app):
        doxygen_handle.generate_xml(app.config.breathe_projects_source,
                                    app.config.breathe_doxygen_config_options)

    app.connect("builder-inited", doxygen_hook)
Exemple #7
0
def setup(app):

    parser_factory = DoxygenParserFactory()
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(
        parser_factory, matcher_factory)
    index_parser = DoxygenIndexParser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes)

    cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
    c_domain_helper = CDomainHelper()
    domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
    domain_handler_factory_creator = DomainHandlerFactoryCreator(
        node_factory, domain_helpers)

    rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
    default_domain_handler = NullDomainHandler()
    renderer_factory_creator = DoxygenToRstRendererFactoryCreator(
        node_factory, parser_factory, default_domain_handler,
        domain_handler_factory_creator, rst_content_creator)

    project_info_factory = ProjectInfoFactory(fnmatch.fnmatch)
    glob_factory = GlobFactory(fnmatch.fnmatch)
    path_handler = PathHandler(os.sep, os.path.basename)
    filter_factory = FilterFactory(glob_factory, path_handler)
    target_handler_factory = TargetHandlerFactory(node_factory)

    root_data_object = RootDataObject()

    directive_factory = DoxygenDirectiveFactory(
        root_data_object, renderer_factory_creator, finder_factory,
        matcher_factory, project_info_factory, filter_factory,
        target_handler_factory)

    app.add_directive(
        "doxygenindex",
        directive_factory.create_index_directive_container(),
    )

    app.add_directive(
        "doxygenfunction",
        directive_factory.create_function_directive_container(),
    )

    app.add_directive(
        "doxygenstruct",
        directive_factory.create_struct_directive_container(),
    )

    app.add_directive(
        "doxygenenum",
        directive_factory.create_enum_directive_container(),
    )

    app.add_directive(
        "doxygentypedef",
        directive_factory.create_typedef_directive_container(),
    )

    app.add_directive(
        "doxygenclass",
        directive_factory.create_class_directive_container(),
    )

    app.add_directive(
        "doxygenfile",
        directive_factory.create_file_directive_container(),
    )

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)
    app.add_config_value("breathe_domain_by_extension", {}, True)
    app.add_config_value("breathe_domain_by_file_pattern", {}, True)

    app.add_stylesheet("breathe.css")

    app.connect("builder-inited", directive_factory.get_config_values)
Exemple #8
0
def setup(app: Sphinx) -> None:
    directives = {
        "doxygenindex": DoxygenIndexDirective,
        "autodoxygenindex": AutoDoxygenIndexDirective,
        "doxygenfunction": DoxygenFunctionDirective,
        "doxygenstruct": DoxygenStructDirective,
        "doxygenclass": DoxygenClassDirective,
        "doxygeninterface": DoxygenInterfaceDirective,
        "doxygenvariable": DoxygenVariableDirective,
        "doxygendefine": DoxygenDefineDirective,
        "doxygenconcept": DoxygenConceptDirective,
        "doxygenenum": DoxygenEnumDirective,
        "doxygenenumvalue": DoxygenEnumValueDirective,
        "doxygentypedef": DoxygenTypedefDirective,
        "doxygenunion": DoxygenUnionDirective,
        "doxygennamespace": DoxygenNamespaceDirective,
        "doxygengroup": DoxygenGroupDirective,
        "doxygenfile": DoxygenFileDirective,
        "autodoxygenfile": AutoDoxygenFileDirective,
        "doxygenpage": DoxygenPageDirective,
    }

    # The directives need these global objects, so in order to smuggle
    # them in, we use env.temp_data. But it is cleared after each document
    # has been read, we use the source-read event to set them.
    # note: the parser factory contains a cache of the parsed XML
    # note: the project_info_factory also contains some caching stuff
    # TODO: is that actually safe for when reading in parallel?
    project_info_factory = ProjectInfoFactory(app)
    parser_factory = DoxygenParserFactory(app)

    def set_temp_data(app: Sphinx,
                      project_info_factory=project_info_factory,
                      parser_factory=parser_factory):
        assert app.env is not None
        app.env.temp_data[
            "breathe_project_info_factory"] = project_info_factory
        app.env.temp_data["breathe_parser_factory"] = parser_factory

    app.connect("source-read", lambda app, docname, source: set_temp_data(app))

    for name, directive in directives.items():
        app.add_directive(name, directive)

    app.add_config_value("breathe_projects", {}, True)  # Dict[str, str]
    app.add_config_value("breathe_default_project", "", True)  # str
    # Provide reasonable defaults for domain_by_extension mapping. Can be overridden by users.
    app.add_config_value("breathe_domain_by_extension", {
        "py": "py",
        "cs": "cs"
    }, True)  # Dict[str, str]
    app.add_config_value("breathe_domain_by_file_pattern", {},
                         True)  # Dict[str, str]
    app.add_config_value("breathe_projects_source", {}, True)
    app.add_config_value("breathe_build_directory", "", True)
    app.add_config_value("breathe_default_members", (), True)
    app.add_config_value("breathe_show_define_initializer", False, "env")
    app.add_config_value("breathe_show_enumvalue_initializer", False, "env")
    app.add_config_value("breathe_show_include", True, "env")
    app.add_config_value("breathe_implementation_filename_extensions",
                         [".c", ".cc", ".cpp"], True)
    app.add_config_value("breathe_doxygen_config_options", {}, True)
    app.add_config_value("breathe_doxygen_aliases", {}, True)
    app.add_config_value("breathe_use_project_refids", False, "env")
    app.add_config_value("breathe_order_parameters_first", False, "env")
    app.add_config_value("breathe_separate_member_pages", False, "env")

    breathe_css = "breathe.css"
    if os.path.exists(os.path.join(app.confdir, "_static", breathe_css)):
        app.add_css_file(breathe_css)

    def write_file(directory, filename, content):
        # Check the directory exists
        if not os.path.exists(directory):
            os.makedirs(directory)

        # Write the file with the provided contents
        with open(os.path.join(directory, filename), "w") as f:
            f.write(content)

    doxygen_handle = AutoDoxygenProcessHandle(subprocess.check_call,
                                              write_file, project_info_factory)

    def doxygen_hook(app: Sphinx):
        doxygen_handle.generate_xml(
            app.config.breathe_projects_source,
            app.config.breathe_doxygen_config_options,
            app.config.breathe_doxygen_aliases,
        )

    app.connect("builder-inited", doxygen_hook)
Exemple #9
0
def setup(app):

    cache_factory = CacheFactory()
    cache = cache_factory.create_cache()
    path_handler = PathHandler(app.confdir, os.sep, os.path.basename, os.path.join)
    mtimer = MTimer(os.path.getmtime)
    file_state_cache = FileStateCache(mtimer, app)
    parser_factory = DoxygenParserFactory(cache, path_handler, file_state_cache)
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(parser_factory, matcher_factory)
    index_parser = parser_factory.create_index_parser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    # Create a math_nodes object with a displaymath member for the displaymath
    # node so that we can treat it in the same way as the nodes & addnodes
    # modules in the NodeFactory
    math_nodes = collections.namedtuple("MathNodes", ["displaymath"])
    math_nodes.displaymath = sphinx.ext.mathbase.displaymath
    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes, math_nodes)

    cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
    c_domain_helper = CDomainHelper()
    domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
    domain_handler_factory_creator = DomainHandlerFactoryCreator(node_factory, domain_helpers)

    rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
    default_domain_handler = NullDomainHandler()
    renderer_factory_creator_constructor = DoxygenToRstRendererFactoryCreatorConstructor(
        node_factory,
        parser_factory,
        default_domain_handler,
        domain_handler_factory_creator,
        rst_content_creator
        )

    # Assume general build directory is the doctree directory without the last component. We strip
    # off any trailing slashes so that dirname correctly drops the last part. This can be overriden
    # with the breathe_build_directory config variable
    build_dir = os.path.dirname(app.doctreedir.rstrip(os.sep))
    project_info_factory = ProjectInfoFactory(app.srcdir, build_dir, app.confdir, fnmatch.fnmatch)
    glob_factory = GlobFactory(fnmatch.fnmatch)
    filter_factory = FilterFactory(glob_factory, path_handler)
    target_handler_factory = TargetHandlerFactory(node_factory)

    root_data_object = RootDataObject()

    directive_factory = DoxygenDirectiveFactory(
        root_data_object,
        renderer_factory_creator_constructor,
        finder_factory,
        matcher_factory,
        project_info_factory,
        filter_factory,
        target_handler_factory
        )

    app.add_directive(
        "doxygenindex",
        directive_factory.create_index_directive_container(),
        )

    app.add_directive(
        "doxygenfunction",
        directive_factory.create_function_directive_container(),
        )

    app.add_directive(
        "doxygenstruct",
        directive_factory.create_struct_directive_container(),
        )

    app.add_directive(
        "doxygenenum",
        directive_factory.create_enum_directive_container(),
        )

    app.add_directive(
        "doxygentypedef",
        directive_factory.create_typedef_directive_container(),
        )

    app.add_directive(
        "doxygenunion",
        directive_factory.create_union_directive_container(),
        )

    app.add_directive(
        "doxygenclass",
        directive_factory.create_class_directive_container(),
        )

    app.add_directive(
        "doxygenfile",
        directive_factory.create_file_directive_container(),
        )

    app.add_directive(
        "doxygennamespace",
        directive_factory.create_namespace_directive_container(),
        )

    app.add_directive(
        "doxygengroup",
        directive_factory.create_group_directive_container(),
        )

    app.add_directive(
        "doxygenvariable",
        directive_factory.create_variable_directive_container(),
        )

    app.add_directive(
        "doxygendefine",
        directive_factory.create_define_directive_container(),
        )

    app.add_directive(
        "autodoxygenindex",
        directive_factory.create_auto_index_directive_container(),
        )

    app.add_directive(
        "autodoxygenfile",
        directive_factory.create_auto_file_directive_container(),
        )

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)
    app.add_config_value("breathe_domain_by_extension", {}, True)
    app.add_config_value("breathe_domain_by_file_pattern", {}, True)
    app.add_config_value("breathe_projects_source", {}, True)
    app.add_config_value("breathe_build_directory", '', True)
    app.add_config_value("breathe_default_members", (), True)

    app.add_stylesheet("breathe.css")

    doxygen_handle = AutoDoxygenProcessHandle(
        path_handler,
        subprocess.check_call,
        write_file,
        project_info_factory
        )

    app.connect("builder-inited", doxygen_handle.generate_xml)

    app.connect("builder-inited", directive_factory.get_config_values)

    app.connect("builder-inited", filter_factory.get_config_values)

    app.connect("env-get-outdated", file_state_cache.get_outdated)

    app.connect("env-purge-doc", file_state_cache.purge_doc)
Exemple #10
0
def setup(app):

    cache_factory = CacheFactory()
    cache = cache_factory.create_cache()
    path_handler = PathHandler(os.sep, os.path.basename, os.path.join)
    mtimer = MTimer(os.path.getmtime)
    file_state_cache = FileStateCache(mtimer, app)
    parser_factory = DoxygenParserFactory(cache, path_handler,
                                          file_state_cache)
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(
        parser_factory, matcher_factory)
    index_parser = parser_factory.create_index_parser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    # Create a math_nodes object with a displaymath member for the displaymath
    # node so that we can treat it in the same way as the nodes & addnodes
    # modules in the NodeFactory
    math_nodes = collections.namedtuple("MathNodes", ["displaymath"])
    math_nodes.displaymath = sphinx.ext.mathbase.displaymath
    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes, math_nodes)

    cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
    c_domain_helper = CDomainHelper()
    domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
    domain_handler_factory_creator = DomainHandlerFactoryCreator(
        node_factory, domain_helpers)

    rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
    default_domain_handler = NullDomainHandler()
    renderer_factory_creator_constructor = DoxygenToRstRendererFactoryCreatorConstructor(
        node_factory, parser_factory, default_domain_handler,
        domain_handler_factory_creator, rst_content_creator)

    # Assume general build directory is the doctree directory without the last component. We strip
    # off any trailing slashes so that dirname correctly drops the last part. This can be overriden
    # with the breathe_build_directory config variable
    build_dir = os.path.dirname(app.doctreedir.rstrip(os.sep))
    project_info_factory = ProjectInfoFactory(app.srcdir, build_dir,
                                              fnmatch.fnmatch)
    glob_factory = GlobFactory(fnmatch.fnmatch)
    filter_factory = FilterFactory(glob_factory, path_handler)
    target_handler_factory = TargetHandlerFactory(node_factory)

    root_data_object = RootDataObject()

    directive_factory = DoxygenDirectiveFactory(
        root_data_object, renderer_factory_creator_constructor, finder_factory,
        matcher_factory, project_info_factory, filter_factory,
        target_handler_factory)

    app.add_directive(
        "doxygenindex",
        directive_factory.create_index_directive_container(),
    )

    app.add_directive(
        "doxygenfunction",
        directive_factory.create_function_directive_container(),
    )

    app.add_directive(
        "doxygenstruct",
        directive_factory.create_struct_directive_container(),
    )

    app.add_directive(
        "doxygenenum",
        directive_factory.create_enum_directive_container(),
    )

    app.add_directive(
        "doxygentypedef",
        directive_factory.create_typedef_directive_container(),
    )

    app.add_directive(
        "doxygenclass",
        directive_factory.create_class_directive_container(),
    )

    app.add_directive(
        "doxygenfile",
        directive_factory.create_file_directive_container(),
    )

    app.add_directive(
        "doxygenvariable",
        directive_factory.create_variable_directive_container(),
    )

    app.add_directive(
        "doxygendefine",
        directive_factory.create_define_directive_container(),
    )

    app.add_directive(
        "autodoxygenindex",
        directive_factory.create_auto_index_directive_container(),
    )

    doxygen_handle = DoxygenProcessHandle(path_handler, subprocess.check_call,
                                          write_file)
    app.add_transform(TransformWrapper(DoxygenAutoTransform, doxygen_handle))

    app.add_transform(DoxygenTransform)

    app.add_node(DoxygenNode)

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)
    app.add_config_value("breathe_domain_by_extension", {}, True)
    app.add_config_value("breathe_domain_by_file_pattern", {}, True)
    app.add_config_value("breathe_projects_source", {}, True)
    app.add_config_value("breathe_build_directory", '', True)

    app.add_stylesheet("breathe.css")

    app.connect("builder-inited", directive_factory.get_config_values)

    app.connect("env-get-outdated", file_state_cache.get_outdated)

    app.connect("env-purge-doc", file_state_cache.purge_doc)
Exemple #11
0
def setup(app):

    cache_factory = CacheFactory()
    cache = cache_factory.create_cache()
    path_handler = PathHandler(os.sep, os.path.basename, os.path.join)
    parser_factory = DoxygenParserFactory(cache, path_handler)
    matcher_factory = ItemMatcherFactory()
    item_finder_factory_creator = DoxygenItemFinderFactoryCreator(parser_factory, matcher_factory)
    index_parser = parser_factory.create_index_parser()
    finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

    node_factory = NodeFactory(docutils.nodes, sphinx.addnodes)

    cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
    c_domain_helper = CDomainHelper()
    domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
    domain_handler_factory_creator = DomainHandlerFactoryCreator(node_factory, domain_helpers)

    rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
    default_domain_handler = NullDomainHandler()
    renderer_factory_creator_constructor = DoxygenToRstRendererFactoryCreatorConstructor(
            node_factory,
            parser_factory,
            default_domain_handler,
            domain_handler_factory_creator,
            rst_content_creator
            )

    project_info_factory = ProjectInfoFactory(fnmatch.fnmatch)
    glob_factory = GlobFactory(fnmatch.fnmatch)
    filter_factory = FilterFactory(glob_factory, path_handler)
    target_handler_factory = TargetHandlerFactory(node_factory)

    root_data_object = RootDataObject()

    directive_factory = DoxygenDirectiveFactory(
            root_data_object,
            renderer_factory_creator_constructor,
            finder_factory,
            matcher_factory,
            project_info_factory,
            filter_factory,
            target_handler_factory
            )

    app.add_directive(
            "doxygenindex",
            directive_factory.create_index_directive_container(),
            )

    app.add_directive(
            "doxygenfunction",
            directive_factory.create_function_directive_container(),
            )

    app.add_directive(
            "doxygenstruct",
            directive_factory.create_struct_directive_container(),
            )

    app.add_directive(
            "doxygenenum",
            directive_factory.create_enum_directive_container(),
            )

    app.add_directive(
            "doxygentypedef",
            directive_factory.create_typedef_directive_container(),
            )

    app.add_directive(
            "doxygenclass",
            directive_factory.create_class_directive_container(),
            )

    app.add_directive(
            "doxygenfile",
            directive_factory.create_file_directive_container(),
            )

    app.add_directive(
            "doxygenvariable",
            directive_factory.create_variable_directive_container(),
            )

    app.add_directive(
            "doxygendefine",
            directive_factory.create_define_directive_container(),
            )

    app.add_config_value("breathe_projects", {}, True)
    app.add_config_value("breathe_default_project", "", True)
    app.add_config_value("breathe_domain_by_extension", {}, True)
    app.add_config_value("breathe_domain_by_file_pattern", {}, True)

    app.add_stylesheet("breathe.css")

    app.connect("builder-inited", directive_factory.get_config_values)
Exemple #12
0
from breathe import NodeFactory, ProjectInfoFactory, DoxygenDirectiveFactory, PathHandler, RootDataObject

import docutils.nodes
import sphinx.addnodes
import textwrap
import fnmatch
import os
import re

# Sphinx source/conf.py file
import conf

cache_factory = CacheFactory()
cache = cache_factory.create_cache()
path_handler = PathHandler(os.sep, os.path.basename, os.path.join)
parser_factory = DoxygenParserFactory(cache, path_handler)
matcher_factory = ItemMatcherFactory()
item_finder_factory_creator = DoxygenItemFinderFactoryCreator(
    parser_factory, matcher_factory)
index_parser = DoxygenIndexParser(cache, path_handler)
finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

node_factory = NodeFactory(docutils.nodes, sphinx.addnodes)

cpp_domain_helper = CppDomainHelper(DefinitionParser, re.sub)
c_domain_helper = CDomainHelper()
domain_helpers = {"c": c_domain_helper, "cpp": cpp_domain_helper}
domain_handler_factory_creator = DomainHandlerFactoryCreator(
    node_factory, domain_helpers)

rst_content_creator = RstContentCreator(ViewList, textwrap.dedent)
Exemple #13
0
from docutils.parsers import rst
from breathe.builder import RstBuilder, BuilderFactory
from breathe.finder import FinderFactory, NoMatchesError, MultipleMatchesError
from breathe.parser import DoxygenParserFactory, DoxygenIndexParser
from breathe.renderer.rst.doxygen import DoxygenToRstRendererFactoryCreator
from breathe.finder.doxygen import DoxygenItemFinderFactoryCreator, ItemMatcherFactory

from breathe import NodeFactory, ProjectInfoFactory, DoxygenDirectiveFactory

import docutils.nodes
import sphinx.addnodes

# Sphinx source/conf.py file
import conf

parser_factory = DoxygenParserFactory()
matcher_factory = ItemMatcherFactory()
item_finder_factory_creator = DoxygenItemFinderFactoryCreator(
    parser_factory, matcher_factory)
index_parser = DoxygenIndexParser()
finder_factory = FinderFactory(index_parser, item_finder_factory_creator)

node_factory = NodeFactory(docutils.nodes, sphinx.addnodes)
renderer_factory_creator = DoxygenToRstRendererFactoryCreator(
    node_factory, parser_factory)
builder_factory = BuilderFactory(RstBuilder, renderer_factory_creator)

project_info_factory = ProjectInfoFactory()
project_info_factory.update(conf.breathe_projects,
                            conf.breathe_default_project)
Exemple #14
0
 def __init__(self, app: Sphinx, parser_factory: DoxygenParserFactory):
     self.app = app
     self.parser_factory = parser_factory
     self.parser = parser_factory.create_index_parser()