Synopsis - Synopsis/Formatters/HTML/XRefPager.py

File: Synopsis/Formatters/HTML/XRefPager.py

     1#
     2# Copyright (C) 2008 Stefan Seefeld
     3# All rights reserved.
     4# Licensed to the public under the terms of the GNU LGPL (>= 2),
     5# see the file COPYING for details.
     6#
     7
     8class XRefPager:
     9    """Generates pages of cross-references."""
    10
    11    def __init__(self, ir):
    12
    13        self.page_map = {}
    14        self.page_info = []
    15
    16        # Split the data into multiple files based on size
    17        page = 0
    18        count = 0
    19        names = ir.sxr.keys()
    20        if names:
    21            self.page_info.append([])
    22        names.sort()
    23        for name in names:
    24            if count > 200:
    25                count = 0
    26                page += 1
    27                self.page_info.append([])
    28            self.page_info[page].append(name)
    29            self.page_map[name] = page
    30            entry = ir.sxr[name]
    31            d, c, r = len(entry.definitions), len(entry.calls), len(entry.references)
    32            count += 1 + d + c + r
    33            if d: count += 1
    34            if c: count += 1
    35            if r: count += 1
    36
    37    def get(self, name):
    38        """Returns the number of the page that the xref info for the given
    39        name is on, or None if not found."""
    40
    41        return self.page_map.get(name)
    42
    43    def pages(self):
    44        """Returns a list of pages, each consisting of a list of names on that
    45        page. This method is intended to be used by whatever generates the
    46        files..."""
    47
    48        return self.page_info
    49

Generated on Thu Apr 16 16:27:14 2009 by
synopsis (version devel)