Ejemplo n.º 1
0
    def handle_contents(self, file_, project_info):
        finder = self.finder_factory.create_finder(project_info)
        finder_filter = self.filter_factory.create_file_finder_filter(file_)

        matches = []
        finder.filter_(finder_filter, matches)

        if len(matches) > 1:
            warning = self.create_warning(None, file=file_, directivename=self.directive_name)
            return warning.warn('{directivename}: Found multiple matches for file "{file} {tail}')
        elif not matches:
            warning = self.create_warning(None, file=file_, directivename=self.directive_name)
            return warning.warn('{directivename}: Cannot find file "{file} {tail}')

        target_handler = create_target_handler(self.options, project_info, self.state.document)
        filter_ = self.filter_factory.create_file_filter(file_, self.options)

        node_list = []
        for node_stack in matches:
            object_renderer = SphinxRenderer(
                self.parser_factory.app,
                project_info,
                node_stack,
                self.state,
                self.state.document,
                target_handler,
                self.parser_factory.create_compound_parser(project_info),
                filter_,
            )

            mask_factory = NullMaskFactory()
            context = RenderContext(node_stack, mask_factory, self.directive_args)
            node_list.extend(object_renderer.render(node_stack[0], context))

        return node_list
Ejemplo n.º 2
0
def render(app,
           member_def,
           domain=None,
           show_define_initializer=False,
           compound_parser=None,
           options=[]):
    """Render Doxygen *member_def* with *renderer_class*."""

    app.config.breathe_separate_member_pages = False
    app.config.breathe_use_project_refids = False
    app.config.breathe_show_define_initializer = show_define_initializer
    app.config.breathe_debug_trace_directives = False
    app.config.breathe_debug_trace_doxygen_ids = False
    app.config.breathe_debug_trace_qualification = False
    renderer = SphinxRenderer(
        app,
        None,  # project_info
        [],  # node_stack
        None,  # state
        None,  # document
        MockTargetHandler(),
        compound_parser,
        OpenFilter())
    renderer.context = MockContext(app, [member_def], domain, options)
    return renderer.render(member_def)
Ejemplo n.º 3
0
    def render(
        self,
        node_stack,
        project_info: ProjectInfo,
        filter_: Filter,
        target_handler: TargetHandler,
        mask_factory: MaskFactoryBase,
        directive_args,
    ) -> List[nodes.Node]:
        "Standard render process used by subclasses"

        try:
            object_renderer = SphinxRenderer(
                self.parser_factory.app,
                project_info,
                node_stack,
                self.state,
                self.state.document,
                target_handler,
                self.parser_factory.create_compound_parser(project_info),
                filter_,
            )
        except ParserError as e:
            return format_parser_error("doxygenclass", e.error, e.filename,
                                       self.state, self.lineno, True)
        except FileIOError as e:
            return format_parser_error("doxygenclass", e.error, e.filename,
                                       self.state, self.lineno, True)

        context = RenderContext(node_stack, mask_factory, directive_args)
        return object_renderer.render(node_stack[0], context)
Ejemplo n.º 4
0
def render(member_def, domain=None, show_define_initializer=False):
    """Render Doxygen *member_def* with *renderer_class*."""
    renderer = SphinxRenderer(MockProjectInfo(show_define_initializer),
                              None,  # renderer_factory
                              create_node_factory(),
                              None,  # state
                              None,  # document
                              MockTargetHandler(),
                              None,   # compound_parser
                              OpenFilter())
    renderer.context = MockContext([member_def], domain)
    return renderer.render(member_def)
Ejemplo n.º 5
0
def render(member_def, domain=None, show_define_initializer=False):
    """Render Doxygen *member_def* with *renderer_class*."""
    renderer = SphinxRenderer(MockProjectInfo(show_define_initializer),
                              None,  # renderer_factory
                              create_node_factory(),
                              None,  # state
                              None,  # document
                              MockTargetHandler(),
                              None,   # compound_parser
                              OpenFilter())
    renderer.context = MockContext([member_def], domain)
    return renderer.render(member_def)
Ejemplo n.º 6
0
def render(member_def):
    """Render Doxygen *member_def* with *renderer_class*."""
    renderer = SphinxRenderer(MockProjectInfo(),
                              None,  # renderer_factory
                              create_node_factory(),
                              None,  # state
                              None,  # document
                              MockTargetHandler(),
                              None,   # compound_parser
                              OpenFilter())
    renderer.context = MockContext([member_def])
    return renderer.render(member_def)
Ejemplo n.º 7
0
def render(member_def):
    """Render Doxygen *member_def* with *renderer_class*."""
    renderer = SphinxRenderer(
        MockProjectInfo(),
        None,  # renderer_factory
        create_node_factory(),
        None,  # state
        None,  # document
        MockTargetHandler(),
        None,  # compound_parser
        OpenFilter())
    renderer.context = MockContext([member_def])
    return renderer.render(member_def)
Ejemplo n.º 8
0
    def handle_contents(self, project_info):
        try:
            finder = self.finder_factory.create_finder(project_info)
        except ParserError as e:
            return format_parser_error(self.name, e.error, e.filename,
                                       self.state, self.lineno, True)
        except FileIOError as e:
            return format_parser_error(self.name, e.error, e.filename,
                                       self.state, self.lineno)

        data_object = finder.root()

        target_handler = create_target_handler(self.options, project_info,
                                               self.state.document)
        filter_ = self.filter_factory.create_index_filter(self.options)

        object_renderer = SphinxRenderer(
            self.parser_factory.app,
            project_info,
            [data_object],
            self.state,
            self.state.document,
            target_handler,
            self.parser_factory.create_compound_parser(project_info),
            filter_,
        )

        mask_factory = NullMaskFactory()
        context = RenderContext([data_object, RootDataObject()], mask_factory,
                                self.directive_args)

        try:
            node_list = object_renderer.render(context.node_stack[0], context)
        except ParserError as e:
            return format_parser_error(self.name, e.error, e.filename,
                                       self.state, self.lineno, True)
        except FileIOError as e:
            return format_parser_error(self.name, e.error, e.filename,
                                       self.state, self.lineno)

        return node_list
Ejemplo n.º 9
0
    def create_function_signature(self, node_stack, project_info, filter_,
                                  target_handler, mask_factory,
                                  directive_args):
        "Standard render process used by subclasses"

        try:
            object_renderer = SphinxRenderer(
                self.parser_factory.app,
                project_info,
                node_stack,
                self.state,
                self.state.document,
                target_handler,
                self.parser_factory.create_compound_parser(project_info),
                filter_,
            )
        except ParserError as e:
            return format_parser_error("doxygenclass", e.error, e.filename,
                                       self.state, self.lineno, True)
        except FileIOError as e:
            return format_parser_error("doxygenclass", e.error, e.filename,
                                       self.state, self.lineno)

        context = RenderContext(node_stack, mask_factory, directive_args)
        node = node_stack[0]
        with WithContext(object_renderer, context):
            # this part should be kept in sync with visit_function in sphinxrenderer
            name = node.get_name()
            # assume we are only doing this for C++ declarations
            declaration = ' '.join([
                object_renderer.create_template_prefix(node),
                ''.join(n.astext()
                        for n in object_renderer.render(node.get_type())),
                name,
                node.get_argsstring()
            ])
        parser = cpp.DefinitionParser(declaration,
                                      location=self.get_source_info(),
                                      config=self.config)
        ast = parser.parse_declaration('function', 'function')
        return str(ast)
Ejemplo n.º 10
0
    def run(self) -> List[Node]:
        name = self.arguments[0]

        try:
            project_info = self.project_info_factory.create_project_info(
                self.options)
        except ProjectError as e:
            warning = create_warning(None,
                                     self.state,
                                     self.lineno,
                                     kind=self.kind)
            return warning.warn('doxygen{kind}: %s' % e)

        try:
            finder = self.finder_factory.create_finder(project_info)
        except MTimeError as e:
            warning = create_warning(None,
                                     self.state,
                                     self.lineno,
                                     kind=self.kind)
            return warning.warn('doxygen{kind}: %s' % e)

        finder_filter = self.filter_factory.create_finder_filter(
            self.kind, name)

        # TODO: find a more specific type for the Doxygen nodes
        matches = []  # type: List[Any]
        finder.filter_(finder_filter, matches)

        # It shouldn't be possible to have too many matches as namespaces & groups in their nature
        # are merged together if there are multiple declarations, so we only check for no matches
        if not matches:
            warning = create_warning(project_info,
                                     self.state,
                                     self.lineno,
                                     name=name,
                                     kind=self.kind)
            return warning.warn(
                'doxygen{kind}: Cannot find namespace "{name}" {tail}')

        if 'content-only' in self.options:
            # Unpack the single entry in the matches list
            (node_stack, ) = matches

            filter_ = self.filter_factory.create_content_filter(
                self.kind, self.options)

            # Having found the compound node for the namespace or group in the index we want to grab
            # the contents of it which match the filter
            contents_finder = self.finder_factory.create_finder_from_root(
                node_stack[0], project_info)
            # TODO: find a more specific type for the Doxygen nodes
            contents = []  # type: List[Any]
            contents_finder.filter_(filter_, contents)

            # Replaces matches with our new starting points
            matches = contents

        target_handler = create_target_handler(self.options, project_info,
                                               self.state.document)
        filter_ = self.filter_factory.create_render_filter(
            self.kind, self.options)

        node_list = []
        for node_stack in matches:
            object_renderer = SphinxRenderer(
                self.parser_factory.app, project_info, node_stack, self.state,
                self.state.document, target_handler,
                self.parser_factory.create_compound_parser(project_info),
                filter_)

            mask_factory = NullMaskFactory()
            context = RenderContext(node_stack, mask_factory,
                                    self.directive_args)
            node_list.extend(
                object_renderer.render(context.node_stack[0], context))

        return node_list