Пример #1
0
    def format(self, record):
        self.root.attrib['id'] = htmltree.chain_values(record.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(
            record.get_name())
        reference_list = record.implements
        with self.open('header'):
            self.h2(record.type_name)

            if reference_list:
                for reference in reference_list:
                    self.italic('implements abstract type: ')
                    self.link(reference.get_reference().name)

            if record.reducible_to_key:
                if reference_list:
                    self.tag('br')
                self.italic('constructible from key: ')
                self.link(record.reducible_to_key, ns=record.type_name)

            self.description(record.description)

        with self.open('ul', attrib={'class': 'item-list'}):
            for record_key in record.keys:

                if not record_key.include_in_format():
                    continue

                with self.open('li'):
                    fmt = HTMLFormatter.get_formatter_for(record_key)
                    fmt.format(record_key, record)
                    self.add(fmt.current())
Пример #2
0
    def format(self, record):
        self.root.attrib['id'] = htmltree.chain_values(record.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(record.get_name())
        reference_list = record.implements
        with self.open('header'):
            self.h2(record.type_name)

            if reference_list:
                for reference in reference_list:
                    self.italic('implements abstract type: ')
                    self.link(reference.get_reference().name)

            if record.reducible_to_key:
                if reference_list:
                    self.tag('br')
                self.italic('constructible from key: ')
                self.link(record.reducible_to_key, ns=record.type_name)

            self.description(record.description)

        with self.open('ul', attrib={ 'class': 'item-list' }):
            for record_key in record.keys:
                if not record_key.include_in_format():
                    continue
                with self.open('li'):
                    fmt = HTMLFormatter.get_formatter_for(record_key)
                    fmt.format(record_key, record)
                    self.add(fmt.current())
Пример #3
0
    def format(self, selection):
        self.root.attrib['id'] = htmltree.chain_values(selection.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(selection.get_name())
        with self.open('header'):
            self.h2(selection.name)
            self.description(selection.description)

        with self.open('ul', attrib={ 'class': 'item-list' }):
            for selection_value in selection.values:
                with self.open('li'):
                    self.h3(selection_value.get_name())
                    self.description(selection_value.description)

        return self
Пример #4
0
    def format(self, selection):
        self.root.attrib['id'] = htmltree.chain_values(selection.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(
            selection.get_name())
        with self.open('header'):
            self.h2(selection.name)
            self.description(selection.description)

        with self.open('ul', attrib={'class': 'item-list'}):
            for selection_value in selection.values:
                with self.open('li'):
                    self.h3(selection_value.get_name())
                    self.description(selection_value.description)

        return self
Пример #5
0
    def format(self, abstract_record):
        self.root.attrib['id'] = htmltree.chain_values(abstract_record.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(abstract_record.get_name())
        with self.open('header'):
            self.h2(abstract_record.name)

            if abstract_record.default_descendant:
                reference = abstract_record.default_descendant.get_reference()
                self.italic('Default descendant ')
                self.link(reference.get_name())

            self.description(abstract_record.description)

        self.italic('Implemented by:')
        with self.open('ul', attrib={ 'class': 'item-list' }):
            for descendant in abstract_record.implementations:
                reference = descendant.get_reference()
                with self.open('li'):
                    self.link(reference.type_name)
                    self.info(' - ')
                    self.span(reference.description)
Пример #6
0
    def format(self, abstract_record):
        self.root.attrib['id'] = htmltree.chain_values(
            abstract_record.get_name())
        self.root.attrib['data-name'] = htmltree.chain_values(
            abstract_record.get_name())
        with self.open('header'):
            self.h2(abstract_record.name)

            if abstract_record.default_descendant:
                reference = abstract_record.default_descendant.get_reference()
                self.italic('Default descendant ')
                self.link(reference.get_name())

            self.description(abstract_record.description)

        self.italic('Implemented by:')
        with self.open('ul', attrib={'class': 'item-list'}):
            for descendant in abstract_record.implementations:
                reference = descendant.get_reference()
                with self.open('li'):
                    self.link(reference.type_name)
                    self.info(' - ')
                    self.span(reference.description)
Пример #7
0
    def get_url_by_name(label, type=''):
        """
        constructs and returns tuple (name, type, link) from given name and label
        :param label: name#field where field is optional
        :param type:
        :return: triplet of (name. type, #link) or triplet of None
        """
        from ist.utils.htmltree import htmltree
        parts = label.split("#")
        name = parts[0]
        fields = parts[1:]

        for (id, item) in Globals.items.iteritems():
            try:
                if item.get('type_name', 'name', 'id').lower() == name.lower():

                    # only link to item?
                    if not fields:
                        return item.get_name(), item.get_type(), '#' + htmltree.chain_values(item.get_name())

                    # link to item's field
                    if fields:
                        curr = item
                        for field in fields:
                            find = Globals.search_in_element(curr, field)
                            if not find:
                                print 'cannot find {} on {}'.format(field, curr)
                                return None
                            # next level
                            curr = find

                        return curr.get_name(), curr.get_type(), '#' + htmltree.chain_values(curr.get_name(), item.get_name())
            except:
                # no such attribute
                pass

        return (None, None, None)