better documentation

This commit is contained in:
Torsten Ruger
2015-10-07 12:24:02 +03:00
parent ed5b946a70
commit e48b7f5c7a
7 changed files with 114 additions and 19 deletions

View File

@ -1,12 +1,17 @@
require_relative "element_view"
# A very simple ElementView with constant text and class. It uses the ElementView.div function
# to generate the html, see there for details
#
class ConstantView < ElementView
# store the class and text
def initialize class_or_id , text = nil
@class_or_id = class_or_id
@text = text
end
# use ElementView.div to create html from the class and text
def draw
@element = div(@class_or_id , @text)
end

View File

@ -1,3 +1,12 @@
# The basic idea is somewhat that of a shadow dom.
#
# ElementView wraps a single div with whatever content you want (derive to implement the view)
#
# It must have an element, which is drawn. Draw returns the div or whatever. An ElementView
# does not draw itself, but rather is drawn.
#
# Listviews provide structure
#
class ElementView
def initialize

View File

@ -1,5 +1,14 @@
require_relative "element_view"
# Listviews hold an array of elements and are responsible for drawing (and re-drawing them)
#
# A ListView hold the elements, but also the drawn html divs. You can change the element
# structure by adding/removing/replacing and the ListView will take care of redrawing the html
#
# A ListView is itself an ElementView so one can build recursive structures.
#
# Also one can easily change the root html element, or by deriving wrap or edit the resulting html
#
class ListView < ElementView
def initialize children

View File

@ -1,8 +1,59 @@
include AST::Sexp
CODE = s(:expressions,
CODE =
s(:expressions,
s(:class, :Integer,
s(:derives, :Object),
s(:expressions,
s(:function, :ref,
s(:name, :digit),
s(:parameters,
s(:parameter, :int, :rest)),
s(:expressions,
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 5))),
s(:if_true,
s(:return,
s(:string, "5"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 1))),
s(:if_true,
s(:return,
s(:string, "1"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 2))),
s(:if_true,
s(:return,
s(:string, "2"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 3))),
s(:if_true,
s(:return,
s(:string, "3"))),
s(:if_false, nil)),
s(:if,
s(:condition,
s(:operator, "==",
s(:name, :rest),
s(:int, 4))),
s(:if_true,
s(:return,
s(:string, "4"))),
s(:if_false, nil)))),
s(:function, :ref,
s(:name, :add_string),
s(:parameters,
@ -55,4 +106,16 @@ CODE = s(:expressions,
s(:call,
s(:name, :add_string),
s(:arguments,
s(:name, :start)))))))))
s(:name, :start)))))))),
s(:class, :Object,
s(:derives, nil),
s(:expressions,
s(:function, :int,
s(:name, :main),
s(:parameters),
s(:expressions,
s(:call,
s(:name, :to_string),
s(:arguments),
s(:receiver,
s(:int, 5))))))))

View File

@ -9,7 +9,9 @@ require "salama"
require "salama-reader"
require "ast"
require "interpreter/interpreter"
# the base, our own litle framework, allows for child and parent views and handles updates
require "base/list_view"
# each seperate view is in it's own class.
require_relative "classes_view"
require_relative "status_view"
require_relative "file_view"