Esempio n. 1
0
 def _format_type_tokens (self, type_tokens):
     if self.__gi_extension.language != 'c':
         new_tokens = []
         for tok in type_tokens:
             if tok not in ['*', 'const', 'restrict', 'volatile']:
                 new_tokens.append (tok)
         return HtmlFormatter._format_type_tokens (self, new_tokens)
     return HtmlFormatter._format_type_tokens (self, type_tokens)
Esempio n. 2
0
    def _format_constant(self, constant):
        if self.__gi_extension.language == 'c':
            return HtmlFormatter._format_constant (self, constant)

        template = self.engine.get_template('constant.html')
        out = template.render ({'definition': None,
                                'constant': constant})
        return (out, False)
Esempio n. 3
0
    def _format_callable_summary (self, return_value, function_name,
            is_callable, is_pointer, flags):
        if self.__gi_extension.language in ["python", "javascript"]:
            is_pointer = False
            return_value = None

        return HtmlFormatter._format_callable_summary (self, return_value,
                function_name, is_callable, is_pointer, flags)
Esempio n. 4
0
    def format (self):
        for l in self.__gi_extension.languages:
            if l == 'python':
                self.fundamentals = self.python_fundamentals
            elif l == 'javascript':
                self.fundamentals = self.javascript_fundamentals
            else:
                self.fundamentals = {}

            for c_name, link in self.fundamentals.iteritems():
                link.id_ = c_name
                doc_tool.link_resolver.add_external_link (link)

            self.__gi_extension.setup_language (l)
            self._output = os.path.join (doc_tool.output, l)
            if not os.path.exists (self._output):
                os.mkdir (self._output)
            HtmlFormatter.format (self)
Esempio n. 5
0
    def _format_struct (self, struct):
        if self.__gi_extension.language == 'c':
            return HtmlFormatter._format_struct (self, struct)
        members_list = self._format_members_list (struct.members, 'Attributes')

        template = self.engine.get_template ("python_compound.html")
        out = template.render ({"compound": struct,
                                "members_list": members_list})
        return (out, False)
Esempio n. 6
0
    def _format_class (self, klass):
        new_names = None
        if self.__gi_extension.language == 'python':
            new_names = self.__gi_extension.gir_parser.python_names
        elif self.__gi_extension.language == 'javascript':
            new_names = self.__gi_extension.gir_parser.javascript_names

        if new_names is not None:
            doc_tool.page_parser.rename_headers (klass.parsed_page, new_names)
        return HtmlFormatter._format_class (self, klass)
Esempio n. 7
0
    def __init__(self, gi_extension):
        from hotdoc.extensions.gi_extension import (GIClassSymbol,
                GIPropertySymbol, GISignalSymbol, GIVFunctionSymbol)
        from hotdoc.core.symbols import FunctionMacroSymbol

        module_path = os.path.dirname(__file__)
        searchpath = [os.path.join(module_path, "templates")]
        self.__gi_extension = gi_extension
        HtmlFormatter.__init__(self, searchpath)
        self._symbol_formatters[GIClassSymbol] = self._format_class
        self._symbol_formatters[GIPropertySymbol] = self._format_gi_property
        self._summary_formatters[GIPropertySymbol] = self._format_gi_property_summary
        self._symbol_formatters[GISignalSymbol] = self._format_gi_signal
        self._summary_formatters[GISignalSymbol] = self._format_gi_signal_summary
        self._symbol_formatters[GIVFunctionSymbol] = self._format_gi_vmethod
        self._summary_formatters[GIVFunctionSymbol] = self._format_gi_vmethod_summary
        self._ordering.insert (2, GIPropertySymbol)
        self._ordering.insert (3, GISignalSymbol)
        self._ordering.insert (4, GIVFunctionSymbol)
        self.python_fundamentals = self.__create_python_fundamentals()
        self.javascript_fundamentals = self.__create_javascript_fundamentals()
Esempio n. 8
0
    def _format_enum (self, enum):
        if self.__gi_extension.language == 'c':
            return HtmlFormatter._format_enum (self, enum)

        for member in enum.members:
            template = self.engine.get_template ("enum_member.html")
            member.detailed_description = template.render ({
                                    'link': member.link,
                                    'detail': member.formatted_doc,
                                    'value': str (member.enum_value)})

        members_list = self._format_members_list (enum.members, 'Members')
        template = self.engine.get_template ("python_compound.html")
        out = template.render ({"compound": enum,
                                "members_list": members_list})
        return (out, False)
Esempio n. 9
0
    def _format_prototype (self, function, is_pointer, title):
        from hotdoc.extensions.gi_extension import GISignalSymbol, GIVFunctionSymbol

        if self.__gi_extension.language in ["python", "javascript"]:
            params = []
            out_params = []
            retval = function.return_value
            for param in function.parameters:
                param.formatted_link = self._format_type_tokens(param.type_tokens)
                if param.detailed_description is not None:
                    params.append (param)
                else:
                    out_params.append (param)

            if retval:
                retval.formatted_link = self._format_type_tokens(retval.type_tokens)
                if retval.link.title == 'void':
                    retval = None

            c_name = function._make_name()

            if self.__gi_extension.language == 'python':
                template = self.engine.get_template('python_prototype.html')
            else:
                template = self.engine.get_template('javascript_prototype.html')

            if type (function) == GISignalSymbol:
                comment = "%s callback for the '%s' signal" % (self.__gi_extension.language, c_name)
            elif type (function) == GIVFunctionSymbol:
                comment = "%s implementation of the '%s' virtual method" % \
                        (self.__gi_extension.language, c_name)
            else:
                comment = "%s wrapper for '%s'" % (self.__gi_extension.language,
                        c_name)

            return template.render ({'return_value': retval,
                'function_name': title, 'parameters':
                params, 'comment': comment, 'throws': function.throws,
                'out_params': out_params, 'is_method': function.is_method})

        return HtmlFormatter._format_prototype (self, function,
            is_pointer, title)
Esempio n. 10
0
 def _format_constant_summary (self, constant):
     if self.__gi_extension.language == 'c':
         return HtmlFormatter._format_constant_summary (self, constant)
     return self._format_compound_summary (constant)
Esempio n. 11
0
 def _format_alias_summary (self, alias):
     if self.__gi_extension.language == 'c':
         return HtmlFormatter._format_alias_summary (self, alias)
     return self._format_compound_summary (alias)
Esempio n. 12
0
 def _format_enum_summary (self, enum):
     if self.__gi_extension.language == 'c':
         return HtmlFormatter._format_enum_summary (self, enum)
     return self._format_compound_summary (enum)
Esempio n. 13
0
    def _format_callable (self, callable_, callable_type, title,
            is_pointer=False, flags=None):

        return HtmlFormatter._format_callable (self, callable_, callable_type, title,
                is_pointer, flags)