File: model/document/module.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: TmDoc#10
  module: Model
  module: Document#12
  module: Module#14
has properties
constant: TAG_LIST #15
  class: PropertySection#29
inherits from
  Abstract ( TmStd::Lsm::Product )
has properties
attribute: tag [R] #30
attribute: properties [R] #30
method: initialize / 2 #32
  class: SeqOfPropertySection#41
inherits from
  Abstract ( TmStd::Lsm::Collection::Sequence )
has properties
constant: LSM_ELEMENT_CLASS #42
  class: Module#47
inherits from
  Document ( TmDoc::Model::Document::Abstraction )
has properties
attribute: above_path [R] #48
attribute: name [R] #49
attribute: a_link_to_above_module [R] #50
attribute: a_infobox [R] #51
attribute: a_module_structure [R] #52
attribute: a_class_hierarchy [R] #53
attribute: property_sections [R] #54
attribute: aliases [R] #55
attribute: attributes [R] #56
attribute: methods [R] #57
method: initialize / 7 #60
method: path #91
method: print #98
  class: SeqOfModule#157
inherits from
  SeqOfDocument ( TmDoc::Model::Document::Abstraction )
has properties
constant: LSM_ELEMENT_CLASS #158
  class: ToplevelModule#163
inherits from
  Module ( TmDoc::Model::Document::Module )
  class: BuiltinModule#167
inherits from
  Module ( TmDoc::Model::Document::Module )
  class: UnknownModule#171
inherits from
  Module ( TmDoc::Model::Document::Module )
  class: Class#175
inherits from
  Module ( TmDoc::Model::Document::Module )
  class: UnknownClass#179
inherits from
  Class ( TmDoc::Model::Document::Module )
  class: Constant#183
inherits from
  Property ( TmDoc::Model::Document::Abstraction::Module )
has properties
attribute: value [R] #184
method: initialize / 6 #187
  class: Alias#212
inherits from
  Property ( TmDoc::Model::Document::Abstraction::Module )
has properties
attribute: orig_name [R] #213
method: initialize / 6 #216
  class: Attribute#239
inherits from
  Property ( TmDoc::Model::Document::Abstraction::Module )
has properties
attribute: accessor [R] #240
method: initialize / 6 #243
  class: Method#266
inherits from
  Property ( TmDoc::Model::Document::Abstraction::Module )
has properties
attribute: args [R] #267
method: initialize / 6 #270

Code

   1  # $Id: module.rb,v 1.15 2011/12/08 23:10:50 machan Exp $
   2 
   3  require 'tmdoc/constant'
   4  require 'tmdoc/model/document/abstraction'
   5  require 'tmdoc/model/document/path'
   6  require 'tmdoc/model/document/link'
   7  require 'tmdoc/model/document/module-infobox'
   8 
   9 
  10  module TmDoc
  11 
  12  module Model::Document
  13 
  14  module Module
  15      TAG_LIST = [
  16          :constant,
  17          :module_alias,
  18          :module_attribute,
  19          :module_function,
  20          :module_method,
  21          :class_alias,
  22          :class_attribute,
  23          :class_method,
  24          :instance_alias,
  25          :instance_attribute,
  26          :instance_method
  27      ]
  28 
  29  class PropertySection < TmStd::Lsm::Product::Abstract
  30      attr_reader :tag, :properties
  31 
  32      def initialize(tag, properties)
  33          ASSERT.kind_of  tag,        Symbol
  34          ASSERT.kind_of  properties, MDA::Module::SeqOfProperty
  35 
  36          @tag        = tag
  37          @properties = properties
  38      end
  39  end
  40 
  41  class SeqOfPropertySection < TmStd::Lsm::Collection::Sequence::Abstract
  42      LSM_ELEMENT_CLASS = PropertySection
  43  end
  44 
  45 
  46 
  47  class Module < Abstraction::Document
  48      attr_reader :above_path,
  49                  :name,
  50                  :a_link_to_above_module,
  51                  :a_infobox,
  52                  :a_module_structure,
  53                  :a_class_hierarchy,
  54                  :property_sections,
  55                  :aliases,
  56                  :attributes,
  57                  :methods
  58 
  59 
  60      def initialize(
  61          above_path,
  62          name,
  63          a_link_to_above_module,
  64          a_infobox,
  65          a_module_structure,
  66          a_class_hierarchy,
  67          property_sections
  68      )
  69          ASSERT.kind_of      above_path,             Path
  70          ASSERT.kind_of      name,                   String
  71          ASSERT.opt_kind_of  a_link_to_above_module, MDL::Module
  72          ASSERT.opt_kind_of  a_infobox,              MDM::InfoBox::InfoBox
  73          ASSERT.opt_kind_of  a_module_structure,     MDN::ModuleStructure
  74          ASSERT.opt_kind_of  a_class_hierarchy,      MDN::ClassHierarchy
  75          ASSERT.opt_kind_of(
  76              property_sections, MDM::SeqOfPropertySection
  77          )
  78 
  79          @above_path = above_path
  80          @name       = name
  81 
  82          @a_link_to_above_module = a_link_to_above_module
  83          @a_infobox              = a_infobox
  84          @a_module_structure     = a_module_structure
  85          @a_class_hierarchy      = a_class_hierarchy
  86 
  87          @property_sections  = property_sections
  88      end
  89 
  90 
  91      def path
  92          p = self.above_path << self.name
  93 
  94          ASSERT.kind_of p, Path
  95      end
  96 
  97 
  98      def print
  99          LOG::Debug.log(
 100              "\t---- %s: %s(%s) ----",
 101              self.class.to_s, self.name, above_path.to_s
 102          )
 103 
 104          ib = self.a_infobox
 105          if ib
 106              LOG::Debug.log "\ta_infobox:"
 107              ib.print
 108          end
 109 
 110          am = self.a_link_to_above_module
 111          if am
 112              LOG::Debug.log "\tabove_module_name: %s", am.name
 113          end
 114 
 115          pss = self.property_sections
 116          if pss
 117              LOG::Debug.log "\tproperty_sections:"
 118              for ps in pss
 119                  LOG::Debug.log "\t\ttag: %s", ps.to_s
 120                  LOG::Debug.log "\t\tproperties:"
 121                  for prop in ps.properties
 122                      LOG::Debug.log "\t\t%s", prop.to_s
 123                  end
 124              end
 125          end
 126 
 127          als = self.aliases
 128          if als
 129              LOG::Debug.log "\taliases:"
 130              for al in als
 131                  LOG::Debug.log "\t\t%s", al.to_s
 132              end
 133          end
 134 
 135          ats = self.attributes
 136          if ats
 137              LOG::Debug.log "\tattributes:"
 138              for at in ats
 139                  LOG::Debug.log "\t\t%s", at.to_s
 140              end
 141          end
 142 
 143          mes = self.methods
 144          if mes
 145              LOG::Debug.log "\tmethods:"
 146              for me in mes
 147                  LOG::Debug.log "\t\t%s", me.to_s
 148              end
 149          end
 150 
 151          nil
 152      end
 153  end
 154 
 155 
 156 
 157  class SeqOfModule < Abstraction::SeqOfDocument
 158      LSM_ELEMENT_CLASS = Module
 159  end
 160 
 161 
 162 
 163  class ToplevelModule < Module; end
 164 
 165 
 166 
 167  class BuiltinModule < Module; end
 168 
 169 
 170 
 171  class UnknownModule < Module; end
 172 
 173 
 174 
 175  class Class < Module; end
 176 
 177 
 178 
 179  class UnknownClass < Class; end
 180 
 181 
 182 
 183  class Constant < Abstraction::Module::Property
 184      attr_reader :value
 185 
 186 
 187      def initialize(
 188          name,
 189          a_link_to_line,
 190          a_link_to_file,
 191          uniq_num,
 192          max_uniq_num,
 193          value
 194      )
 195          ASSERT.kind_of  name,           String
 196          ASSERT.kind_of  a_link_to_line, MDL::Line
 197          ASSERT.kind_of  a_link_to_file, MDL::File
 198          ASSERT.kind_of  uniq_num,       Integer
 199          ASSERT.kind_of  max_uniq_num,   Integer
 200          ASSERT.kind_of  value,          String
 201 
 202          super(
 203              name, a_link_to_line, a_link_to_file, uniq_num, max_uniq_num
 204          )
 205 
 206          @value = value
 207      end
 208  end
 209 
 210 
 211 
 212  class Alias < Abstraction::Module::Property
 213      attr_reader :orig_name
 214 
 215 
 216      def initialize(
 217          name,
 218          a_link_to_line,
 219          a_link_to_file,
 220          uniq_num,
 221          max_uniq_num,
 222          orig_name
 223      )
 224          ASSERT.kind_of  name,           String
 225          ASSERT.kind_of  a_link_to_line, MDL::Line
 226          ASSERT.kind_of  a_link_to_file, MDL::File
 227          ASSERT.kind_of  uniq_num,       Integer
 228          ASSERT.kind_of  max_uniq_num,   Integer
 229          ASSERT.kind_of  orig_name,      String
 230 
 231          super(name, a_link_to_line, a_link_to_file, uniq_num, max_uniq_num)
 232 
 233          @orig_name = orig_name
 234      end
 235  end
 236 
 237 
 238 
 239  class Attribute < Abstraction::Module::Property
 240      attr_reader :accessor
 241 
 242 
 243      def initialize(
 244          name,
 245          a_link_to_line,
 246          a_link_to_file,
 247          uniq_num,
 248          max_uniq_num,
 249          accessor
 250      )
 251          ASSERT.kind_of  name,           String
 252          ASSERT.kind_of  a_link_to_line, MDL::Line
 253          ASSERT.kind_of  a_link_to_file, MDL::File
 254          ASSERT.kind_of  uniq_num,       Integer
 255          ASSERT.kind_of  max_uniq_num,   Integer
 256          ASSERT.kind_of  accessor,       String
 257 
 258          super(name, a_link_to_line, a_link_to_file, uniq_num, max_uniq_num)
 259 
 260          @accessor = accessor
 261      end
 262  end
 263 
 264 
 265 
 266  class Method < Abstraction::Module::Property
 267      attr_reader :args
 268 
 269 
 270      def initialize(
 271          name,
 272          a_link_to_line,
 273          a_link_to_file,
 274          uniq_num,
 275          max_uniq_num,
 276          args
 277      )
 278          ASSERT.kind_of  name,           String
 279          ASSERT.kind_of  a_link_to_line, MDL::Line
 280          ASSERT.kind_of  a_link_to_file, MDL::File
 281          ASSERT.kind_of  uniq_num,       Integer
 282          ASSERT.kind_of  max_uniq_num,   Integer
 283          ASSERT.kind_of  args,           LSM::SeqOfString
 284 
 285          super(
 286              name, a_link_to_line, a_link_to_file, uniq_num, max_uniq_num
 287          )
 288 
 289          @args = args
 290      end
 291  end
 292 
 293  end # TmDoc::Model::Document::Module
 294 
 295  end # TmDoc::Model::Document
 296 
 297  end # TmDoc