Synopsis - Synopsis/Formatters/HTML/Fragment.py

File: Synopsis/Formatters/HTML/Fragment.py

     1#
     2# Copyright (C) 2000 Stephen Davies
     3# Copyright (C) 2000 Stefan Seefeld
     4# All rights reserved.
     5# Licensed to the public under the terms of the GNU LGPL (>= 2),
     6# see the file COPYING for details.
     7#
     8
     9from Tags import *
    10
    11class Fragment(object):
    12   """Generates HTML fragment for a declaration. Multiple strategies are
    13   combined to generate the output for a single declaration, allowing the
    14   user to customise the output by choosing a set of strategies. This follows
    15   the Strategy design pattern.
    16
    17   The key concept of this class is the format* methods. Any
    18   class derived from Strategy that overrides one of the format methods
    19   will have that method called by the Summary and Detail formatters when
    20   they visit that ASG type. Summary and Detail maintain a list of
    21   Strategies, and a list for each ASG type.
    22
    23   For example, when Strategy.Summary visits a Function object, it calls
    24   the formatFunction method on all Strategys registed with
    25   SummaryFormatter that implemented that method. Each of these format
    26   methods returns a string, which may contain a TD tag to create a new
    27   column.
    28
    29   An important point to note is that only Strategies which override a
    30   particular format method are called - if that format method is not
    31   overridden then it is not called for that declaration type.
    32   """
    33
    34   def register(self, formatter):
    35      """Store formatter as self.formatter. The formatter is either a
    36      SummaryFormatter or DetailFormatter, and is used for things like
    37      reference() and label() calls. Local references to the formatter's
    38      reference and label methods are stored in self for more efficient use
    39      of them."""
    40
    41      self.processor = formatter.processor
    42      self.directory_layout = self.processor.directory_layout
    43      self.formatter = formatter
    44      self.label = formatter.label
    45      self.reference = formatter.reference
    46      self.format_type = formatter.format_type
    47      self.view = formatter.view()
    48
    49   #
    50   # Utility methods
    51   #
    52   def format_modifiers(self, modifiers):
    53      """Returns a HTML string from the given list of string modifiers. The
    54      modifiers are enclosed in 'keyword' spans."""
    55
    56      def keyword(m):
    57         if m == '&': return span('keyword', '&amp;')
    58         return span('keyword', m)
    59      return ''.join([keyword(m) for m in modifiers])
    60
    61
    62   #
    63   # ASG Formatters
    64   #
    65   def format_declaration(self, decl): pass
    66   def format_macro(self, decl): pass
    67   def format_forward(self, decl): pass
    68   def format_group(self, decl): pass
    69   def format_scope(self, decl): pass
    70   def format_module(self, decl): pass
    71   def format_meta_module(self, decl): pass
    72   def format_class(self, decl): pass
    73   def format_class_template(self, decl): pass
    74   def format_typedef(self, decl): pass
    75   def format_enum(self, decl): pass
    76   def format_variable(self, decl): pass
    77   def format_const(self, decl): pass
    78   def format_function(self, decl): pass
    79   def format_function_template(self, decl): pass
    80   def format_operation(self, decl): pass
    81   def format_operation_template(self, decl): pass
    82

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