From dave at badgers-in-foil.co.uk Fri Jul 1 20:58:58 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 01 Jul 2005 20:58:58 +0000 Subject: [as2api-dev] [CVS trunk] Make use of link_method() in more places that were doing it 'by hand'. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+12-11164 -> 165
Make use of link_method() in more places that were doing it 'by hand'.

link_for_method() can now automatically generate internal links, by inspecting
the type the current page documents (if any).

trunk/as2api
html_output.rb 164 -> 165
--- trunk/as2api/html_output.rb	2005-06-29 23:11:43 UTC (rev 164)
+++ trunk/as2api/html_output.rb	2005-07-01 20:58:56 UTC (rev 165)
@@ -268,7 +268,11 @@
 
 
   def link_for_method(method)
-    return "#{link_for_type(method.containing_type)}#method_#{method.name}"
+    if @type == method.containing_type
+      "#method_#{method.name}"
+    else
+      "#{link_for_type(method.containing_type)}#method_#{method.name}"
+    end
   end
 
   def link_method(method)
@@ -290,6 +294,11 @@
 end
 
 class BasicPage < Page
+  def initialize(base_name, path_name=nil)
+    super(base_name, path_name)
+    @type = nil
+  end
+
   def generate_content
     html_body do
       # accessability; make a link to skip over the initial navigation elements
@@ -437,9 +446,7 @@
 	html_p do
 	  html_code do
 	    pcdata("new ")
-	      html_a("href"=>"#method_#{type.constructor.name}") do
-		pcdata(type.constructor.name+"()")
-	      end
+	    link_method(type.constructor)
 	  end
 	end
       end
@@ -469,13 +476,7 @@
     methods.each_with_index do |method, index|
       known_method_names << method.name
       pcdata(", ") if index > 0
-      if type.document?
-	html_a("href"=>"#{href_prefix}#method_#{method.name}") do
-	  pcdata(method.name+"()")
-	end
-      else
-	pcdata(method.name+"()")
-      end
+      link_method(method)
     end
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Fri Jul 1 21:03:25 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 01 Jul 2005 21:03:25 +0000 Subject: [as2api-dev] [CVS trunk] Add title attributes to HTML arround method names, giving the method's signature Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+32-3165 -> 166
Add title attributes to HTML arround method names, giving the method's signature

This text will then appear when the mouse hovers over the method name, in many
browsers.

trunk/as2api
html_output.rb 165 -> 166
--- trunk/as2api/html_output.rb	2005-07-01 20:58:56 UTC (rev 165)
+++ trunk/as2api/html_output.rb	2005-07-01 21:03:24 UTC (rev 166)
@@ -266,6 +266,32 @@
     end
   end
 
+  def signature_for_method(method)
+    sig = ""
+    if method.access.is_static
+      sig << "static "
+    end
+    unless method.access.visibility.nil?
+      sig << "#{method.access.visibility.body} "
+    end
+    sig << "function "
+    sig << method.name
+    sig << "("
+    method.arguments.each_with_index do |arg, index|
+      sig << ", " if index > 0
+      sig << arg.name
+      if arg.arg_type
+	sig << ":"
+	sig << arg.arg_type.name
+      end
+    end
+    sig << ")"
+    if method.return_type
+      sig << ":"
+      sig << method.return_type.name
+    end
+    sig
+  end
 
   def link_for_method(method)
     if @type == method.containing_type
@@ -276,14 +302,17 @@
   end
 
   def link_method(method)
+    sig = signature_for_method(method)
     if method.containing_type.document?
-      html_a("href"=>link_for_method(method)) do
+      html_a("href"=>link_for_method(method), "title"=>sig) do
 	pcdata(method.name)
 	pcdata("()")
       end
     else
-      pcdata(method.name)
-      pcdata("()")
+      html_span("title"=>sig) do
+	pcdata(method.name)
+	pcdata("()")
+      end
     end
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Fri Jul 1 22:45:50 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 01 Jul 2005 22:45:50 +0000 Subject: [as2api-dev] [CVS trunk] output_doccomment_initial_sentence() generates per-type text for package summary Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+84-63166 -> 167
output_doccomment_initial_sentence() generates per-type text for package summary

At the same time, a few methods needed to be hoisted from TypePage up to
BasicPage, so that PackageIndexPage can make use of them too

trunk/as2api
html_output.rb 166 -> 167
--- trunk/as2api/html_output.rb	2005-07-01 21:03:24 UTC (rev 166)
+++ trunk/as2api/html_output.rb	2005-07-01 22:45:47 UTC (rev 167)
@@ -266,6 +266,14 @@
     end
   end
 
+  def link_type_proxy(type_proxy, qualified=false)
+    if type_proxy.resolved?
+      link_type(type_proxy.resolved_type, qualified)
+    else
+      html_span(type_proxy.local_name, {"class"=>"unresolved_type_name"})
+    end
+  end
+
   def signature_for_method(method)
     sig = ""
     if method.access.is_static
@@ -349,6 +357,70 @@
       html_a("as2api", {"href"=>PROJECT_PAGE, "title"=>"ActionScript 2 API Documentation Generator"})
     end
   end
+
+  def output_doccomment_blocktag(block)
+    block.each_inline do |inline|
+      output_doccomment_inlinetag(inline)
+    end
+  end
+
+  def output_doccomment_inlinetag(inline)
+    if inline.is_a?(String)
+      passthrough(inline)  # allow HTML through unabused (though I wish it were
+                           # easy to require it be valid XHTML)
+    elsif inline.is_a?(LinkTag)
+      if inline.target && inline.member
+	if inline.target.resolved?
+	  href = link_for_type(inline.target.resolved_type)
+	  if inline.member =~ /\(/
+	    target = "#method_#{$`}"
+	  else
+	    target = "#field_#{inline.member}"
+	  end
+	  href << target
+	  html_a("href"=>href) do
+	    pcdata("#{inline.target.name}.#{inline.member}")
+	  end
+	else
+	  pcdata("#{inline.target.name}##{inline.member}")
+	end
+      elsif inline.target
+	link_type_proxy(inline.target)
+      else
+	if inline.member =~ /\(/
+	  target = "#method_#{$`}"
+	else
+	  target = "#field_#{inline.member}"
+	end
+	html_a("href"=>target) do
+	  pcdata(inline.member)
+	end
+      end
+    elsif inline.is_a?(CodeTag)
+      html_code do
+	pcdata(inline.text)
+      end
+    else
+      html_em(inline.inspect)
+    end
+  end
+
+  def output_doccomment_initial_sentence(block)
+    block.each_inline do |inline|
+      if inline.is_a?(String)
+	if inline =~ /[\.:]\s+[A-Z]/ ||
+	   inline =~ /[\.:]\s+\Z/ ||
+	   inline =~ /<\/?[Pp]\b/
+	  output_doccomment_inlinetag($`)
+	  return
+	else
+	  output_doccomment_inlinetag(inline)
+	end
+      else
+	output_doccomment_inlinetag(inline)
+      end
+    end
+  end
 end
 
 class TypePage < BasicPage
@@ -736,53 +808,6 @@
     return comment_has_method_additional_info?(comment_data) || !spec_method.nil?
   end
 
-  def output_doccomment_blocktag(block)
-    block.each_inline do |inline|
-      output_doccomment_inlinetag(inline)
-    end
-  end
-
-  def output_doccomment_inlinetag(inline)
-    if inline.is_a?(String)
-      passthrough(inline)  # allow HTML through unabused (though I wish it were
-                           # easy to require it be valid XHTML)
-    elsif inline.is_a?(LinkTag)
-      if inline.target && inline.member
-	if inline.target.resolved?
-	  href = link_for_type(inline.target.resolved_type)
-	  if inline.member =~ /\(/
-	    target = "#method_#{$`}"
-	  else
-	    target = "#field_#{inline.member}"
-	  end
-	  href << target
-	  html_a("href"=>href) do
-	    pcdata("#{inline.target.name}.#{inline.member}")
-	  end
-	else
-	  pcdata("#{inline.target.name}##{inline.member}")
-	end
-      elsif inline.target
-	link_type_proxy(inline.target)
-      else
-	if inline.member =~ /\(/
-	  target = "#method_#{$`}"
-	else
-	  target = "#field_#{inline.member}"
-	end
-	html_a("href"=>target) do
-	  pcdata(inline.member)
-	end
-      end
-    elsif inline.is_a?(CodeTag)
-      html_code do
-	pcdata(inline.text)
-      end
-    else
-      html_em(inline.inspect)
-    end
-  end
-
   def method_synopsis(method)
     html_code("class"=>"method_synopsis") do
       if method.access.is_static
@@ -865,15 +890,7 @@
     end
   end
 
-  def link_type_proxy(type_proxy, qualified=false)
-    if type_proxy.resolved?
-      link_type(type_proxy.resolved_type, qualified)
-    else
-      html_span(type_proxy.local_name, {"class"=>"unresolved_type_name"})
-    end
-  end
 
-
   # TODO: All these comment_*() methods obviously want to belong to some new
   #       class, as yet unwritten.
 
@@ -983,7 +1000,7 @@
 	interfaces.sort!
 	html_table("class"=>"summary_list", "summary"=>"") do
 	  html_tr do
-	    html_th("Interface Summary")
+	    html_th("Interface Summary", {"colspan"=>"2"})
 	  end
 	  interfaces.each do |type|
 	    html_tr do
@@ -991,9 +1008,11 @@
 	      html_td do
 		html_a(type.unqualified_name, {"href"=>type.unqualified_name+".html"})
 	      end
-	      #html_td do
-		# TODO: package description
-	      #end
+	      html_td do
+		if type.comment
+		  output_doccomment_initial_sentence(type.comment[0])
+		end
+	      end
 	    end
 	  end
 	end
@@ -1003,7 +1022,7 @@
 	classes.sort!
 	html_table("class"=>"summary_list", "summary"=>"") do
 	  html_tr do
-	    html_th("Class Summary")
+	    html_th("Class Summary", {"colspan", "2"})
 	  end
 	  classes.each do |type|
 	    html_tr do
@@ -1011,9 +1030,11 @@
 	      html_td do
 		html_a(type.unqualified_name, {"href"=>type.unqualified_name+".html"})
 	      end
-	      #html_td do
-		# TODO: package description
-	      #end
+	      html_td do
+		if type.comment
+		  output_doccomment_initial_sentence(type.comment[0])
+		end
+	      end
 	    end
 	  end
 	end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 11:38:16 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 11:38:16 +0000 Subject: [as2api-dev] [CVS trunk] Oops; each_implemented_interface() is not allowed for interfaces themselves Message-ID:
Commit in trunk/as2api on MAIN
api_model.rb+5-3167 -> 168
Oops; each_implemented_interface() is not allowed for interfaces themselves

trunk/as2api
api_model.rb 167 -> 168
--- trunk/as2api/api_model.rb	2005-07-01 22:45:47 UTC (rev 167)
+++ trunk/as2api/api_model.rb	2005-07-02 11:38:14 UTC (rev 168)
@@ -291,9 +291,11 @@
       as_method = as_class.get_method_called(name)
       return as_method unless as_method.nil? || as_method.comment.nil?
     end
-    containing_type.each_implemented_interface do |as_interface|
-      as_method = as_interface.get_method_called(name)
-      return as_method unless as_method.nil? || as_method.comment.nil?
+    if containing_type.is_a?(ASClass)
+      containing_type.each_implemented_interface do |as_interface|
+        as_method = as_interface.get_method_called(name)
+        return as_method unless as_method.nil? || as_method.comment.nil?
+      end
     end
   end
 end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 16:13:48 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 16:13:48 +0000 Subject: [as2api-dev] [CVS trunk] Define metadata s between generated pages. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+94-5168 -> 169
Define metadata <link>s between generated pages.
These are used as the basis of Mozilla'a 'Site Navigation Bar', among other
things.

trunk/as2api
html_output.rb 168 -> 169
--- trunk/as2api/html_output.rb	2005-07-02 11:38:14 UTC (rev 168)
+++ trunk/as2api/html_output.rb	2005-07-02 16:13:47 UTC (rev 169)
@@ -228,9 +228,7 @@
   def generate_head
     html_head do
       html_title(title) unless title.nil?
-      html_link("rel"=>"stylesheet",
-		       "type"=>"text/css",
-		       "href"=>base_path("style.css"))
+      generate_links
       html_meta("name"=>"generator", "content"=>PROJECT_PAGE)
       unless encoding.nil?
         html_meta("http-equiv"=>"Content-Type",
@@ -239,6 +237,29 @@
     end
   end
 
+  def generate_links
+    html_link("rel"=>"stylesheet",
+             "type"=>"text/css",
+	     "href"=>base_path("style.css"))
+    link_top do |title, href|
+      html_link("rel"=>"top", "title"=>title, "href"=>href)
+    end
+    link_up do |title, href|
+      html_link("rel"=>"up", "title"=>title, "href"=>href)
+    end
+    link_prev do |title, href|
+      html_link("rel"=>"prev", "title"=>title, "href"=>href)
+    end
+    link_next do |title, href|
+      html_link("rel"=>"next", "title"=>title, "href"=>href)
+    end
+  end
+
+  def link_top; end
+  def link_up; end
+  def link_prev; end
+  def link_next; end
+
   def link_for_type(type)
     base_path(type.qualified_name.gsub(/\./, "/")+".html")
   end
@@ -433,8 +454,12 @@
       @encoding = "utf-8"
     end
     @title = type.qualified_name
+    @prev_type = nil
+    @next_type = nil
   end
 
+  attr_accessor :prev_type, :next_type
+
   def generate_body_content
       if @type.instance_of?(ASClass)
 	html_h1("Class "+@type.qualified_name)
@@ -501,6 +526,28 @@
     end
   end
 
+  def link_top
+    yield "Overview", base_path("overview-summary.html")
+  end
+
+  def link_up
+    yield "Package #{@type.package_name}", "package-summary.html"
+  end
+
+  def link_prev
+    if @prev_type
+      kind = @prev_type.is_a?(ASInterface) ? "Interface" : "Class"
+      yield "#{kind} #{@prev_type.qualified_name}", link_for_type(@prev_type)
+    end
+  end
+
+  def link_next
+    if @next_type
+      kind = @next_type.is_a?(ASInterface) ? "Interface" : "Class"
+      yield "#{kind} #{@next_type.qualified_name}", link_for_type(@next_type)
+    end
+  end
+
   def field_index_list(type)
     html_div("class"=>"field_index") do
       html_h2("Field Index")
@@ -991,8 +1038,12 @@
     @package = package
     @title = "Package #{package_display_name_for(@package)} API Documentation"
     @conf = conf
+    @prev_package
+    @next_package
   end
 
+  attr_accessor :prev_package, :next_package
+
   def generate_body_content
       html_h1("Package "+package_display_name_for(@package))
       interfaces = @package.interfaces
@@ -1064,6 +1115,20 @@
     end
   end
 
+  def link_top
+    yield "Overview", base_path("overview-summary.html")
+  end
+  def link_prev
+    if @prev_package
+      yield "Package #{package_display_name_for(@prev_package)}", base_path(package_link_for(@prev_package, "package-summary.html"))
+    end
+  end
+  def link_next
+    if @next_package
+      yield "Package #{package_display_name_for(@next_package)}", base_path(package_link_for(@next_package, "package-summary.html"))
+    end
+  end
+
   def class_diagram
     dir = File.join(@conf.output_dir, path_name)
     if FileTest.exists?(File.join(dir, "package-classes.png"))
@@ -1513,6 +1578,9 @@
     end
   end
 
+  def link_top
+    yield "Overview", base_path("overview-summary.html")
+  end
 end
 
 def make_page_list(conf, type_agregator)
@@ -1524,15 +1592,36 @@
   list << AllTypesFramePage.new(type_agregator)
 
   # packages..
+  last_package = nil
+  last_pkg_index = nil
   type_agregator.each_package do |package|
-    list << PackageIndexPage.new(conf, package)
+    pkg_index = PackageIndexPage.new(conf, package)
+    list << pkg_index
     list << PackageFramePage.new(package)
+
+    if last_package
+      pkg_index.prev_package = last_package
+      last_pkg_index.next_package = package
+    end
+    last_package = package
+    last_pkg_index = pkg_index
   end
 
   # types..
+  last_type = nil
+  last_type_page = nil
   type_agregator.each_type do |type|
     if type.document?
-      list << TypePage.new(type)
+      type_page = TypePage.new(type)
+      list << type_page
+
+      if last_type
+	type_page.prev_type = last_type
+	last_type_page.next_type = type
+      end
+
+      last_type = type
+      last_type_page = type_page
     end
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 16:26:11 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 16:26:11 +0000 Subject: [as2api-dev] [CVS trunk] is more apt markup than in these cases Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+11-15169 -> 170
<caption> is more apt markup than <th> in these cases

trunk/as2api
html_output.rb 169 -> 170
--- trunk/as2api/html_output.rb	2005-07-02 16:13:47 UTC (rev 169)
+++ trunk/as2api/html_output.rb	2005-07-02 16:26:10 UTC (rev 170)
@@ -12,7 +12,7 @@
 
   write_file(output_dir, name) do |out|
     out.print <<-HERE
-h1, h2, h3, h4 th {
+h1, h2, h3, h4, caption {
 	font-family: sans-serif;
 }
 
@@ -76,14 +76,16 @@
 	width: 100%;
 	margin-bottom: 1em;
 }
-table.summary_list th {
-	background-color: #CCCCFF;
-	font-size: larger;
-}
-table.summary_list td, table.summary_list th {
+table.summary_list td, table.summary_list caption {
 	border: 2px solid grey;
 	padding: .2em;
 }
+table.summary_list caption {
+	background-color: #CCCCFF;
+	border-bottom: 0;
+	font-size: larger;
+	font-weight: bolder;
+}
 ul.navigation_list {
 	padding-left: 0;
 }
@@ -1050,9 +1052,7 @@
       unless interfaces.empty?
 	interfaces.sort!
 	html_table("class"=>"summary_list", "summary"=>"") do
-	  html_tr do
-	    html_th("Interface Summary", {"colspan"=>"2"})
-	  end
+	  html_caption("Interface Summary")
 	  interfaces.each do |type|
 	    html_tr do
 	
@@ -1072,9 +1072,7 @@
       unless classes.empty?
 	classes.sort!
 	html_table("class"=>"summary_list", "summary"=>"") do
-	  html_tr do
-	    html_th("Class Summary", {"colspan", "2"})
-	  end
+	  html_caption("Class Summary")
 	  classes.each do |type|
 	    html_tr do
 	
@@ -1316,9 +1314,7 @@
   def generate_body_content
       html_h1("API Overview")
       html_table("class"=>"summary_list", "summary"=>"") do
-	html_tr do
-	  html_th("Packages")
-	end
+	html_caption("Packages")
 	packages = @type_agregator.packages.sort
 	packages.each do |package|
 	  html_tr do
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 16:27:03 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 16:27:03 +0000 Subject: [as2api-dev] [CVS trunk] Oops; missing attribute initialisations Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+2-2170 -> 171
Oops; missing attribute initialisations

trunk/as2api
html_output.rb 170 -> 171
--- trunk/as2api/html_output.rb	2005-07-02 16:26:10 UTC (rev 170)
+++ trunk/as2api/html_output.rb	2005-07-02 16:27:00 UTC (rev 171)
@@ -1040,8 +1040,8 @@
     @package = package
     @title = "Package #{package_display_name_for(@package)} API Documentation"
     @conf = conf
-    @prev_package
-    @next_package
+    @prev_package = nil
+    @next_package = nil
   end
 
   attr_accessor :prev_package, :next_package
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 18:09:31 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 18:09:31 +0000 Subject: [as2api-dev] [CVS trunk] Fill in the 'package' attribute of each ASType Message-ID:
Commit in trunk/as2api on MAIN
api_loader.rb+1171 -> 172
Fill in the 'package' attribute of each ASType

trunk/as2api
api_loader.rb 171 -> 172
--- trunk/as2api/api_loader.rb	2005-07-02 16:27:00 UTC (rev 171)
+++ trunk/as2api/api_loader.rb	2005-07-02 18:09:28 UTC (rev 172)
@@ -393,6 +393,7 @@
       package = ASPackage.new(package_name)
       @packages[package_name] = package
     end
+    type.package = package
     package.add_type(type)
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 18:10:57 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 18:10:57 +0000 Subject: [as2api-dev] [CVS trunk] Factor a common text-generating pattern out into a new method Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+10-6172 -> 173
Factor a common text-generating pattern out into a new method

trunk/as2api
html_output.rb 172 -> 173
--- trunk/as2api/html_output.rb	2005-07-02 18:09:28 UTC (rev 172)
+++ trunk/as2api/html_output.rb	2005-07-02 18:10:57 UTC (rev 173)
@@ -533,7 +533,7 @@
   end
 
   def link_up
-    yield "Package #{@type.package_name}", "package-summary.html"
+    yield package_description_for(@type.package), "package-summary.html"
   end
 
   def link_prev
@@ -1025,6 +1025,10 @@
   package.name
 end
 
+def package_description_for(package)
+  "Package #{package_display_name_for(package)}"
+end
+
 def package_link_for(package, page)
   return page if package.name == ""
   package_dir_for(package) + "/" + page
@@ -1038,7 +1042,7 @@
     dir = package_dir_for(package)
     super("package-summary", dir)
     @package = package
-    @title = "Package #{package_display_name_for(@package)} API Documentation"
+    @title = "#{package_description_for(@package)} API Documentation"
     @conf = conf
     @prev_package = nil
     @next_package = nil
@@ -1047,7 +1051,7 @@
   attr_accessor :prev_package, :next_package
 
   def generate_body_content
-      html_h1("Package "+package_display_name_for(@package))
+      html_h1(package_description_for(@package))
       interfaces = @package.interfaces
       unless interfaces.empty?
 	interfaces.sort!
@@ -1118,12 +1122,12 @@
   end
   def link_prev
     if @prev_package
-      yield "Package #{package_display_name_for(@prev_package)}", base_path(package_link_for(@prev_package, "package-summary.html"))
+      yield package_description_for(@prev_package), base_path(package_link_for(@prev_package, "package-summary.html"))
     end
   end
   def link_next
     if @next_package
-      yield "Package #{package_display_name_for(@next_package)}", base_path(package_link_for(@next_package, "package-summary.html"))
+      yield package_description_for(@next_package), base_path(package_link_for(@next_package, "package-summary.html"))
     end
   end
 
@@ -1264,7 +1268,7 @@
     dir = package_dir_for(package)
     super("package-frame", dir)
     @package = package
-    @title = "Package #{package_display_name_for(@package)} API Naviation"
+    @title = "#{package_description_for(@package)} API Naviation"
     @doctype_id = :transitional
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 18:58:48 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 18:58:48 +0000 Subject: [as2api-dev] [CVS trunk] Another little refactoring of text-generating code; classes/interfaces this time Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+9-7173 -> 174
Another little refactoring of text-generating code; classes/interfaces this time

trunk/as2api
html_output.rb 173 -> 174
--- trunk/as2api/html_output.rb	2005-07-02 18:10:57 UTC (rev 173)
+++ trunk/as2api/html_output.rb	2005-07-02 18:58:47 UTC (rev 174)
@@ -267,12 +267,11 @@
   end
 
   def link_type(type, qualified=false, attrs={})
+    attrs["title"] = type_description_for(type)
     if type.instance_of?(ASInterface)
       attrs["class"] = "interface_name"
-      attrs["title"] = "Interface #{type.qualified_name}"
     elsif type.instance_of?(ASClass)
       attrs["class"] = "class_name"
-      attrs["title"] = "Class #{type.qualified_name}"
     elsif type == AS_VOID
       attrs["class"] = "void_name"
     end
@@ -463,11 +462,7 @@
   attr_accessor :prev_type, :next_type
 
   def generate_body_content
-      if @type.instance_of?(ASClass)
-	html_h1("Class "+@type.qualified_name)
-      elsif @type.instance_of?(ASInterface)
-	html_h1("Interface "+@type.qualified_name)
-      end
+      html_h1(type_description_for(@type))
 
       type_hierachy(@type)
 
@@ -1034,6 +1029,13 @@
   package_dir_for(package) + "/" + page
 end
 
+def type_description_for(as_type)
+  if as_type.instance_of?(ASClass)
+    "Class #{@type.qualified_name}"
+  elsif as_type.instance_of?(ASInterface)
+    "Interface #{@type.qualified_name}"
+  end
+end
 
 
 class PackageIndexPage < BasicPage
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 20:15:08 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 20:15:08 +0000 Subject: [as2api-dev] [CVS trunk] Add the same sort of common link-building code for fields as we have for methods Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+38-13174 -> 175
Add the same sort of common link-building code for fields as we have for methods
including title tags giving the field synopsis

trunk/as2api
html_output.rb 174 -> 175
--- trunk/as2api/html_output.rb	2005-07-02 18:58:47 UTC (rev 174)
+++ trunk/as2api/html_output.rb	2005-07-02 20:15:02 UTC (rev 175)
@@ -346,6 +346,42 @@
     end
   end
 
+  def signature_for_field(field)
+    sig = ""
+    if field.access.is_static
+      sig << "static "
+    end
+    unless field.access.visibility.nil?
+      sig << "#{field.access.visibility.body} "
+    end
+    sig << field.name
+    if field.field_type
+      sig << ":"
+      sig << field.field_type.name
+    end
+  end
+
+  def link_for_field(field)
+    if @type == field.containing_type
+      "#field_#{field.name}"
+    else
+      "#{link_for_type(field.containing_type)}#field_#{field.name}"
+    end
+  end
+
+  def link_field(field)
+    sig = signature_for_field(field)
+    if field.containing_type.document?
+      html_a("href"=>link_for_field(field), "title"=>sig) do
+	pcdata(field.name)
+      end
+    else
+      html_span("title"=>sig) do
+	pcdata(field.name)
+      end
+    end
+  end
+
   def base_path(file)
     return file if @path_name.nil?
     ((".."+File::SEPARATOR) * @path_name.split(File::SEPARATOR).length) + file
@@ -571,15 +607,7 @@
     fields.each do |field|
       next unless document_member?(field)
       pcdata(", ") if index > 0
-      html_code do
-	if type.document?
-	  html_a("href"=>"#{href_prefix}#field_#{field.name}") do
-	    pcdata(field.name)
-	  end
-	else
-	  pcdata(field.name)
-	end
-      end
+      link_field(field)
       index += 1
     end
   end
@@ -1513,10 +1541,7 @@
 
 class FieldIndexTerm < MemberIndexTerm
   def link(out)
-    href_prefix = out.link_for_type(@astype)
-    out.html_a("href"=>"#{href_prefix}#field_#{@asmember.name}") do
-      out.pcdata(@asmember.name)
-    end
+    out.link_field(@asmember)
     out.pcdata(" field in ")
     out.link_type(@astype, true)
   end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 20:16:13 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 20:16:13 +0000 Subject: [as2api-dev] [CVS trunk] Forgot to fix these variable names after moving code around Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+2-2175 -> 176
Forgot to fix these variable names after moving code around

trunk/as2api
html_output.rb 175 -> 176
--- trunk/as2api/html_output.rb	2005-07-02 20:15:02 UTC (rev 175)
+++ trunk/as2api/html_output.rb	2005-07-02 20:16:11 UTC (rev 176)
@@ -1059,9 +1059,9 @@
 
 def type_description_for(as_type)
   if as_type.instance_of?(ASClass)
-    "Class #{@type.qualified_name}"
+    "Class #{as_type.qualified_name}"
   elsif as_type.instance_of?(ASInterface)
-    "Interface #{@type.qualified_name}"
+    "Interface #{as_type.qualified_name}"
   end
 end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 20:47:51 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 20:47:51 +0000 Subject: [as2api-dev] [CVS trunk] Help for debugging nils in attributes Message-ID:
Commit in trunk/as2api on MAIN
xmlwriter.rb+1176 -> 177
Help for debugging nils in attributes

trunk/as2api
xmlwriter.rb 176 -> 177
--- trunk/as2api/xmlwriter.rb	2005-07-02 20:16:11 UTC (rev 176)
+++ trunk/as2api/xmlwriter.rb	2005-07-02 20:47:50 UTC (rev 177)
@@ -25,6 +25,7 @@
     @io.print(text)
     unless attrs.nil?
       attrs.each do |key, val|
+      	raise "#{key.inspect}=#{val.inspect}" if key.nil? || val.nil?
 	@io.print(' ')
 	@io.print(key)
 	@io.print('="')
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 20:49:22 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 20:49:22 +0000 Subject: [as2api-dev] [CVS trunk] Don't set title=nil for types we can't describe, and always return the sig Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+3-1177 -> 178
Don't set title=nil for types we can't describe, and always return the sig
from signature_for_field()

trunk/as2api
html_output.rb 177 -> 178
--- trunk/as2api/html_output.rb	2005-07-02 20:47:50 UTC (rev 177)
+++ trunk/as2api/html_output.rb	2005-07-02 20:49:21 UTC (rev 178)
@@ -267,7 +267,8 @@
   end
 
   def link_type(type, qualified=false, attrs={})
-    attrs["title"] = type_description_for(type)
+    desc = type_description_for(type)
+    attrs["title"] = desc unless desc.nil?
     if type.instance_of?(ASInterface)
       attrs["class"] = "interface_name"
     elsif type.instance_of?(ASClass)
@@ -359,6 +360,7 @@
       sig << ":"
       sig << field.field_type.name
     end
+    sig
   end
 
   def link_for_field(field)
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 23:18:49 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 23:18:49 +0000 Subject: [as2api-dev] [CVS trunk] Use StringScanner to simplify the guts of the lexer ever-so-slightly Message-ID:
Commit in trunk/as2api/parse on MAIN
lexer.rb+10-13178 -> 179
Use StringScanner to simplify the guts of the lexer ever-so-slightly

trunk/as2api/parse
lexer.rb 178 -> 179
--- trunk/as2api/parse/lexer.rb	2005-07-02 20:49:21 UTC (rev 178)
+++ trunk/as2api/parse/lexer.rb	2005-07-02 23:18:48 UTC (rev 179)
@@ -1,4 +1,6 @@
 
+require 'strscan'
+
 module ActionScript
 module Parse
 
@@ -245,7 +247,7 @@
   private
 
   def ASLexer.make_match(match)
-    Regexp.new("\\A#{match}")
+    Regexp.new(match)
   end
 
   h =		"[0-9a-fA-F]"
@@ -288,7 +290,6 @@
 
     add_match(match) do |lex, match, io|
       lex.emit(ActionScript::Parse.const_get(class_name).new(io.lineno))
-      match.post_match
     end
   end
 
@@ -300,12 +301,10 @@
     # TODO: whitespace tokens don't span lines, which might not be the expected
     #       behaviour
     lex.emit(WhitespaceToken.new(match[0], io.lineno))
-    match.post_match
   end
 
   add_match(SINGLE_LINE_COMMENT) do |lex, match, io|
     lex.emit(SingleLineCommentToken.new(match[1], io.lineno))
-    match.post_match
   end
 
   add_match(OMULTI_LINE_COMMENT) do |lex, match, io|
@@ -318,7 +317,7 @@
     end
     comment << $`
     lex.emit(MultiLineCommentToken.new(comment, lineno))
-    $'
+    match.string = $'
   end
 
   Keywords.each do |keyword|
@@ -335,7 +334,6 @@
 
   add_match(ident) do |lex, match, io|
     lex.emit(IdentifierToken.new(match[0], io.lineno))
-    match.post_match
   end
 
   add_match(STRING_START1) do |lex, match, io|
@@ -348,7 +346,7 @@
     end
     str << $1
     lex.emit(StringToken.new(str, lineno))
-    $'
+    match.string = $'
   end
 
   add_match(STRING_START2) do |lex, match, io|
@@ -361,12 +359,11 @@
     end
     str << $1
     lex.emit(StringToken.new(str, lineno))
-    $'
+    match.string = $'
   end
 
   add_match(num) do |lex, match, io|
     lex.emit(NumberToken.new(match[0], io.lineno))
-    match.post_match
   end
 
   def check_fill
@@ -376,14 +373,14 @@
   end
 
   def fill
-    line = @io.readline
-    while line.size>0
+    line = StringScanner.new(@io.readline)
+    until line.eos?
       matched = false
       @@matches.each do |token_match|
 	re, action = token_match
-	match = re.match(line)
+	match = line.scan(re)
 	if match
-	  line = action.call(self, match, @io)
+	  action.call(self, line, @io)
 	  matched = true
 	  break
 	end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 2 23:52:09 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 02 Jul 2005 23:52:09 +0000 Subject: [as2api-dev] [CVS trunk] After some profilling, it seems like ASLexer#fill might be the major bottleneck. Message-ID:
Commit in trunk/as2api/parse on MAIN
lexer.rb+18-17179 -> 180
After some profilling, it seems like ASLexer#fill might be the major bottleneck.

This change unrolls the fill() methods inner @@matches.each loop, but keeps
the code fairly tight still, by generating the fill() method using class_eval()

This naive change cuts about 30% off the runtime of the example I've been
testing with (was ~40secs, now ~27secs).

The lexer code could still use a lot of cleaning up.

trunk/as2api/parse
lexer.rb 179 -> 180
--- trunk/as2api/parse/lexer.rb	2005-07-02 23:18:48 UTC (rev 179)
+++ trunk/as2api/parse/lexer.rb	2005-07-02 23:52:07 UTC (rev 180)
@@ -247,7 +247,7 @@
   private
 
   def ASLexer.make_match(match)
-    Regexp.new(match)
+    match.gsub("/", "\\/").gsub("\n", "\\n")
   end
 
   h =		"[0-9a-fA-F]"
@@ -372,25 +372,26 @@
     end
   end
 
-  def fill
-    line = StringScanner.new(@io.readline)
-    until line.eos?
-      matched = false
-      @@matches.each do |token_match|
-	re, action = token_match
-	match = line.scan(re)
-	if match
-	  action.call(self, line, @io)
-	  matched = true
-	  break
-	end
-      end
-      unless matched
-        parse_error(line)
-      end
+  def self.build_lexer
+    text = <<-EOS
+      def fill
+        line = StringScanner.new(@io.readline)
+        until line.eos?
+    EOS
+    @@matches.each_with_index do |token_match, index|
+      re, action = token_match
+      text << "if line.scan(/#{re}/)\n"
+      text << "  @@matches[#{index}][1].call(self, line, @io)\n"
+      text << "  next\n"
+      text << "end\n"
     end
+    text << "        end\n      end\n"
+    puts text
+    class_eval(text)
   end
 
+  self.build_lexer
+
   public
   def emit(token)
     @tokens << token
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 3 19:20:43 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 03 Jul 2005 19:20:43 +0000 Subject: [as2api-dev] [CVS trunk] Remove debug output Message-ID:
Commit in trunk/as2api/parse on MAIN
lexer.rb-1180 -> 181
Remove debug output

trunk/as2api/parse
lexer.rb 180 -> 181
--- trunk/as2api/parse/lexer.rb	2005-07-02 23:52:07 UTC (rev 180)
+++ trunk/as2api/parse/lexer.rb	2005-07-03 19:20:42 UTC (rev 181)
@@ -386,7 +386,6 @@
       text << "end\n"
     end
     text << "        end\n      end\n"
-    puts text
     class_eval(text)
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 3 20:11:52 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 03 Jul 2005 20:11:52 +0000 Subject: [as2api-dev] [CVS trunk] Simplify unit test code by making a better piece of framework Message-ID:
Commit in trunk/as2api on MAIN
tc_actionscript_lexer.rb+26-60181 -> 182
Simplify unit test code by making a better piece of framework

trunk/as2api
tc_actionscript_lexer.rb 181 -> 182
--- trunk/as2api/tc_actionscript_lexer.rb	2005-07-03 19:20:42 UTC (rev 181)
+++ trunk/as2api/tc_actionscript_lexer.rb	2005-07-03 20:11:50 UTC (rev 182)
@@ -6,81 +6,36 @@
   include ActionScript::Parse
 
   def test_simple_string
-    simple_lex("'test'") do |tok|
-      assert_instance_of(StringToken, tok)
-      assert_equal("test", tok.body)
-    end
-    simple_lex("\"test\"") do |tok|
-      assert_instance_of(StringToken, tok)
-      assert_equal("test", tok.body)
-    end
-    simple_lex("\"'\"") do |tok|
-      assert_instance_of(StringToken, tok)
-      assert_equal("'", tok.body)
-    end
-    simple_lex('"\\"\"') do |tok|
-      assert_instance_of(StringToken, tok)
-      assert_equal('"', tok.body)
-    end
+    assert_lex_to("'test'", StringToken.new("test", 1))
+    assert_lex_to("\"test\"", StringToken.new("test", 1))
+    assert_lex_to("\"'\"", StringToken.new("'", 1))
+    assert_lex_to('"\\"\"', StringToken.new('"', 1))
   end
 
   def test_identfier
-    simple_lex("foo") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("foo", tok.body)
-    end
+    assert_lex_to("foo", IdentifierToken.new("foo", 1))
     # check keyword at start of identifier doesn't confuse lexer
-    simple_lex("getfoo") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("getfoo", tok.body)
-    end
-    simple_lex("BAR") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("BAR", tok.body)
-    end
+    assert_lex_to("getfoo", IdentifierToken.new("getfoo", 1))
+    assert_lex_to("BAR", IdentifierToken.new("BAR", 1))
     # 'dollar' and underscore are allowed
-    simple_lex("$foo") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("$foo", tok.body)
-    end
-    simple_lex("bar$") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("bar$", tok.body)
-    end
-    simple_lex("_x") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("_x", tok.body)
-    end
-    simple_lex("z_") do |tok|
-      assert_instance_of(IdentifierToken, tok)
-      assert_equal("z_", tok.body)
-    end
+    assert_lex_to("$foo", IdentifierToken.new("$foo", 1))
+    assert_lex_to("bar$", IdentifierToken.new("bar$", 1))
+    assert_lex_to("_x", IdentifierToken.new("_x", 1))
+    assert_lex_to("z_", IdentifierToken.new("z_", 1))
   end
 
   def test_number
-    simple_lex("1") do |tok|
-      assert_instance_of(NumberToken, tok)
-      assert_equal("1", tok.body)
-    end
+    assert_lex_to("1", NumberToken.new("1", 1))
   end
 
   def test_single_line_comment
-    simple_lex("// foo ") do |tok|
-      assert_instance_of(SingleLineCommentToken, tok)
-      assert_equal(" foo ", tok.body)
-    end
+    assert_lex_to("// foo ", SingleLineCommentToken.new(" foo ", 1))
     # 'single line' comments shouldn't eat the whole body of a Mac-format file
-    simple_lex("//foo\r") do |tok|
-      assert_instance_of(SingleLineCommentToken, tok)
-      assert_equal("foo", tok.body)
-    end
+    assert_lex_to("//foo\r", SingleLineCommentToken.new("foo", 1))
   end
 
   def test_multiline_comment
-    simple_lex("/* hide!/* */") do |tok|
-      assert_instance_of(MultiLineCommentToken, tok)
-      assert_equal(" hide!/* ", tok.body)
-    end
+    assert_lex_to("/* hide!/* */", MultiLineCommentToken.new(" hide!/* ", 1))
   end
 
   def test_comma; assert_simple_token(",", CommaToken) end
@@ -118,6 +73,17 @@
     assert_nil(lex.get_next)
   end
 
+  def assert_lex_to(text, *tokens)
+    input = StrIO.new(text)
+    lex = ASLexer.new(input)
+    tokens.each do |expected|
+      tok = lex.get_next
+      assert_equal(expected.class, tok.class)
+      assert_equal(expected.body, tok.body)
+    end
+    assert_nil(lex.get_next)
+  end
+
   def assert_simple_token(text, token)
     simple_lex(text) do |tok|
       assert_instance_of(token, tok)
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 3 20:17:46 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 03 Jul 2005 20:17:46 +0000 Subject: [as2api-dev] [CVS trunk] Don't let a SingleLineCommentToken eat its terminating end-of-line sequence. Message-ID:
Commit in trunk/as2api on MAIN
parse/lexer.rb+1-1182 -> 183
tc_actionscript_lexer.rb+2-1182 -> 183
+3-2
2 modified files
Don't let a SingleLineCommentToken eat its terminating end-of-line sequence.
This will now appear as an additional WhiteSpaceToken.

Applications that care about whitespace will need this.

trunk/as2api/parse
lexer.rb 182 -> 183
--- trunk/as2api/parse/lexer.rb	2005-07-03 20:11:50 UTC (rev 182)
+++ trunk/as2api/parse/lexer.rb	2005-07-03 20:17:44 UTC (rev 183)
@@ -257,7 +257,7 @@
   escape =	"(?:#{unicode}|\\\\[ -~\\200-\\377])"
   nmstart =	"(?:[a-zA-Z_$]|#{nonascii}|#{escape})"
   nmchar =	"(?:[a-zA-Z0-9_$]|#{nonascii}|#{escape})"
-  SINGLE_LINE_COMMENT = "//([^\n\r]*)(?:\r\n|\r|\n)?"
+  SINGLE_LINE_COMMENT = "//([^\n\r]*)"
   OMULTI_LINE_COMMENT = "/\\*"
   CMULTI_LINE_COMMENT = "\\*/"
   STRING_START1 = "'"

trunk/as2api
tc_actionscript_lexer.rb 182 -> 183
--- trunk/as2api/tc_actionscript_lexer.rb	2005-07-03 20:11:50 UTC (rev 182)
+++ trunk/as2api/tc_actionscript_lexer.rb	2005-07-03 20:17:44 UTC (rev 183)
@@ -31,7 +31,8 @@
   def test_single_line_comment
     assert_lex_to("// foo ", SingleLineCommentToken.new(" foo ", 1))
     # 'single line' comments shouldn't eat the whole body of a Mac-format file
-    assert_lex_to("//foo\r", SingleLineCommentToken.new("foo", 1))
+    assert_lex_to("//foo\r", SingleLineCommentToken.new("foo", 1),
+                             WhitespaceToken.new("\r", 1))
   end
 
   def test_multiline_comment
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 4 00:20:57 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 04 Jul 2005 00:20:57 +0000 Subject: [as2api-dev] [CVS trunk] New --sources option adds syntax-highlighted source code to the documentation Message-ID:
Commit in trunk/as2api on MAIN
api_loader.rb+1-2183 -> 184
api_model.rb+13-2183 -> 184
html_output.rb+221-12183 -> 184
ui/cli.rb+9-4183 -> 184
+244-20
4 modified files
New --sources option adds syntax-highlighted source code to the documentation

trunk/as2api
api_loader.rb 183 -> 184
--- trunk/as2api/api_loader.rb	2005-07-03 20:17:44 UTC (rev 183)
+++ trunk/as2api/api_loader.rb	2005-07-04 00:20:55 UTC (rev 184)
@@ -25,8 +25,7 @@
     begin
       is_utf8 = detect_bom?(io)
       type = simple_parse(io)
-      type.input_filename = file.suffix
-      type.sourcepath_location(File.dirname(file.suffix))
+      type.input_file = file
       type.source_utf8 = is_utf8
       return type
     rescue =>e

trunk/as2api
api_model.rb 183 -> 184
--- trunk/as2api/api_model.rb	2005-07-03 20:17:44 UTC (rev 183)
+++ trunk/as2api/api_model.rb	2005-07-04 00:20:55 UTC (rev 184)
@@ -25,12 +25,23 @@
     @comment = nil
     @type_resolver = nil
     @import_manager = nil
-    @input_filename = nil
+    @input_file = nil
     @document = true
   end
 
-  attr_accessor :package, :extends, :comment, :source_utf8, :type_resolver, :import_manager, :input_filename, :intrinsic, :constructor
+  attr_accessor :package, :extends, :comment, :source_utf8, :type_resolver, :import_manager, :intrinsic, :constructor
 
+  def input_filename
+    @input_file.suffix
+  end
+
+  def input_file=(file)
+    @input_file = file
+    sourcepath_location = file
+  end
+
+  attr_reader :input_file
+
   def add_method(method)
     @methods << method
   end

trunk/as2api
html_output.rb 183 -> 184
--- trunk/as2api/html_output.rb	2005-07-03 20:17:44 UTC (rev 183)
+++ trunk/as2api/html_output.rb	2005-07-04 00:20:55 UTC (rev 184)
@@ -121,6 +121,20 @@
 .diagram {
 	text-align: center;
 }
+
+
+/* Source highlighting rules */
+
+.lineno {
+  color: gray;
+  background-color:lightgray;
+  border-right: 1px solid gray;
+  margin-right: .5em;
+}
+.comment { color: green; }
+.comment.doc { color: 4466ff; }
+.str_const, .num_const { color: blue; }
+.key { font-weight: bolder; color: purple; }
     HERE
   end
 end
@@ -391,8 +405,9 @@
 end
 
 class BasicPage < Page
-  def initialize(base_name, path_name=nil)
+  def initialize(conf, base_name, path_name=nil)
     super(base_name, path_name)
+    @conf = conf
     @type = nil
   end
 
@@ -485,9 +500,9 @@
 
 class TypePage < BasicPage
 
-  def initialize(type)
+  def initialize(conf, type)
     dir = type.package_name.gsub(/\./, "/")
-    super(type.unqualified_name, dir)
+    super(conf, type.unqualified_name, dir)
     @type = type
     if @type.source_utf8
       @encoding = "utf-8"
@@ -555,6 +570,11 @@
       html_li do
 	html_span("Class", {"class"=>"nav_current"})
       end
+      if @conf.sources
+	html_li do
+	  html_a("Source", {"href"=>@type.unqualified_name+".as.html"})
+	end
+      end
       html_li do
 	html_a("Index", {"href"=>base_path("index-files/index.html")})
       end
@@ -1072,10 +1092,9 @@
 
   def initialize(conf, package)
     dir = package_dir_for(package)
-    super("package-summary", dir)
+    super(conf, "package-summary", dir)
     @package = package
     @title = "#{package_description_for(@package)} API Documentation"
-    @conf = conf
     @prev_package = nil
     @next_package = nil
   end
@@ -1143,6 +1162,11 @@
       html_li do
 	html_span("Class")
       end
+      if @conf.sources
+	html_li do
+	  html_span("Source")
+	end
+      end
       html_li do
 	html_a("Index", {"href"=>base_path("index-files/index.html")})
       end
@@ -1341,8 +1365,8 @@
 end
 
 class OverviewPage < BasicPage
-  def initialize(type_agregator)
-    super("overview-summary")
+  def initialize(conf, type_agregator)
+    super(conf, "overview-summary")
     @type_agregator = type_agregator
     @title = "API Overview"
   end
@@ -1378,6 +1402,11 @@
       html_li do
 	html_span("Class")
       end
+      if @conf.sources
+	html_li do
+	  html_span("Source")
+	end
+      end
       html_li do
 	html_a("Index", {"href"=>"index-files/index.html"})
       end
@@ -1550,8 +1579,8 @@
 end
 
 class IndexPage < BasicPage
-  def initialize(type_agregator)
-    super("index", "index-files")
+  def initialize(conf, type_agregator)
+    super(conf, "index", "index-files")
     @type_agregator = type_agregator
     @title = "Alphabetical Index"
   end
@@ -1601,6 +1630,11 @@
       html_li do
 	html_span("Class")
       end
+      if @conf.sources
+	html_li do
+	  html_span("Source")
+	end
+      end
       html_li do
 	html_span("Index", {"class"=>"nav_current"})
       end
@@ -1612,11 +1646,185 @@
   end
 end
 
+
+class SourcePage < BasicPage
+
+  def initialize(conf, type)
+    dir = type.package_name.gsub(/\./, "/")
+    super(conf, type.unqualified_name+".as", dir)
+    @type = type
+  end
+
+  def generate_body_content
+    html_pre do
+      file = @type.input_file
+      parse(File.join(file.prefix, file.suffix))
+    end
+  end
+
+  def parse(file)
+    File.open(File.join(file)) do |io|
+      begin
+	is_utf8 = detect_bom?(io)
+	as_io = ASIO.new(io)
+	lex = ActionScript::Parse::SkipASLexer.new(HighlightASLexer.new(self, as_io))
+	parse = HighlightASParser.new(lex)
+	parse.handler = ActionScript::Parse::ASHandler.new
+	parse.parse_compilation_unit
+      rescue =>e
+	$stderr.puts "#{file}: #{e.message}\n#{e.backtrace.join("\n")}"
+      end
+    end
+  end
+
+  class HighlightASParser < ActionScript::Parse::ASParser
+
+  end
+
+  Keywords = [
+    ActionScript::Parse::AsToken,
+    ActionScript::Parse::BreakToken,
+    ActionScript::Parse::CaseToken,
+    ActionScript::Parse::CatchToken,
+    ActionScript::Parse::ClassToken,
+    ActionScript::Parse::ConstToken,
+    ActionScript::Parse::ContinueToken,
+    ActionScript::Parse::DefaultToken,
+    ActionScript::Parse::DynamicToken,
+    ActionScript::Parse::DeleteToken,
+    ActionScript::Parse::DoToken,
+    ActionScript::Parse::ElseToken,
+    ActionScript::Parse::ExtendsToken,
+    ActionScript::Parse::FalseToken,
+    ActionScript::Parse::FinallyToken,
+    ActionScript::Parse::ForToken,
+    ActionScript::Parse::FunctionToken,
+    ActionScript::Parse::IfToken,
+    ActionScript::Parse::ImplementsToken,
+    ActionScript::Parse::ImportToken,
+    ActionScript::Parse::InToken,
+    ActionScript::Parse::InstanceofToken,
+    ActionScript::Parse::InterfaceToken,
+    ActionScript::Parse::IntrinsicToken,
+    ActionScript::Parse::NewToken,
+    ActionScript::Parse::NullToken,
+    ActionScript::Parse::PackageToken,
+    ActionScript::Parse::PrivateToken,
+    ActionScript::Parse::PublicToken,
+    ActionScript::Parse::ReturnToken,
+    ActionScript::Parse::StaticToken,
+    ActionScript::Parse::SuperToken,
+    ActionScript::Parse::SwitchToken,
+    ActionScript::Parse::ThisToken,
+    ActionScript::Parse::ThrowToken,
+    ActionScript::Parse::TrueToken,
+    ActionScript::Parse::TryToken,
+    ActionScript::Parse::TypeofToken,
+    ActionScript::Parse::UseToken,
+    ActionScript::Parse::VarToken,
+    ActionScript::Parse::VoidToken,
+    ActionScript::Parse::WhileToken,
+    ActionScript::Parse::WithToken
+  ]
+
+  class HighlightASLexer < ActionScript::Parse::ASLexer
+    def initialize(out, io)
+      super(io)
+      @lineno = 0
+      @out = out
+    end
+
+    def get_next
+      tok = super
+      out(tok)
+      tok
+    end
+
+    def out(tok)
+      mark_lineno if @lineno == 0
+      if Keywords.include?(tok.class)
+	pp_tok(tok, "key")
+	return
+      end
+      
+      case tok
+	when ActionScript::Parse::MultiLineCommentToken
+	  if tok.body[0] == "*"[0]
+	    pp_tok(tok, "comment doc")
+	  else
+	    pp_tok(tok, "comment")
+	  end
+	when ActionScript::Parse::SingleLineCommentToken
+	  pp_tok(tok, "comment")
+	when ActionScript::Parse::StringToken
+	  pp_tok(tok, "str_const")
+	when ActionScript::Parse::NumberToken
+	  pp_tok(tok, "num_const")
+	else
+	  p_tok(tok)
+      end
+    end
+
+    def pp_tok(tok, clazz)
+      @out.html_span("class"=>clazz) do
+	p_tok(tok)
+      end
+    end
+    def p_tok(tok)
+      txt = StringScanner.new(tok.to_s)
+      until txt.eos?
+	if match = txt.scan_until(/\r\n|\n|\r/)
+	  p_str(match)
+	  mark_lineno
+	else
+	  p_str(txt.rest)
+	  txt.terminate
+	end
+      end
+    end
+
+    def mark_lineno
+      @lineno += 1
+      @out.html_span("id"=>@lineno.to_s, "class"=>"lineno") do
+	@out.pcdata("%6d  " % [@lineno])
+      end
+    end
+
+    def p_str(str)
+      @out.pcdata(str)
+    end
+  end
+
+  def navigation
+    html_ul("class"=>"main_nav") do
+      html_li do
+	html_a("Overview", {"href"=>base_path("overview-summary.html")})
+      end
+      html_li do
+	html_a("Package", {"href"=>"package-summary.html"})
+      end
+      html_li do
+	html_a("Class", {"href"=>@type.unqualified_name+".html"})
+      end
+      html_li do
+	html_span("Source", {"class"=>"nav_current"})
+      end
+      html_li do
+	html_a("Index", {"href"=>base_path("index-files/index.html")})
+      end
+    end
+  end
+
+  def link_top
+    yield "Overview", base_path("overview-summary.html")
+  end
+end
+
 def make_page_list(conf, type_agregator)
   list = []
 
   list << FramesetPage.new()
-  list << OverviewPage.new(type_agregator)
+  list << OverviewPage.new(conf, type_agregator)
   list << OverviewFramePage.new(type_agregator)
   list << AllTypesFramePage.new(type_agregator)
 
@@ -1641,8 +1849,9 @@
   last_type_page = nil
   type_agregator.each_type do |type|
     if type.document?
-      type_page = TypePage.new(type)
+      type_page = TypePage.new(conf, type)
       list << type_page
+      list << SourcePage.new(conf, type) if conf.sources
 
       if last_type
 	type_page.prev_type = last_type
@@ -1654,7 +1863,7 @@
     end
   end
 
-  list << IndexPage.new(type_agregator)
+  list << IndexPage.new(conf, type_agregator)
 
   list
 end

trunk/as2api/ui
cli.rb 183 -> 184
--- trunk/as2api/ui/cli.rb	2005-07-03 20:17:44 UTC (rev 183)
+++ trunk/as2api/ui/cli.rb	2005-07-04 00:20:55 UTC (rev 184)
@@ -10,7 +10,8 @@
 		  :progress_listener,
 		  :input_encoding,
 		  :draw_diagrams,
-		  :dot_exe)
+		  :dot_exe,
+		  :sources)
 
 SourceFile = Struct.new(:prefix, :suffix)
 
@@ -82,7 +83,8 @@
       [ "--progress",         GetoptLong::NO_ARGUMENT ],
       [ "--encoding",         GetoptLong::REQUIRED_ARGUMENT ],
       [ "--draw-diagrams",    GetoptLong::NO_ARGUMENT ],
-      [ "--dot-exe",          GetoptLong::REQUIRED_ARGUMENT ]
+      [ "--dot-exe",          GetoptLong::REQUIRED_ARGUMENT ],
+      [ "--sources",          GetoptLong::NO_ARGUMENT ]
     )
 
     conf = Conf.new
@@ -110,6 +112,8 @@
 	  conf.draw_diagrams = true
 	when "--dot-exe"
 	  conf.dot_exe = arg
+	when "--sources"
+	  conf.sources = true
       end
     end
     if ARGV.empty?
@@ -158,8 +162,7 @@
       begin
 	is_utf8 = detect_bom?(io)
 	type = simple_parse(io)
-	type.input_filename = file.suffix
-	type.sourcepath_location(File.dirname(file.suffix))
+	type.input_file = file
 	type.source_utf8 = is_utf8
 	type_agregator.add_type(type)
       rescue =>e
@@ -223,6 +226,8 @@
   --dot-exe <filename>
         Specify the location of the 'dot' tool from Graphviz, if it is not
         available via the standard PATH.
+  --sources
+        Generate an HTML page for the source code of each input file
     END
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 4 22:31:49 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 04 Jul 2005 22:31:49 +0000 Subject: [as2api-dev] [CVS trunk] Add back missing error handling (got dropped during earlier optimisation). Message-ID:
Commit in trunk/as2api on MAIN
parse/lexer.rb+6-1184 -> 185
tc_actionscript_lexer.rb+8184 -> 185
+14-1
2 modified files
Add back missing error handling (got dropped during earlier optimisation).

There was an infinate loop when no lexer rule matched input :(

trunk/as2api/parse
lexer.rb 184 -> 185
--- trunk/as2api/parse/lexer.rb	2005-07-04 00:20:55 UTC (rev 184)
+++ trunk/as2api/parse/lexer.rb	2005-07-04 22:31:48 UTC (rev 185)
@@ -385,7 +385,12 @@
       text << "  next\n"
       text << "end\n"
     end
-    text << "        end\n      end\n"
+    text << <<-EOS
+          # no previous regexp matched,
+          parse_error(line.rest)
+        end
+      end
+    EOS
     class_eval(text)
   end
 

trunk/as2api
tc_actionscript_lexer.rb 184 -> 185
--- trunk/as2api/tc_actionscript_lexer.rb	2005-07-04 00:20:55 UTC (rev 184)
+++ trunk/as2api/tc_actionscript_lexer.rb	2005-07-04 22:31:48 UTC (rev 185)
@@ -5,6 +5,14 @@
 
   include ActionScript::Parse
 
+  def test_lex_error
+    begin
+      assert_lex_to("@")
+      flunk("should be exception on invalid input")
+    rescue
+    end
+  end
+
   def test_simple_string
     assert_lex_to("'test'", StringToken.new("test", 1))
     assert_lex_to("\"test\"", StringToken.new("test", 1))
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 4 23:21:51 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 04 Jul 2005 23:21:51 +0000 Subject: [as2api-dev] [CVS trunk] Rather than each lexical action call emit() directly, just return the token Message-ID:
Commit in trunk/as2api/parse on MAIN
lexer.rb+17-17185 -> 186
Rather than each lexical action call emit() directly, just return the token
and have the calling code do the emit().  This is simpler.

trunk/as2api/parse
lexer.rb 185 -> 186
--- trunk/as2api/parse/lexer.rb	2005-07-04 22:31:48 UTC (rev 185)
+++ trunk/as2api/parse/lexer.rb	2005-07-04 23:21:49 UTC (rev 186)
@@ -288,8 +288,8 @@
     EOE
     ActionScript::Parse.const_set(class_name, the_class)
 
-    add_match(match) do |lex, match, io|
-      lex.emit(ActionScript::Parse.const_get(class_name).new(io.lineno))
+    add_match(match) do |match, io|
+      ActionScript::Parse.const_get(class_name).new(io.lineno)
     end
   end
 
@@ -297,17 +297,17 @@
     make_simple_token(name.capitalize, name, "#{name}\\b")
   end
 
-  add_match(WHITESPACE) do |lex, match, io|
+  add_match(WHITESPACE) do |match, io|
     # TODO: whitespace tokens don't span lines, which might not be the expected
     #       behaviour
-    lex.emit(WhitespaceToken.new(match[0], io.lineno))
+    WhitespaceToken.new(match[0], io.lineno)
   end
 
-  add_match(SINGLE_LINE_COMMENT) do |lex, match, io|
-    lex.emit(SingleLineCommentToken.new(match[1], io.lineno))
+  add_match(SINGLE_LINE_COMMENT) do |match, io|
+    SingleLineCommentToken.new(match[1], io.lineno)
   end
 
-  add_match(OMULTI_LINE_COMMENT) do |lex, match, io|
+  add_match(OMULTI_LINE_COMMENT) do |match, io|
     lineno = io.lineno
     line = match.post_match
     comment = ''
@@ -316,8 +316,8 @@
       line = io.readline;
     end
     comment << $`
-    lex.emit(MultiLineCommentToken.new(comment, lineno))
     match.string = $'
+    MultiLineCommentToken.new(comment, lineno)
   end
 
   Keywords.each do |keyword|
@@ -332,11 +332,11 @@
     make_punctuation_token(*punct)
   end
 
-  add_match(ident) do |lex, match, io|
-    lex.emit(IdentifierToken.new(match[0], io.lineno))
+  add_match(ident) do |match, io|
+    IdentifierToken.new(match[0], io.lineno)
   end
 
-  add_match(STRING_START1) do |lex, match, io|
+  add_match(STRING_START1) do |match, io|
     lineno = io.lineno
     line = match.post_match
     str = ''
@@ -345,11 +345,11 @@
       line = io.readline;
     end
     str << $1
-    lex.emit(StringToken.new(str, lineno))
     match.string = $'
+    StringToken.new(str, lineno)
   end
 
-  add_match(STRING_START2) do |lex, match, io|
+  add_match(STRING_START2) do |match, io|
     lineno = io.lineno
     line = match.post_match
     str = ''
@@ -358,12 +358,12 @@
       line = io.readline;
     end
     str << $1
-    lex.emit(StringToken.new(str, lineno))
     match.string = $'
+    StringToken.new(str, lineno)
   end
 
-  add_match(num) do |lex, match, io|
-    lex.emit(NumberToken.new(match[0], io.lineno))
+  add_match(num) do |match, io|
+    NumberToken.new(match[0], io.lineno)
   end
 
   def check_fill
@@ -381,7 +381,7 @@
     @@matches.each_with_index do |token_match, index|
       re, action = token_match
       text << "if line.scan(/#{re}/)\n"
-      text << "  @@matches[#{index}][1].call(self, line, @io)\n"
+      text << "  emit(@@matches[#{index}][1].call(line, @io))\n"
       text << "  next\n"
       text << "end\n"
     end
CVSspam 0.2.11
From wavy at users.sourceforge.net Tue Jul 5 09:33:03 2005 From: wavy at users.sourceforge.net (David Holroyd) Date: Tue, 5 Jul 2005 09:33:03 +0000 Subject: [as2api-dev] Re: [Asunit-users] Great tool, but where's the documentation? In-Reply-To: References: Message-ID: <20050705093303.GA15054@vhost.badgers-in-foil.co.uk> On Mon, Jul 04, 2005 at 10:44:30PM -0400, Kristopher Schultz wrote: > Also, I've decided to use Dave's as2api utility as my reference doc > generator when proofing my doc comments. I've chosen as2api because a) > I'd like to support Dave's efforts (thanks, Dave!), b) using as2api > should help ensure that the doc comment formatting will parse properly > in any doc gen tool that supports javadoc style tags, and c) it's > free. Cool! If there's anything I can do to help, just let me know (maybe on as2api-dev -- to keep off-topic discussion away from the asunit list). > There are some downsides, however. From what I can tell, as2api can > not currently generate XHTML-compliant markup (and in fact, the markup > required to get the doc comments to display properly will likely have > to change if as2api ever does become XHTML-compliant), I put a bit of effort into making output from the as2api 0.3 release validate against the XHTML DTDs. Are you using an older version, or did I miss some bugs? > and it doesn't support alternate output formats - especially Flash > Help and XML. I spend next-to-no time using the MM Flash IDE, so I'm more motivated to get the HTML output working really well, for the moment. [ I'll accept patches ;) ] dave -- http://david.holroyd.me.uk/ From kschultz at resource.com Tue Jul 5 12:51:54 2005 From: kschultz at resource.com (Kristopher Schultz) Date: Tue, 5 Jul 2005 08:51:54 -0400 Subject: [as2api-dev] code coloring request Message-ID: Dave, I noticed that when I view the code source exported as part of the the API docs that it is nicely color coded. Any chance of applying this same code coloring to code placed inside
 tags within a doc
comment?

Kris
=20
--=20
=20
Kristopher Schultz
Developer
=20
Resource Interactive
p: 614.410.2123
www.resource.com


From dave at badgers-in-foil.co.uk  Tue Jul  5 13:31:23 2005
From: dave at badgers-in-foil.co.uk (David Holroyd)
Date: Tue, 5 Jul 2005 13:31:23 +0000
Subject: [as2api-dev] code coloring request
In-Reply-To: 
References: 
Message-ID: <20050705133123.GB16672@vhost.badgers-in-foil.co.uk>

On Tue, Jul 05, 2005 at 08:51:54AM -0400, Kristopher Schultz wrote:
> I noticed that when I view the code source exported as part of the the
> API docs that it is nicely color coded. Any chance of applying this same
> code coloring to code placed inside 
 tags within a doc
> comment?

Heh, I was having thoughts along the same lines.  However, I was
thinking that this should happen only to the content of {@code} tags.

I'm reluctant to apply magic processing to the contents of particular
HTML tags, but that's mostly bacause as2api doesn't inspect the HTML at
all; any tags are just passed through verbatim.

Also, if people want to put stuff other than AS into a 
, the AS
syntax highlight applied to the content will look messy.

However, before I can add this in, I need to do a bunch of work on the
doc-comment parser.  The current, simplistic implementation will not
allow a {@code} tag to span multiple lines, which people are sure to
need.

....Oh dear, I just realised that closing braces will need fairly
cunning handling,

i.e
  {@code while(true) { ... }}

That could be done with brace matching I guess.


What do you think?


dave

-- 
http://david.holroyd.me.uk/


From Gaspy   Sat Jul  9 06:00:33 2005
From: Gaspy  (Gaspy)
Date: Sat, 9 Jul 2005 09:00:33 +0300
Subject: [as2api-dev] AS2API command line problems
Message-ID: <5a0e474805070823007e4f3628@mail.gmail.com>

------=_Part_357_10408951.1120888833208
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello,

I know I will sound like a complete idiot, but I just can't make the latest=
=20
as2aspi windows binary to work.

In a folder, I have a bunch of .as files, with the path md.components; I=20
moved as2api in that folder and from the command prompt I entered 'as2api=
=20
md.components.*' and I got ''error: No source files matching specified=20
packages". Then I tried countless variations, like entring just 'md' or '
md.components' or specifying the classpath as 'as2api --classpath=20
d:\works\md_classes md.components.* and so on.

Then, I tried the older Windows GUI version. It (kindof) worked in that it=
=20
parsed the classes, but it ignored all the comments.

So, what' wrong?

Regards,
Armand

------=_Part_357_10408951.1120888833208
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello,

I know I will sound like a complete idiot, but I just can't make the latest= as2aspi windows binary to  work.

In a folder, I have a bunch of .as files, with the path md.components; I moved as2api in that folder and from the command prompt I entered 'as2api md.components.*' and I got ''error: No source files matching specified packages". Then I tried countless variations, like entring just 'md' or 'md.components' or specifying the classpath as 'as2api --classpath d:\works\md_classes md.components.* and so on.

Then, I tried the older Windows GUI version. It (kindof) worked in that it = parsed the classes, but it ignored all the comments.

So, what' wrong?

Regards,
   Armand
------=_Part_357_10408951.1120888833208-- From alex at gengon.de Sat Jul 9 12:45:29 2005 From: alex at gengon.de (=?ISO-8859-1?Q?Alex_K=E4mmerer?=) Date: Sat, 09 Jul 2005 14:45:29 +0200 Subject: [as2api-dev] Some CSS and HTML probs ??? Message-ID: <42CFC6E9.6040005@gengon.de> hey leutz, i´m working on a diffrent style for the doc and found some not so nice 'issues'. browser don´t like empty a tags like all text behind will be part of the tag. i think its better to make it like this , its not xml like but it works fine on all browsers. and also IE and mozilla looking very diffrent, i think a cleaner allover working HTML would be great ;) Maybe a list with all used css classes would be great. i will work out a little how to style and will post it here much thx and keep on working it is a great tool on now and i think it will become a more standard tool in future for as2 docs. it´s simple and fast yours alex From dave at badgers-in-foil.co.uk Sun Jul 10 12:43:53 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 10 Jul 2005 12:43:53 +0000 Subject: [as2api-dev] AS2API command line problems In-Reply-To: <5a0e474805070823007e4f3628@mail.gmail.com> References: <5a0e474805070823007e4f3628@mail.gmail.com> Message-ID: <20050710124353.GA22963@vhost.badgers-in-foil.co.uk> Hi there! On Sat, Jul 09, 2005 at 09:00:33AM +0300, Gaspy wrote: > In a folder, I have a bunch of .as files, with the path md.components; I > moved as2api in that folder and from the command prompt I entered 'as2api > md.components.*' and I got ''error: No source files matching specified > packages". Then I tried countless variations, like entring just 'md' or ' > md.components' or specifying the classpath as 'as2api --classpath > d:\works\md_classes md.components.* and so on. Does your directory structure match the package structure exactly? If you tell as2api to document 'md.components.*', it will search for classes within the subfolders 'md/components/...' in your classpath (i.e 'd:\works\md_classes\md\components' contains the .as files for this package). > Then, I tried the older Windows GUI version. It (kindof) worked in that it > parsed the classes, but it ignored all the comments. Can you provide an example of one of the classes? If you don't want to post your code to a public mailing list, by all means send me a private email. Hope I can help, dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Sun Jul 10 12:55:15 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 10 Jul 2005 12:55:15 +0000 Subject: [as2api-dev] [CVS trunk] Fix anchor targets for non-XHTML-understanding browsers. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+2-2186 -> 187
Fix anchor targets for non-XHTML-understanding browsers.
(Second reminder from Alex K?\195?\164mmerer -- Rostislav previously provided this fix.)

trunk/as2api
html_output.rb 186 -> 187
--- trunk/as2api/html_output.rb	2005-07-04 23:21:49 UTC (rev 186)
+++ trunk/as2api/html_output.rb	2005-07-10 12:55:14 UTC (rev 187)
@@ -692,7 +692,7 @@
   end
 
   def document_field(field)
-    html_a("name"=>"field_#{field.name}")
+    html_a("", "name"=>"field_#{field.name}")
     html_h3(field.name)
     html_div("class"=>"field_details") do
       field_synopsis(field)
@@ -726,7 +726,7 @@
     css_class = "method_details"
     css_class << " alt_row" if alt_row
     html_div("class"=>css_class) do
-      html_a("name"=>"method_#{method.name}")
+      html_a("", "name"=>"method_#{method.name}")
       html_h3(method.name)
       method_synopsis(method)
       html_div("class"=>"method_info") do
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 10 13:11:32 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 10 Jul 2005 13:11:32 +0000 Subject: [as2api-dev] Some CSS and HTML probs ??? In-Reply-To: <42CFC6E9.6040005@gengon.de> References: <42CFC6E9.6040005@gengon.de> Message-ID: <20050710131132.GB22963@vhost.badgers-in-foil.co.uk> Hello! On Sat, Jul 09, 2005 at 02:45:29PM +0200, Alex K?mmerer wrote: > i?m working on a diffrent style for the doc > and found some not so nice 'issues'. > browser don?t like empty a tags like > all text behind will be part of the tag. i think its better to make it > like this , its not xml like but it works fine > on all browsers. Oops, that's something that that Rostislav Hristov included his big set of changes to the HTML output -- but I guess I missed it :( I've just commited a fix for this, so it will appear in the next release. > and also IE and mozilla looking very diffrent, i think a cleaner allover > working HTML would be great ;) I'll own-up to not really having tested the last release's output in IE. I will try to check before the next release; but if you can point out any specific stuff that needs fixing, things will move along faster :) > Maybe a list with all used css classes would be great. Yeah, very good idea, but I don't want to document the CSS hooks quite yet. That would give the impression that they will remain between releases, and I need a free hand to change things around in upcoming versions. Once I'm happy that the output has 'stabilised', documenting the CSS, as you suggest, would be a great idea. > i will work out a little how to style and will post it here Cool! It would be great to see what you come up with. thanks for the bug reports, dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Mon Jul 11 17:58:36 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 11 Jul 2005 17:58:36 +0000 Subject: [as2api-dev] [CVS trunk] Un-break the sourcepath_location hack Message-ID:
Commit in trunk/as2api on MAIN
api_model.rb+1-1187 -> 188
Un-break the sourcepath_location hack

trunk/as2api
api_model.rb 187 -> 188
--- trunk/as2api/api_model.rb	2005-07-10 12:55:14 UTC (rev 187)
+++ trunk/as2api/api_model.rb	2005-07-11 17:58:34 UTC (rev 188)
@@ -37,7 +37,7 @@
 
   def input_file=(file)
     @input_file = file
-    sourcepath_location = file
+    sourcepath_location(File.dirname(file.suffix))
   end
 
   attr_reader :input_file
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 11 19:14:02 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 11 Jul 2005 19:14:02 +0000 Subject: [as2api-dev] Re: AS2API command line & GUI issues In-Reply-To: <42D2154D.9020105@media-division.com> References: <42D2154D.9020105@media-division.com> Message-ID: <20050711191401.GE11804@vhost.badgers-in-foil.co.uk> On Mon, Jul 11, 2005 at 09:44:29AM +0300, Armand Niculescu wrote: > sorry to bother, No trouble at all! > I have some details of the problems I'm facing. > > The directory structure is OK as far as I can tell, I have a screenshot, > the packages are in separate folders. Yeah, from that screenshot, it appears as though the directory structure is exactly as it should be. I will try to prepare a version of as2api that gives more feedback than just "No source files matching ..." to help debug this. > You'll also find a sample class file from the package as well as the > resulting documentation from the 0.2 GUI version. The comments in the file you provided don't confirm to the format that as2api expects. Specifically, - @param documentation must name the parameter being documented, so rather than, @param value to validate you need, @param num value to validate - Descriptions don't have a specific tag; just put the descriptive text at the very beginning of the comment, before anything else. Rather than, /** ... @description Validate a number, with optional boundaries ... you need, /** Validate a number, with optional boundaries ... This is based on the format used by JavaDoc. dave From Gaspy Mon Jul 11 19:42:21 2005 From: Gaspy (Gaspy) Date: Mon, 11 Jul 2005 22:42:21 +0300 Subject: [as2api-dev] Re: AS2API command line & GUI issues In-Reply-To: <20050711191401.GE11804@vhost.badgers-in-foil.co.uk> References: <42D2154D.9020105@media-division.com> <20050711191401.GE11804@vhost.badgers-in-foil.co.uk> Message-ID: <5a0e474805071112425b246cec@mail.gmail.com> ------=_Part_1138_18677272.1121110941936 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dave, thanks for clarifaying the tags for me... I've tried other documentation=20 generators that expected different formats and I didn't check the format=20 expected by as2api. I will alter a class tomorrow and try again. A debug version is welcome, I'm looking forward to it. Thanks, Armand ------=_Part_1138_18677272.1121110941936 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dave,

thanks for clarifaying the tags for me... I've tried other documentation generators that expected different formats and I didn't check the format expected by as2api. I will alter a class tomorrow and try again.

A debug version is welcome, I'm looking forward to it.

Thanks,
   Armand

------=_Part_1138_18677272.1121110941936-- From dave at badgers-in-foil.co.uk Mon Jul 11 20:16:54 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 11 Jul 2005 20:16:54 +0000 Subject: [as2api-dev] [CVS trunk] Add warning about useless classpath entries Message-ID:
Commit in trunk/as2api/ui on MAIN
cli.rb+8188 -> 189
Add warning about useless classpath entries

trunk/as2api/ui
cli.rb 188 -> 189
--- trunk/as2api/ui/cli.rb	2005-07-11 17:58:34 UTC (rev 188)
+++ trunk/as2api/ui/cli.rb	2005-07-11 20:16:53 UTC (rev 189)
@@ -150,9 +150,14 @@
   def find_sources
     result = []
     @conf.classpath.each do |path|
+      found_sources = false
       each_source(path) do |source|
 	result << SourceFile.new(path, source) if process_file?(source)
+	found_sources = true
       end
+      unless found_sources
+	warn("#{path.inspect} contains no ActionScript files")
+      end
     end
     result
   end
@@ -236,6 +241,9 @@
     exit(-1)
   end
 
+  def warn(msg)
+    $stderr.puts("warning: #{msg}")
+  end
 end
 
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 11 21:40:49 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 11 Jul 2005 21:40:49 +0000 Subject: [as2api-dev] [CVS trunk] Annoying messages about packages we're ignoring, for the sake of debugging Message-ID:
Commit in trunk/as2api/ui on MAIN
cli.rb+10-1189 -> 190
Annoying messages about packages we're ignoring, for the sake of debugging

trunk/as2api/ui
cli.rb 189 -> 190
--- trunk/as2api/ui/cli.rb	2005-07-11 20:16:53 UTC (rev 189)
+++ trunk/as2api/ui/cli.rb	2005-07-11 21:40:48 UTC (rev 190)
@@ -2,6 +2,7 @@
 require 'documenter'
 require 'getoptlong'
 require 'html_output'
+require 'set'
 
 Conf = Struct.new(:output_dir,
                   :classpath,
@@ -149,10 +150,18 @@
 
   def find_sources
     result = []
+    ignored_packages = Set.new
     @conf.classpath.each do |path|
       found_sources = false
       each_source(path) do |source|
-	result << SourceFile.new(path, source) if process_file?(source)
+	if process_file?(source)
+	  result << SourceFile.new(path, source)
+	else
+	  dirname = File.dirname(source)
+	  if ignored_packages.add?(dirname)
+	    warn("package #{dirname.gsub(/\//, '.').inspect} will not be documented")
+	  end
+	end
 	found_sources = true
       end
       unless found_sources
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 11 22:18:57 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 11 Jul 2005 22:18:57 +0000 Subject: [as2api-dev] [CVS trunk] Canonicalize classpath elements before searching. Message-ID:
Commit in trunk/as2api/ui on MAIN
cli.rb+1-1190 -> 191
Canonicalize classpath elements before searching.
I suspect relative paths may previously have been pruned by starts-with-. test

trunk/as2api/ui
cli.rb 190 -> 191
--- trunk/as2api/ui/cli.rb	2005-07-11 21:40:48 UTC (rev 190)
+++ trunk/as2api/ui/cli.rb	2005-07-11 22:18:56 UTC (rev 191)
@@ -153,7 +153,7 @@
     ignored_packages = Set.new
     @conf.classpath.each do |path|
       found_sources = false
-      each_source(path) do |source|
+      each_source(File.expand_path(path)) do |source|
 	if process_file?(source)
 	  result << SourceFile.new(path, source)
 	else
CVSspam 0.2.11
From Gaspy Tue Jul 12 08:55:21 2005 From: Gaspy (Gaspy) Date: Tue, 12 Jul 2005 11:55:21 +0300 Subject: [as2api-dev] Command line followup Message-ID: <5a0e474805071201555d6dede@mail.gmail.com> ------=_Part_1386_27664397.1121158521518 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, after trying the windows .exe with no luck, I decided to try the ruby=20 scripts... so, I downloaded Ruby 182-15, installed it, and run the as2api= =20 from command line. surprise, surprise, it worked! I think I've downloaded the same script=20 version from the website (0.3) and i've used the same commandline=20 parameteres, in one case it was as2api.exe --classpath d:\works\md_classes md.* and in the other ruby as2api.rb --classpath d:\works\md_classes md.* Very strange, but at least it works and I can use it. Thank you for your very hard work, Armand ------=_Part_1386_27664397.1121158521518 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,

after trying the windows .exe with no luck, I decided to try the ruby scripts... so, I downloaded Ruby 182-15, installed it, and run the as2api from command line.

surprise, surprise, it worked! I think I've downloaded the same script version from the website (0.3) and i've used the same commandline parameteres, in one case it was
as2api.exe --classpath d:\works\md_classes md.*
and in the other
ruby as2api.rb --classpath d:\works\md_classes md.*

Very strange, but at least it works and I can use it.

Thank you for your very hard work,
    Armand
------=_Part_1386_27664397.1121158521518-- From dave at badgers-in-foil.co.uk Tue Jul 12 17:11:49 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 12 Jul 2005 17:11:49 +0000 Subject: [as2api-dev] [CVS trunk] Implement lexical actions with named callback methods, rather than Procs. Message-ID:
Commit in trunk/as2api/parse on MAIN
lexer.rb+33-23191 -> 192
Implement lexical actions with named callback methods, rather than Procs.

Part of ongoing refactoring to try and make Lexer infrastructure more
reusable.

trunk/as2api/parse
lexer.rb 191 -> 192
--- trunk/as2api/parse/lexer.rb	2005-07-11 22:18:56 UTC (rev 191)
+++ trunk/as2api/parse/lexer.rb	2005-07-12 17:11:48 UTC (rev 192)
@@ -274,8 +274,8 @@
   w =		"[ \t\r\n\f]*"
 
 
-  def self.add_match(match)
-    @@matches << [make_match(match), Proc.new]
+  def self.add_match(match, lex_meth_sym, tok_class_sym)
+    @@matches << [make_match(match), lex_meth_sym, tok_class_sym]
   end
 
   def self.make_simple_token(name, value, match)
@@ -288,26 +288,34 @@
     EOE
     ActionScript::Parse.const_set(class_name, the_class)
 
-    add_match(match) do |match, io|
-      ActionScript::Parse.const_get(class_name).new(io.lineno)
-    end
+    add_match(match, :lex_simple_token, class_name.to_sym)
   end
 
+  def lex_simple_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(io.lineno)
+  end
+
   def self.make_keyword_token(name)
     make_simple_token(name.capitalize, name, "#{name}\\b")
   end
 
-  add_match(WHITESPACE) do |match, io|
-    # TODO: whitespace tokens don't span lines, which might not be the expected
-    #       behaviour
-    WhitespaceToken.new(match[0], io.lineno)
+  # TODO: whitespace tokens don't span lines, which might not be the expected
+  #       behaviour
+  add_match(WHITESPACE, :lex_simplebody_token, :WhitespaceToken)
+
+  def lex_simplebody_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
   end
 
-  add_match(SINGLE_LINE_COMMENT) do |match, io|
+  add_match(SINGLE_LINE_COMMENT, :lex_singlelinecoomment_token, :SingleLineCommentToken)
+
+  def lex_singlelinecoomment_token(class_sym, match, io)
     SingleLineCommentToken.new(match[1], io.lineno)
   end
 
-  add_match(OMULTI_LINE_COMMENT) do |match, io|
+  add_match(OMULTI_LINE_COMMENT, :lex_multilinecomment_token, :MultiLineCommentToken)
+
+  def lex_multilinecomment_token(class_sym, match, io)
     lineno = io.lineno
     line = match.post_match
     comment = ''
@@ -332,39 +340,41 @@
     make_punctuation_token(*punct)
   end
 
-  add_match(ident) do |match, io|
-    IdentifierToken.new(match[0], io.lineno)
-  end
+  add_match(ident, :lex_simplebody_token, :IdentifierToken)
 
-  add_match(STRING_START1) do |match, io|
+  add_match(STRING_START1, :lex_string1_token, :StringToken)
+
+  def lex_string1_token(class_sym, match, io)
     lineno = io.lineno
     line = match.post_match
     str = ''
-    until line =~ /\A#{STRING_END1}/o
+    until line =~ /#{STRING_END1}/o
       str << line
       line = io.readline;
+      raise "#{lineno}:unexpected EOF in string" if line.nil?
     end
     str << $1
     match.string = $'
     StringToken.new(str, lineno)
   end
 
-  add_match(STRING_START2) do |match, io|
+  add_match(STRING_START2, :lex_string2_token, :StringToken)
+
+  def lex_string2_token(class_sym, match, io)
     lineno = io.lineno
     line = match.post_match
     str = ''
-    until line =~ /\A#{STRING_END2}/o
+    until line =~ /#{STRING_END2}/o
       str << line
       line = io.readline;
+      raise "#{lineno}:unexpected EOF in string" if line.nil?
     end
     str << $1
     match.string = $'
     StringToken.new(str, lineno)
   end
 
-  add_match(num) do |match, io|
-    NumberToken.new(match[0], io.lineno)
-  end
+  add_match(num, :lex_simplebody_token, :NumberToken)
 
   def check_fill
     if @tokens.empty? && !@io.eof?
@@ -379,9 +389,9 @@
         until line.eos?
     EOS
     @@matches.each_with_index do |token_match, index|
-      re, action = token_match
+      re, lex_method, tok_class = token_match
       text << "if line.scan(/#{re}/)\n"
-      text << "  emit(@@matches[#{index}][1].call(line, @io))\n"
+      text << "  emit(#{lex_method.to_s}(:#{tok_class.to_s}, line, @io))\n"
       text << "  next\n"
       text << "end\n"
     end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Tue Jul 12 17:16:16 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 12 Jul 2005 17:16:16 +0000 Subject: [as2api-dev] [CVS trunk] Some TODO items I've been collecting Message-ID:
Commit in trunk/as2api on MAIN
TODO+17192 -> 193
Some TODO items I've been collecting

trunk/as2api
TODO 192 -> 193
--- trunk/as2api/TODO	2005-07-12 17:11:48 UTC (rev 192)
+++ trunk/as2api/TODO	2005-07-12 17:16:15 UTC (rev 193)
@@ -14,3 +14,20 @@
  
  - Automatically include the default CSS with the generated files (if there's
    no file there already)
+
+ - add --lang attribute so that generated HTML may include this metadata
+   (maybe once there's some kind of gettext support for generated strings)
+
+ - Maybe copy content of @author into HTML <meta name="Author" ...>
+   On the other hand, the @author tag sucks
+
+ - add parameter to specify a CSS to copy, rather than using the default
+
+ - User comments?
+   http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/144794
+   http://www.php.net/manual/en/ref.w32api.php
+   http://xulplanet.com/references/elemref/ref_xblhandler.html
+   http://www.jdocs.org/pdfbox/0.6.6/api/org/pdfbox/pdfwriter/COSWriter.html
+
+ - Handling of hex integer constants appears to be broken -- '0xff' gets
+   treated as IntegerToken<0>, IdentifierToken<xff> (I think).
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Tue Jul 12 21:06:33 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 12 Jul 2005 21:06:33 +0000 Subject: [as2api-dev] [CVS trunk] Move AS-lexer-specifics to a new file, leaving a small core of reusable code. Message-ID:
Commit in trunk/as2api on MAIN
api_loader.rb+1-1193 -> 194
parse/aslexer.rb+372added 194
     /lexer.rb+37-382193 -> 194
tc_actionscript_lexer.rb+1-1193 -> 194
+411-384
1 added + 3 modified, total 4 files
Move AS-lexer-specifics to a new file, leaving a small core of reusable code.

I'm hoping that this small core can be used to write a better doc-comment
parser.  Even if that doesn't work out, I think this new arrangement is a
little cleaner.

trunk/as2api
api_loader.rb 193 -> 194
--- trunk/as2api/api_loader.rb	2005-07-12 17:16:15 UTC (rev 193)
+++ trunk/as2api/api_loader.rb	2005-07-12 21:06:32 UTC (rev 194)
@@ -1,5 +1,5 @@
 
-require 'parse/lexer'
+require 'parse/aslexer'
 require 'parse/parser'
 require 'api_model'
 require 'doc_comment'

trunk/as2api/parse
aslexer.rb added at 194
--- trunk/as2api/parse/aslexer.rb	2005-07-12 17:16:15 UTC (rev 193)
+++ trunk/as2api/parse/aslexer.rb	2005-07-12 21:06:32 UTC (rev 194)
@@ -0,0 +1,372 @@
+
+require 'parse/lexer'
+
+module ActionScript
+module Parse
+
+# TODO Create an EOFToken (so that we can report its line number)
+
+class ASToken
+  def initialize(body, lineno)
+    @body = body
+    @lineno = lineno
+  end
+  def body
+    @body
+  end
+  def lineno
+    @lineno
+  end
+  def to_s
+    @body
+  end
+end
+
+class CommentToken < ASToken
+end
+
+class NumberToken < CommentToken
+end
+
+class SingleLineCommentToken < CommentToken
+  def to_s
+    "//#{@body}"
+  end
+end
+
+class MultiLineCommentToken < CommentToken
+  def to_s
+    "/*#{@body}*/"
+  end
+end
+
+class WhitespaceToken < ASToken
+end
+
+class IdentifierToken < ASToken
+end
+
+class StringToken < ASToken
+  def initialize(body, lineno)
+    @body = unescape(body)
+    @lineno = lineno
+  end
+
+  def to_s
+    "\"#{escape(@body)}\""
+  end
+
+  def escape(text)
+    text.gsub(/./m) do
+      case $&
+        when "\\" then "\\\\"
+        when "\"" then "\\\""
+	when "\n" then "\\n"
+	when "\t" then "\\t"
+        else $&
+      end
+    end
+  end
+
+  def unescape(text)
+    escape = false
+    text.gsub(/./) do
+      if escape
+        escape = false
+        case $&
+          when "\\" then "\\"
+          when "n" then "\n"
+          when "t" then "\t"
+          else $&
+        end
+      else
+        case $&
+	  when "\\" then escape=true; ""
+	  else $&
+	end
+      end
+    end
+  end
+end
+
+# "get" and "set" where initially included in this list, since they are used
+# as modifiers to function declarations.  The are also allowed to appear as
+# identifiers, unfortunately, so we treat them as such, and have the parser
+# make special checks on the identifier body.
+Keywords = [
+  "as",
+  "break",
+  "case",
+  "catch",
+  "class",
+  "const",
+  "continue",
+  "default",
+  "dynamic",     # non-ECMA
+  "delete",
+  "do",
+  "else",
+  "extends",
+  "false",
+  "finally",
+  "for",
+  "function",
+  "if",
+  "implements",  # reserved, but unused in ECMA
+  "import",
+  "in",
+  "instanceof",
+  "interface",   # reserved, but unused in ECMA
+  "intrinsic",   # non-ECMA
+#  "is",         # not a keyword in AS
+#  "namespace",  # not a keyword in AS
+  "new",
+  "null",
+  "package",
+  "private",
+  "public",
+  "return",
+  "static",      # non-ECMA
+  "super",
+  "switch",
+  "this",
+  "throw",
+  "true",
+  "try",
+  "typeof",
+  "use",
+  "var",
+  "void",
+  "while",
+  "with"
+]
+
+Reserved = [
+  "abstract",
+  "debugger",
+  "enum",
+  "export",
+  "goto",
+  "native",
+  "protected",
+  "synchronized",
+  "throws",
+  "transient",
+  "volatile"
+]
+
+Punctuation = [
+  [:DivideAssign,         "/="],
+  [:Divide,               "/"],
+  [:BitNot,               "~"],
+  [:RBrace,               "}"],
+  [:OrAssign,             "||="],
+  [:Or,                   "||"],
+  [:BitOrAssign,          "|="],
+  [:BitOr,                "|"],
+  [:LBrace,               "{"],
+  [:XOrAssign,            "^^="],
+  [:XOr,                  "^^"],
+  [:BitXOrAssign,         "^="],
+  [:BitXOr,               "^"],
+  [:RBracket,             "]"],
+  [:LBracket,             "["],
+  [:Hook,                 "?"],
+  [:RShiftUnsignedAssign, ">>>="],
+  [:RShiftUnsigned,       ">>>"],
+  [:RShiftAssign,         ">>="],
+  [:RShift,               ">>"],
+  [:GreaterEquals,        ">="],
+  [:Greater,              ">"],
+  [:Same,                 "==="],
+  [:Equals,               "=="],
+  [:Assign,               "="],
+  [:LessEquals,           "<="],
+  [:LShiftAssign,         "<<="],
+  [:LShift,               "<<"],
+  [:Less,                 "<"],
+  [:Semicolon,            ";"],
+  [:Member,               "::"],
+  [:Colon,                ":"],
+  [:Ellipsis,             "..."],
+  [:Dot,                  "."],
+  [:MinusAssign,          "-="],
+  [:Decrement,            "--"],
+  [:Minus,                "-"],
+  [:Comma,                ","],
+  [:PlusAssign,           "+="],
+  [:Increment,            "++"],
+  [:Plus,                 "+"],
+  [:StarAssign,           "*="],
+  [:Star,                 "*"],
+  [:RParen,               ")"],
+  [:LParen,               "("],
+  [:BitAndAssign,         "&="],
+  [:AndAssign,            "&&="],
+  [:And,                  "&&"],
+  [:BitAnd,               "&"],
+  [:ModuloAssign,         "%="],
+  [:Modulo,               "%"],
+  [:BangSame,             "!=="],
+  [:BangEquals,           "!="],
+  [:Bang,                 "!"]
+]
+
+  h =		"[0-9a-fA-F]"
+  nl =		"\\n|\\r\\n|\\r|\\f"
+  nonascii =	"[\\200-\\377]"
+  unicode =	"\\\\#{h}{1,6}[ \\t\\r\\n\\f]?"
+  escape =	"(?:#{unicode}|\\\\[ -~\\200-\\377])"
+  nmstart =	"(?:[a-zA-Z_$]|#{nonascii}|#{escape})"
+  nmchar =	"(?:[a-zA-Z0-9_$]|#{nonascii}|#{escape})"
+  SINGLE_LINE_COMMENT = "//([^\n\r]*)"
+  OMULTI_LINE_COMMENT = "/\\*"
+  CMULTI_LINE_COMMENT = "\\*/"
+  STRING_START1 = "'"
+  STRING_END1 = "((?:(?:\\\\')|[\\t !\#$%&(-~]|#{nl}|\"|#{nonascii}|#{escape})*)\'"
+  STRING_START2 = '"'
+  STRING_END2 = "((?:(?:\\\\\")|[\\t !\#$%&(-~]|#{nl}|'|#{nonascii}|#{escape})*)\""
+  WHITESPACE = "[ \t\r\n\f]+"
+
+
+  IDENT =	"#{nmstart}#{nmchar}*"
+#  name =	"#{nmchar}+"
+  NUM	 =	"[0-9]+|[0-9]*\\.[0-9]+"
+#  string =	"#{string1}|#{string2}"
+  w =		"[ \t\r\n\f]*"
+
+class ASLexer < AbstractLexer
+
+
+  def lex_simple_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(io.lineno)
+  end
+
+  def lex_simplebody_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
+  end
+
+  def lex_singlelinecoomment_token(class_sym, match, io)
+    SingleLineCommentToken.new(match[1], io.lineno)
+  end
+
+  def lex_multilinecomment_token(class_sym, match, io)
+    lineno = io.lineno
+    line = match.post_match
+    comment = ''
+    until line =~ /\*\//o
+      comment << line
+      line = io.readline;
+    end
+    comment << $`
+    match.string = $'
+    MultiLineCommentToken.new(comment, lineno)
+  end
+
+  def lex_string1_token(class_sym, match, io)
+    lineno = io.lineno
+    line = match.post_match
+    str = ''
+    until line =~ /#{STRING_END1}/o
+      str << line
+      line = io.readline;
+      raise "#{lineno}:unexpected EOF in string" if line.nil?
+    end
+    str << $1
+    match.string = $'
+    StringToken.new(str, lineno)
+  end
+
+  def lex_string2_token(class_sym, match, io)
+    lineno = io.lineno
+    line = match.post_match
+    str = ''
+    until line =~ /#{STRING_END2}/o
+      str << line
+      line = io.readline;
+      raise "#{lineno}:unexpected EOF in string" if line.nil?
+    end
+    str << $1
+    match.string = $'
+    StringToken.new(str, lineno)
+  end
+
+
+end
+
+def self.build_lexer
+  builder = LexerBuilder.new
+
+  # TODO: whitespace tokens don't span lines, which might not be the expected
+  #       behaviour
+  builder.add_match(WHITESPACE, :lex_simplebody_token, :WhitespaceToken)
+
+  builder.add_match(SINGLE_LINE_COMMENT, :lex_singlelinecoomment_token, :SingleLineCommentToken)
+
+  builder.add_match(OMULTI_LINE_COMMENT, :lex_multilinecomment_token, :MultiLineCommentToken)
+
+  Keywords.each do |keyword|
+    builder.make_keyword_token(keyword)
+  end
+
+  Punctuation.each do |punct|
+    builder.make_punctuation_token(*punct)
+  end
+
+  builder.add_match(IDENT, :lex_simplebody_token, :IdentifierToken)
+
+  builder.add_match(STRING_START1, :lex_string1_token, :StringToken)
+
+  builder.add_match(STRING_START2, :lex_string2_token, :StringToken)
+
+  builder.add_match(NUM, :lex_simplebody_token, :NumberToken)
+
+  builder.build_lexer(ASLexer)
+end
+
+build_lexer
+
+class SkipASLexer
+  def initialize(lexer)
+    @lex = lexer
+    @handler = nil
+  end
+
+  def handler=(handler)
+    @handler = handler
+  end
+
+  def get_next
+    while skip?(tok=@lex.get_next)
+      notify(tok)
+    end
+    tok
+  end
+
+  def peek_next
+    while skip?(tok=@lex.peek_next)
+      notify(tok)
+      @lex.get_next
+    end
+    tok
+  end
+
+  protected
+
+  def skip?(tok)
+    tok.is_a?(CommentToken) || tok.is_a?(WhitespaceToken)
+  end
+
+  def notify(tok)
+    unless @handler.nil?
+      @handler.comment(tok.body)
+    end
+  end
+end
+
+
+end  # module Parse
+end  # module ActionScript
+
+
+# vim:shiftwidth=2:softtabstop=2

trunk/as2api/parse
lexer.rb 193 -> 194
--- trunk/as2api/parse/lexer.rb	2005-07-12 17:16:15 UTC (rev 193)
+++ trunk/as2api/parse/lexer.rb	2005-07-12 21:06:32 UTC (rev 194)
@@ -4,224 +4,9 @@
 module ActionScript
 module Parse
 
-# TODO Create an EOFToken (so that we can report its line number)
 
-class ASToken
-  def initialize(body, lineno)
-    @body = body
-    @lineno = lineno
-  end
-  def body
-    @body
-  end
-  def lineno
-    @lineno
-  end
-  def to_s
-    @body
-  end
-end
+class AbstractLexer
 
-class CommentToken < ASToken
-end
-
-class NumberToken < CommentToken
-end
-
-class SingleLineCommentToken < CommentToken
-  def to_s
-    "//#{@body}"
-  end
-end
-
-class MultiLineCommentToken < CommentToken
-  def to_s
-    "/*#{@body}*/"
-  end
-end
-
-class WhitespaceToken < ASToken
-end
-
-class IdentifierToken < ASToken
-end
-
-class StringToken < ASToken
-  def initialize(body, lineno)
-    @body = unescape(body)
-    @lineno = lineno
-  end
-
-  def to_s
-    "\"#{escape(@body)}\""
-  end
-
-  def escape(text)
-    text.gsub(/./m) do
-      case $&
-        when "\\" then "\\\\"
-        when "\"" then "\\\""
-	when "\n" then "\\n"
-	when "\t" then "\\t"
-        else $&
-      end
-    end
-  end
-
-  def unescape(text)
-    escape = false
-    text.gsub(/./) do
-      if escape
-        escape = false
-        case $&
-          when "\\" then "\\"
-          when "n" then "\n"
-          when "t" then "\t"
-          else $&
-        end
-      else
-        case $&
-	  when "\\" then escape=true; ""
-	  else $&
-	end
-      end
-    end
-  end
-end
-
-# "get" and "set" where initially included in this list, since they are used
-# as modifiers to function declarations.  The are also allowed to appear as
-# identifiers, unfortunately, so we treat them as such, and have the parser
-# make special checks on the identifier body.
-Keywords = [
-  "as",
-  "break",
-  "case",
-  "catch",
-  "class",
-  "const",
-  "continue",
-  "default",
-  "dynamic",     # non-ECMA
-  "delete",
-  "do",
-  "else",
-  "extends",
-  "false",
-  "finally",
-  "for",
-  "function",
-  "if",
-  "implements",  # reserved, but unused in ECMA
-  "import",
-  "in",
-  "instanceof",
-  "interface",   # reserved, but unused in ECMA
-  "intrinsic",   # non-ECMA
-#  "is",         # not a keyword in AS
-#  "namespace",  # not a keyword in AS
-  "new",
-  "null",
-  "package",
-  "private",
-  "public",
-  "return",
-  "static",      # non-ECMA
-  "super",
-  "switch",
-  "this",
-  "throw",
-  "true",
-  "try",
-  "typeof",
-  "use",
-  "var",
-  "void",
-  "while",
-  "with"
-]
-
-Reserved = [
-  "abstract",
-  "debugger",
-  "enum",
-  "export",
-  "goto",
-  "native",
-  "protected",
-  "synchronized",
-  "throws",
-  "transient",
-  "volatile"
-]
-
-Punctuation = [
-  [:DivideAssign,         "/="],
-  [:Divide,               "/"],
-  [:BitNot,               "~"],
-  [:RBrace,               "}"],
-  [:OrAssign,             "||="],
-  [:Or,                   "||"],
-  [:BitOrAssign,          "|="],
-  [:BitOr,                "|"],
-  [:LBrace,               "{"],
-  [:XOrAssign,            "^^="],
-  [:XOr,                  "^^"],
-  [:BitXOrAssign,         "^="],
-  [:BitXOr,               "^"],
-  [:RBracket,             "]"],
-  [:LBracket,             "["],
-  [:Hook,                 "?"],
-  [:RShiftUnsignedAssign, ">>>="],
-  [:RShiftUnsigned,       ">>>"],
-  [:RShiftAssign,         ">>="],
-  [:RShift,               ">>"],
-  [:GreaterEquals,        ">="],
-  [:Greater,              ">"],
-  [:Same,                 "==="],
-  [:Equals,               "=="],
-  [:Assign,               "="],
-  [:LessEquals,           "<="],
-  [:LShiftAssign,         "<<="],
-  [:LShift,               "<<"],
-  [:Less,                 "<"],
-  [:Semicolon,            ";"],
-  [:Member,               "::"],
-  [:Colon,                ":"],
-  [:Ellipsis,             "..."],
-  [:Dot,                  "."],
-  [:MinusAssign,          "-="],
-  [:Decrement,            "--"],
-  [:Minus,                "-"],
-  [:Comma,                ","],
-  [:PlusAssign,           "+="],
-  [:Increment,            "++"],
-  [:Plus,                 "+"],
-  [:StarAssign,           "*="],
-  [:Star,                 "*"],
-  [:RParen,               ")"],
-  [:LParen,               "("],
-  [:BitAndAssign,         "&="],
-  [:AndAssign,            "&&="],
-  [:And,                  "&&"],
-  [:BitAnd,               "&"],
-  [:ModuloAssign,         "%="],
-  [:Modulo,               "%"],
-  [:BangSame,             "!=="],
-  [:BangEquals,           "!="],
-  [:Bang,                 "!"]
-]
-
-# This is a Lexer for the tokens of ActionScript 2.0.
-class ASLexer
-  # This is a naive lexer implementation that considers input line-by-line,
-  # with special cases to handle multiline tokens (strings, comments).
-  # spacial care must be taken to declaire tokens in the 'correct' order (as
-  # the fist match wins), and to cope with keyword/identifier ambiguity
-  # (keywords have '\b' regexp-lookahead appended)
-
-  @@matches = []
-
   def initialize(io)
     @io = io
     @tokens = Array.new
@@ -244,41 +29,46 @@
     @tokens.shift
   end
 
-  private
+  def check_fill
+    if @tokens.empty? && !@io.eof?
+      fill()
+    end
+  end
 
-  def ASLexer.make_match(match)
-    match.gsub("/", "\\/").gsub("\n", "\\n")
+  def emit(token)
+    @tokens << token
   end
 
-  h =		"[0-9a-fA-F]"
-  nl =		"\\n|\\r\\n|\\r|\\f"
-  nonascii =	"[\\200-\\377]"
-  unicode =	"\\\\#{h}{1,6}[ \\t\\r\\n\\f]?"
-  escape =	"(?:#{unicode}|\\\\[ -~\\200-\\377])"
-  nmstart =	"(?:[a-zA-Z_$]|#{nonascii}|#{escape})"
-  nmchar =	"(?:[a-zA-Z0-9_$]|#{nonascii}|#{escape})"
-  SINGLE_LINE_COMMENT = "//([^\n\r]*)"
-  OMULTI_LINE_COMMENT = "/\\*"
-  CMULTI_LINE_COMMENT = "\\*/"
-  STRING_START1 = "'"
-  STRING_END1 = "((?:(?:\\\\')|[\\t !\#$%&(-~]|#{nl}|\"|#{nonascii}|#{escape})*)\'"
-  STRING_START2 = '"'
-  STRING_END2 = "((?:(?:\\\\\")|[\\t !\#$%&(-~]|#{nl}|'|#{nonascii}|#{escape})*)\""
-  WHITESPACE = "[ \t\r\n\f]+"
+  def parse_error(text)
+    raise "#{@io.lineno}:no lexigraphic match for text starting '#{text}'"
+  end
+  def warn(message)
+    $stderr.puts(message)
+  end
+end
 
 
-  ident =	"#{nmstart}#{nmchar}*"
-#  name =	"#{nmchar}+"
-  num	 =	"[0-9]+|[0-9]*\\.[0-9]+"
-#  string =	"#{string1}|#{string2}"
-  w =		"[ \t\r\n\f]*"
+# This is a Lexer for the tokens of ActionScript 2.0.
+class LexerBuilder
+  # This is a naive lexer implementation that considers input line-by-line,
+  # with special cases to handle multiline tokens (strings, comments).
+  # spacial care must be taken to declaire tokens in the 'correct' order (as
+  # the fist match wins), and to cope with keyword/identifier ambiguity
+  # (keywords have '\b' regexp-lookahead appended)
 
+  def initialize
+    @matches = []
+  end
 
-  def self.add_match(match, lex_meth_sym, tok_class_sym)
-    @@matches << [make_match(match), lex_meth_sym, tok_class_sym]
+  def make_match(match)
+    match.gsub("/", "\\/").gsub("\n", "\\n")
   end
 
-  def self.make_simple_token(name, value, match)
+  def add_match(match, lex_meth_sym, tok_class_sym)
+    @matches << [make_match(match), lex_meth_sym, tok_class_sym]
+  end
+
+  def make_simple_token(name, value, match)
     class_name = "#{name}Token"
     the_class = Class.new(ASToken)
     the_class.class_eval <<-EOE
@@ -291,104 +81,21 @@
     add_match(match, :lex_simple_token, class_name.to_sym)
   end
 
-  def lex_simple_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(io.lineno)
-  end
-
-  def self.make_keyword_token(name)
+  def make_keyword_token(name)
     make_simple_token(name.capitalize, name, "#{name}\\b")
   end
 
-  # TODO: whitespace tokens don't span lines, which might not be the expected
-  #       behaviour
-  add_match(WHITESPACE, :lex_simplebody_token, :WhitespaceToken)
-
-  def lex_simplebody_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
-  end
-
-  add_match(SINGLE_LINE_COMMENT, :lex_singlelinecoomment_token, :SingleLineCommentToken)
-
-  def lex_singlelinecoomment_token(class_sym, match, io)
-    SingleLineCommentToken.new(match[1], io.lineno)
-  end
-
-  add_match(OMULTI_LINE_COMMENT, :lex_multilinecomment_token, :MultiLineCommentToken)
-
-  def lex_multilinecomment_token(class_sym, match, io)
-    lineno = io.lineno
-    line = match.post_match
-    comment = ''
-    until line =~ /\*\//o
-      comment << line
-      line = io.readline;
-    end
-    comment << $`
-    match.string = $'
-    MultiLineCommentToken.new(comment, lineno)
-  end
-
-  Keywords.each do |keyword|
-    make_keyword_token(keyword)
-  end
-
-  def self.make_punctuation_token(name, value)
+  def make_punctuation_token(name, value)
     make_simple_token(name, value, Regexp.escape(value))
   end
 
-  Punctuation.each do |punct|
-    make_punctuation_token(*punct)
-  end
-
-  add_match(ident, :lex_simplebody_token, :IdentifierToken)
-
-  add_match(STRING_START1, :lex_string1_token, :StringToken)
-
-  def lex_string1_token(class_sym, match, io)
-    lineno = io.lineno
-    line = match.post_match
-    str = ''
-    until line =~ /#{STRING_END1}/o
-      str << line
-      line = io.readline;
-      raise "#{lineno}:unexpected EOF in string" if line.nil?
-    end
-    str << $1
-    match.string = $'
-    StringToken.new(str, lineno)
-  end
-
-  add_match(STRING_START2, :lex_string2_token, :StringToken)
-
-  def lex_string2_token(class_sym, match, io)
-    lineno = io.lineno
-    line = match.post_match
-    str = ''
-    until line =~ /#{STRING_END2}/o
-      str << line
-      line = io.readline;
-      raise "#{lineno}:unexpected EOF in string" if line.nil?
-    end
-    str << $1
-    match.string = $'
-    StringToken.new(str, lineno)
-  end
-
-  add_match(num, :lex_simplebody_token, :NumberToken)
-
-  def check_fill
-    if @tokens.empty? && !@io.eof?
-      fill()
-    end
-  end
-
-  def self.build_lexer
+  def build_lexer(target_class)
     text = <<-EOS
       def fill
         line = StringScanner.new(@io.readline)
         until line.eos?
     EOS
-    @@matches.each_with_index do |token_match, index|
+    @matches.each_with_index do |token_match, index|
       re, lex_method, tok_class = token_match
       text << "if line.scan(/#{re}/)\n"
       text << "  emit(#{lex_method.to_s}(:#{tok_class.to_s}, line, @io))\n"
@@ -401,62 +108,10 @@
         end
       end
     EOS
-    class_eval(text)
+    target_class.class_eval(text)
   end
 
-  self.build_lexer
-
-  public
-  def emit(token)
-    @tokens << token
-  end
-
-  def parse_error(text)
-    raise "#{@io.lineno}:no lexigraphic match for text starting '#{text}'"
-  end
-  def warn(message)
-    $stderr.puts(message)
-  end
 end
 
-
-class SkipASLexer
-  def initialize(lexer)
-    @lex = lexer
-    @handler = nil
-  end
-
-  def handler=(handler)
-    @handler = handler
-  end
-
-  def get_next
-    while skip?(tok=@lex.get_next)
-      notify(tok)
-    end
-    tok
-  end
-
-  def peek_next
-    while skip?(tok=@lex.peek_next)
-      notify(tok)
-      @lex.get_next
-    end
-    tok
-  end
-
-  protected
-
-  def skip?(tok)
-    tok.is_a?(CommentToken) || tok.is_a?(WhitespaceToken)
-  end
-
-  def notify(tok)
-    unless @handler.nil?
-      @handler.comment(tok.body)
-    end
-  end
-end
-
 end # module Parse
 end # module ActionScript

trunk/as2api
tc_actionscript_lexer.rb 193 -> 194
--- trunk/as2api/tc_actionscript_lexer.rb	2005-07-12 17:16:15 UTC (rev 193)
+++ trunk/as2api/tc_actionscript_lexer.rb	2005-07-12 21:06:32 UTC (rev 194)
@@ -1,5 +1,5 @@
 require 'test/unit'
-require 'parse/lexer'
+require 'parse/aslexer'
 
 class TC_ActionScriptLexer < Test::Unit::TestCase
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 13 16:06:23 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 13 Jul 2005 16:06:23 +0000 Subject: [as2api-dev] [CVS trunk] Another feature it might be interesting to implement at some point Message-ID:
Commit in trunk/as2api on MAIN
TODO+2194 -> 195
Another feature it might be interesting to implement at some point

trunk/as2api
TODO 194 -> 195
--- trunk/as2api/TODO	2005-07-12 21:06:32 UTC (rev 194)
+++ trunk/as2api/TODO	2005-07-13 16:06:22 UTC (rev 195)
@@ -31,3 +31,5 @@
 
  - Handling of hex integer constants appears to be broken -- '0xff' gets
    treated as IntegerToken<0>, IdentifierToken<xff> (I think).
+
+ - API changes a la http://www.jdiff.org/
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 13 17:09:59 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 13 Jul 2005 17:09:59 +0000 Subject: [as2api-dev] [CVS trunk] point require statement at the correct file Message-ID:
Commit in trunk/as2api on MAIN
tc_actionscript_parser.rb+1-1195 -> 196
point require statement at the correct file

trunk/as2api
tc_actionscript_parser.rb 195 -> 196
--- trunk/as2api/tc_actionscript_parser.rb	2005-07-13 16:06:22 UTC (rev 195)
+++ trunk/as2api/tc_actionscript_parser.rb	2005-07-13 17:09:58 UTC (rev 196)
@@ -1,5 +1,5 @@
 require 'test/unit'
-require 'parse/lexer'
+require 'parse/aslexer'
 require 'parse/parser'
 
 class TC_ActionScriptParser < Test::Unit::TestCase
CVSspam 0.2.11
From armand at media-division.com Wed Jul 13 15:57:08 2005 From: armand at media-division.com (Armand Niculescu) Date: Wed, 13 Jul 2005 18:57:08 +0300 Subject: [as2api-dev] Re: AS2API command line & GUI issues In-Reply-To: <20050712093530.GB29013@vhost.badgers-in-foil.co.uk> References: <42D2154D.9020105@media-division.com> <20050712093530.GB29013@vhost.badgers-in-foil.co.uk> Message-ID: <42D539D4.1040301@media-division.com> >I attach an updated windows .exe version that produces more debugging >info, and contains a bugfix which might effect the classpath searching >code in some cases. > > The new windows compiled file seems to work perfectly with default classpath as well as with specified classpaths. It also shows an error when the classpath does not match the package structure, so I think this problem is solved. I did encounter however another bug: it seems it does not like the 'import' keyword, e.g.: import md.utils.Validate class md.components.myComp { ... the above structure makes AS2API to skip the class file. Armand From dave at badgers-in-foil.co.uk Wed Jul 13 18:53:44 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 13 Jul 2005 18:53:44 +0000 Subject: [as2api-dev] Re: AS2API command line & GUI issues In-Reply-To: <42D539D4.1040301@media-division.com> References: <42D2154D.9020105@media-division.com> <20050712093530.GB29013@vhost.badgers-in-foil.co.uk> <42D539D4.1040301@media-division.com> Message-ID: <20050713185344.GA27569@vhost.badgers-in-foil.co.uk> On Wed, Jul 13, 2005 at 06:57:08PM +0300, Armand Niculescu wrote: > The new windows compiled file seems to work perfectly with default > classpath as well as with specified classpaths. It also shows an error > when the classpath does not match the package structure, so I think > this problem is solved. Great! Thanks for letting me know. > it seems it does not like the 'import' keyword, e.g.: > > import md.utils.Validate > class md.components.myComp > { > ... > > the above structure makes AS2API to skip the class file. I have several examples of files that have working imports. Is there any error message mentioning this file in the output sent to your console window? Does it help if you add a semicolon to the end of the import statement? dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Wed Jul 13 22:41:33 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 13 Jul 2005 22:41:33 +0000 Subject: [as2api-dev] [CVS trunk] Move class ASToken into the general instrastructure Message-ID:
Commit in trunk/as2api/parse on MAIN
aslexer.rb-18196 -> 197
lexer.rb+18196 -> 197
+18-18
2 modified files
Move class ASToken into the general instrastructure

trunk/as2api/parse
aslexer.rb 196 -> 197
--- trunk/as2api/parse/aslexer.rb	2005-07-13 17:09:58 UTC (rev 196)
+++ trunk/as2api/parse/aslexer.rb	2005-07-13 22:41:31 UTC (rev 197)
@@ -4,24 +4,6 @@
 module ActionScript
 module Parse
 
-# TODO Create an EOFToken (so that we can report its line number)
-
-class ASToken
-  def initialize(body, lineno)
-    @body = body
-    @lineno = lineno
-  end
-  def body
-    @body
-  end
-  def lineno
-    @lineno
-  end
-  def to_s
-    @body
-  end
-end
-
 class CommentToken < ASToken
 end
 

CVSspam 0.2.11
From Gaspy Thu Jul 14 09:58:54 2005 From: Gaspy (Gaspy) Date: Thu, 14 Jul 2005 12:58:54 +0300 Subject: [as2api-dev] Re: as2api-dev digest, Vol 1 #88 - 6 msgs In-Reply-To: <20050714001943.432.28605.Mailman@vhost.badgers-in-foil.co.uk> References: <20050714001943.432.28605.Mailman@vhost.badgers-in-foil.co.uk> Message-ID: <5a0e474805071402586992bf0a@mail.gmail.com> ------=_Part_855_15429804.1121335134022 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Dave, >=20 > I have several examples of files that have working imports. yes, I too have other cases where import works. Upon investigation it seems that if there are [ ] metatags just above the= =20 import statement, as2api produces the error. Such metatags are like [IconFile("icon_checkbox.png")] [Event("onChange")] Is there any error message mentioning this file in the output sent to > your console window? This is the trace (not sure if all of it is relevant): md/components/Textfield.as: Expected , or ,= =20 but found # ./parse/parser.rb:440:in `err' ./parse/parser.rb:95:in `parse_type_definition' ./parse/parser.rb:54:in `parse_compilation_unit' ./api_loader.rb:18:in `simple_parse' ./ui/cli.rb:160:in `parse_file' ./ui/cli.rb:157:in `open' ./ui/cli.rb:157:in `parse_file' ./ui/cli.rb:176:in `parse_all' ./ui/cli.rb:174:in `each_with_index' ./ui/cli.rb:174:in `each' ./ui/cli.rb:174:in `each_with_index' ./ui/cli.rb:174:in `parse_all' ./ui/cli.rb:173:in `parsing_sources' ./ui/cli.rb:173:in `parse_all' ./ui/cli.rb:186:in `main' ./ui/cli.rb:237 as2api.rb:3:in `require' as2api.rb:3 Does it help if you add a semicolon to the end of the import statement? no. I will make more tests if needed, just let me know ------=_Part_855_15429804.1121335134022 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi Dave,

I have severa= l examples of files that have working imports.


yes, I too have other cases where import works.
Upon investigation it seems that if there are [ ] metatags just above the import statement, as2api produces the error. Such metatags are like
[IconFile("icon_checkbox.png")]
[Event("onChange")]

Is there any erro= r message mentioning this file in the output sent to
your console window= ?

This is the trace  (not sure if all of it is relevant):
md/components/Textfield.as: Expected <class>, <interface> or <intrinsic>, but found #<ActionScript::Parse::ImportToken:0x2b18f40 @lineno=3D33, @body=3D"import">
./parse/parser.rb:440:in `err'
./parse/parser.rb:95:in `parse_type_definition'
./parse/parser.rb:54:in `parse_compilation_unit'
./api_loader.rb:18:in `simple_parse'
./ui/cli.rb:160:in `parse_file'
./ui/cli.rb:157:in `open'
./ui/cli.rb:157:in `parse_file'
./ui/cli.rb:176:in `parse_all'
./ui/cli.rb:174:in `each_with_index'
./ui/cli.rb:174:in `each'
./ui/cli.rb:174:in `each_with_index'
./ui/cli.rb:174:in `parse_all'
./ui/cli.rb:173:in `parsing_sources'
./ui/cli.rb:173:in `parse_all'
./ui/cli.rb:186:in `main'
./ui/cli.rb:237
as2api.rb:3:in `require'
as2api.rb:3

Does it help if y= ou add a semicolon to the end of the import statement?

no.

I will make more tests if needed, just let me know

------=_Part_855_15429804.1121335134022-- From dave at badgers-in-foil.co.uk Thu Jul 14 11:46:41 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Thu, 14 Jul 2005 11:46:41 +0000 Subject: [as2api-dev] Re: as2api-dev digest, Vol 1 #88 - 6 msgs In-Reply-To: <5a0e474805071402586992bf0a@mail.gmail.com> References: <20050714001943.432.28605.Mailman@vhost.badgers-in-foil.co.uk> <5a0e474805071402586992bf0a@mail.gmail.com> Message-ID: <20050714114641.GA11474@vhost.badgers-in-foil.co.uk> On Thu, Jul 14, 2005 at 12:58:54PM +0300, Gaspy wrote: > Hi Dave, > > > I have several examples of files that have working imports. > > yes, I too have other cases where import works. > Upon investigation it seems that if there are [ ] metatags just above the > import statement, as2api produces the error. Such metatags are like > [IconFile("icon_checkbox.png")] > [Event("onChange")] Ah, I see. The current parser only allows these attributes to appear immediately preceeding the type definition. I guess they need to be allowed before the import statements too, but do you know if they should be allowed to appear interspersed within the import list? I suspect that they should be allowed there. dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Thu Jul 14 12:16:16 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Thu, 14 Jul 2005 12:16:16 +0000 Subject: [as2api-dev] [CVS trunk] Ruby inherantly provides a proper String IO implementation, these days Message-ID:
Commit in trunk/as2api on MAIN
tc_actionscript_parser.rb+2-23197 -> 198
Ruby inherantly provides a proper String IO implementation, these days

trunk/as2api
tc_actionscript_parser.rb 197 -> 198
--- trunk/as2api/tc_actionscript_parser.rb	2005-07-13 22:41:31 UTC (rev 197)
+++ trunk/as2api/tc_actionscript_parser.rb	2005-07-14 12:16:15 UTC (rev 198)
@@ -1,6 +1,7 @@
 require 'test/unit'
 require 'parse/aslexer'
 require 'parse/parser'
+require 'stringio'
 
 class TC_ActionScriptParser < Test::Unit::TestCase
 
@@ -61,7 +62,7 @@
 
  private
   def simple_parse(text)
-    input = StrIO.new(text)
+    input = StringIO.new(text)
     lex = SkipASLexer.new(ASLexer.new(input))
     parse = ASParser.new(lex)
     parse.handler = ASHandler.new
@@ -69,25 +70,3 @@
     assert_nil(lex.get_next)
   end
 end
-
-# Simple IO-like object the readsfrom a String, rather than a file
-# TODO: handle multiple lines
-class StrIO
-  def initialize(data)
-    @data = data
-  end
-
-  def readline
-    dat = @data
-    @data = nil
-    dat
-  end
-
-  def eof?
-    @data.nil?
-  end
-
-  def lineno
-    1
-  end
-end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Thu Jul 14 12:22:52 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Thu, 14 Jul 2005 12:22:52 +0000 Subject: [as2api-dev] [CVS trunk] Allow a mixture of imports and attributes at the start of a file. Message-ID:
Commit in trunk/as2api on MAIN
parse/parser.rb+10-5198 -> 199
tc_actionscript_parser.rb+6198 -> 199
+16-5
2 modified files
Allow a mixture of imports and attributes at the start of a file.
Previously, attributes were only allowed just before the type definition (i.e.
after the end of any list of import statements).

trunk/as2api/parse
parser.rb 198 -> 199
--- trunk/as2api/parse/parser.rb	2005-07-14 12:16:15 UTC (rev 198)
+++ trunk/as2api/parse/parser.rb	2005-07-14 12:22:50 UTC (rev 199)
@@ -50,15 +50,21 @@
 
   def parse_compilation_unit
     @handler.compilation_unit_start
-    parse_imports
+    parse_imports_and_attributes
     parse_type_definition
     @handler.compilation_unit_end
   end
 
 
-  def parse_imports
-    while lookahead?(ImportToken)
-      parse_import
+  def parse_imports_and_attributes
+    while true
+      if lookahead?(ImportToken)
+        parse_import
+      elsif lookahead?(LBracketToken)
+	eat_attribute
+      else
+	break
+      end
     end
   end
 
@@ -86,7 +92,6 @@
   end
 
   def parse_type_definition
-    parse_attribute_list
     if lookahead?(ClassToken) || lookahead?(DynamicToken) || lookahead?(IntrinsicToken)
       type = parse_class_or_intrinsic_definition
     elsif lookahead?(InterfaceToken)

trunk/as2api
tc_actionscript_parser.rb 198 -> 199
--- trunk/as2api/tc_actionscript_parser.rb	2005-07-14 12:16:15 UTC (rev 198)
+++ trunk/as2api/tc_actionscript_parser.rb	2005-07-14 12:22:50 UTC (rev 199)
@@ -13,6 +13,12 @@
     end
   end
 
+  def test_imports_and_attributes
+    simple_parse("[foo=bar]\nimport foo;[bar=foo]\nclass Foo {}") do |parse|
+      parse.parse_compilation_unit
+    end
+  end
+
   def test_access_modifier
     simple_parse("") do |parse|
       access = parse.parse_access_modifier
CVSspam 0.2.11
From Gaspy Fri Jul 15 14:25:59 2005 From: Gaspy (Gaspy) Date: Fri, 15 Jul 2005 17:25:59 +0300 Subject: [as2api-dev] Metatags and a couple of suggestions In-Reply-To: <20050715001945.24187.53593.Mailman@vhost.badgers-in-foil.co.uk> References: <20050715001945.24187.53593.Mailman@vhost.badgers-in-foil.co.uk> Message-ID: <5a0e474805071507253b3e016@mail.gmail.com> ------=_Part_1568_22723572.1121437559796 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline >=20 >=20 > Ah, I see. The current parser only allows these attributes to appear > immediately preceeding the type definition. >=20 > I guess they need to be allowed before the import statements too, but do > you know if they should be allowed to appear interspersed within the > import list? I suspect that they should be allowed there. >=20 >=20 Dave, yes, I moved the import list above the metatags and it works now. I think the parser shoud work regardless of the position of the metatags... I also noted a few things I want to comment on: 1. If a class declares a method to be public and then a descendant class=20 overrides that method and makes it private, as2doc will still create the=20 documentation for the private method, copying it from the super class. Now,= =20 I realize this may not be the best practice, but sometimes it's needed. 2. It may be useful sometimes to copy definitions for inherited=20 methods/properties rather than linking to them. This could be achieved via = a=20 command line switch. If class D inherits from C, which inherits from B,=20 which inherits from A, I'd prefer to have the methods for class D in one=20 page so I can print it, rather than having to check three other classes. To= =20 use the MX2004 components as an example, we have UIObject --> UIComponent= =20 --> SimpleButton --> Button. The documentation for Button should contain=20 everything, as very few people will dig... What do you think? Armand ------=_Part_1568_22723572.1121437559796 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

Ah, I se= e.  The current parser only allows these attributes to appear
= immediately preceeding the type definition.

I guess they need to be allowed before the import statements too, b= ut do
you know if they should be allowed to appear interspersed within t= he
import list?  I suspect that they should be allowed there.<= br>

Dave, yes, I moved the import list above the metatags and it works now.

I think the parser shoud work regardless of the position of the metatags...=

I also noted a few things I want to comment on:

1. If a class declares a method to be public and then a descendant class overrides that method and makes it private, as2doc will still create the documentation for the private method, copying it from the super class. Now, I realize this may not be the best practice, but sometimes it's needed.

2. It may be useful sometimes to copy definitions for inherited methods/properties rather than linking to them. This could be achieved via a command line switch. If class D inherits from C, which inherits from B, which inherits from A, I'd prefer to have the methods for class D in one page so I can print it, rather than having to check three other classes. To use the MX2004 components as an example, we have UIObject --> UIComponent --> SimpleButton --> Button. The documentation for Button should contain everything, as very few people will dig...

What do you think?

Armand
------=_Part_1568_22723572.1121437559796-- From dave at badgers-in-foil.co.uk Fri Jul 15 16:06:45 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 15 Jul 2005 16:06:45 +0000 Subject: [as2api-dev] Metatags and a couple of suggestions In-Reply-To: <5a0e474805071507253b3e016@mail.gmail.com> References: <20050715001945.24187.53593.Mailman@vhost.badgers-in-foil.co.uk> <5a0e474805071507253b3e016@mail.gmail.com> Message-ID: <20050715160644.GE1912@vhost.badgers-in-foil.co.uk> On Fri, Jul 15, 2005 at 05:25:59PM +0300, Gaspy wrote: > > Ah, I see. The current parser only allows these attributes to appear > > immediately preceeding the type definition. > > > > I guess they need to be allowed before the import statements too, but do > > you know if they should be allowed to appear interspersed within the > > import list? I suspect that they should be allowed there. > > > Dave, yes, I moved the import list above the metatags and it works now. > > I think the parser shoud work regardless of the position of the metatags... I've commited a change which should fix this (I hope). > I also noted a few things I want to comment on: > > 1. If a class declares a method to be public and then a descendant class > overrides that method and makes it private, as2doc will still create the > documentation for the private method, copying it from the super class. Now, > I realize this may not be the best practice, but sometimes it's needed. Can you actually call the now-private method in that case? In my opinion, private methods are not part of the API, so they should not be documented. In this edge-case, I'm not sure what the status of the method is. (I'm ignorant about lots of fiddly ActionScript details like this -- please tell me The Way It Is ;) > 2. It may be useful sometimes to copy definitions for inherited > methods/properties rather than linking to them. This could be achieved via a > command line switch. If class D inherits from C, which inherits from B, > which inherits from A, I'd prefer to have the methods for class D in one > page so I can print it, rather than having to check three other classes. To > use the MX2004 components as an example, we have UIObject --> UIComponent > --> SimpleButton --> Button. The documentation for Button should contain > everything, as very few people will dig... There's a balance to be made between, - Learning the API of the class in front of us right now - Learning the API of the *system* as a whole While 'flattening' the API documentation as you suggest will make the former task easier, I think it will be bad for the second task. Developers using your API should be encouraged to learn that; to know a class, you must also know its superclasses. This involves a little more upfront effort, but will be a saving in the long run, as that effort will be shared for all the other subclasses. On the other hand, the current output really isn't designed for print, and will obviously be deficient without hyperlinks, etc. The real solution to this problem might therefore be to create another, print-specific output format, with cross-references to page numbers etc. What do you think? dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Fri Jul 15 22:05:09 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 15 Jul 2005 22:05:09 +0000 Subject: [as2api-dev] [CVS trunk] Yet another doc comment parser. We are now on rebuild-from-scratch number 3. Message-ID:
Commit in trunk/as2api on MAIN
parse/doccomment_lexer.rb+74added 200
     /doccomment_parser.rb+150added 200
tc_doc_comment.rb+12199 -> 200
+236
2 added + 1 modified, total 3 files
Yet another doc comment parser.  We are now on rebuild-from-scratch number 3.

This new code has the advantage that inline tags may now span lines and can
contain nested braces.

trunk/as2api/parse
doccomment_lexer.rb added at 200
--- trunk/as2api/parse/doccomment_lexer.rb	2005-07-14 12:22:50 UTC (rev 199)
+++ trunk/as2api/parse/doccomment_lexer.rb	2005-07-15 22:05:05 UTC (rev 200)
@@ -0,0 +1,74 @@
+
+require 'parse/lexer'
+
+module ActionScript
+module Parse
+
+class DocWhitespaceToken < ASToken
+end
+
+class EndOfLineToken < ASToken
+end
+
+class StarsToken < ASToken
+end
+
+class ParaAtTagToken < ASToken
+  def to_s
+    "@#{@body}"
+  end
+end
+
+class InlineAtTagToken < ASToken
+  def to_s
+    "{@#{@body}"
+  end
+end
+
+class WordToken < ASToken
+end
+
+class DocCommentLexer < AbstractLexer
+  def lex_simple_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(io.lineno)
+  end
+
+  def lex_simplebody_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
+  end
+
+  def lex_simplecapture_token(class_sym, match, io)
+    ActionScript::Parse.const_get(class_sym).new(match[1], io.lineno)
+  end
+end
+
+END_OF_LINE = "\r\n|\r|\n"
+DOC_WHITESPACE = "[ \t\f]"
+AT_INLINE_TAG = "\\{@([^ \t\r\n\f}{]+)"
+AT_PARA_TAG = "@([^ \t\r\n\f]+)"
+WHITESPACE_THEN_STARS = "[ \t]*\\*+"
+WORD = "[^ \t\f\n\r}{]+"
+
+def self.build_doc_lexer
+  builder = LexerBuilder.new
+
+  builder.add_match(WHITESPACE_THEN_STARS, :lex_simplebody_token, :StarsToken)
+  builder.add_match(DOC_WHITESPACE, :lex_simplebody_token, :DocWhitespaceToken)
+  builder.add_match(END_OF_LINE, :lex_simplebody_token, :EndOfLineToken)
+
+  builder.add_match(AT_INLINE_TAG, :lex_simplecapture_token, :InlineAtTagToken)
+  builder.add_match(AT_PARA_TAG, :lex_simplecapture_token, :ParaAtTagToken)
+
+  builder.make_punctuation_token(:LBrace, "{")
+  builder.make_punctuation_token(:RBrace, "}")
+
+  builder.add_match(WORD, :lex_simplebody_token, :WordToken)
+
+  builder.build_lexer(DocCommentLexer)
+end
+
+build_doc_lexer
+
+
+end
+end

trunk/as2api/parse
doccomment_parser.rb added at 200
--- trunk/as2api/parse/doccomment_parser.rb	2005-07-14 12:22:50 UTC (rev 199)
+++ trunk/as2api/parse/doccomment_parser.rb	2005-07-15 22:05:05 UTC (rev 200)
@@ -0,0 +1,150 @@
+
+module ActionScript
+module Parse
+
+
+
+class DocCommentParser
+
+  def initialize(lexer)
+    @lex = lexer
+    @handler = nil
+  end
+
+  def handler=(handler)
+    @handler = handler
+  end
+
+  # this is the main parser entry-point
+  def parse_comment
+    @handler.comment_start(@lex.peek_next.lineno)
+    while @lex.peek_next
+      parse_line
+    end
+    @handler.comment_end
+  end
+
+  def parse_line
+    maybe_skip(StarsToken)
+    parse_whitespace
+    if lookahead?(ParaAtTagToken)
+      @handler.start_paragraph_tag(expect(ParaAtTagToken))
+    end
+    until lookahead?(EndOfLineToken) || eof?
+      if lookahead?(InlineAtTagToken)
+	parse_inline_tag
+      else
+	eat_text_token
+      end
+    end
+    unless eof?
+      eat_text_token_of_kind(EndOfLineToken)
+    end
+  end
+
+  def parse_whitespace
+    if lookahead?(DocWhitespaceToken)
+      eat_text_token_of_kind(DocWhitespaceToken)
+    end
+  end
+
+  def parse_inline_tag
+    tok = expect(InlineAtTagToken)
+    @handler.start_inline_tag(tok)
+    until lookahead?(RBraceToken)
+      err("end of input before closing brace for #{tok.inspect}") if eof?
+      if lookahead?(LBraceToken)
+	parse_brace_pair
+      elsif lookahead?(EndOfLineToken)
+	eat_text_token
+	maybe_skip(StarsToken)
+      else
+	eat_text_token
+      end
+    end
+    expect(RBraceToken)
+    @handler.end_inline_tag
+  end
+
+  def parse_brace_pair
+    eat_text_token_of_kind(LBraceToken)
+    until lookahead?(RBraceToken) || eof?
+      if lookahead?(LBraceToken)
+	parse_brace_pair
+      elsif lookahead?(EndOfLineToken)
+	eat_text_token
+	maybe_skip(StarsToken)
+      else
+	eat_text_token
+      end
+    end
+    eat_text_token_of_kind(RBraceToken)
+  end
+
+  # treats the text token, whatever kind it may be, as text without special
+  # meaning
+  def eat_text_token
+    @handler.text(@lex.get_next)
+  end
+
+  def eat_text_token_of_kind(kind)
+    @handler.text(expect(kind))
+  end
+
+ private
+  def expect(kind)
+    tok = @lex.get_next
+    unless tok.is_a?(kind)
+      err("Expected '#{kind}' but found '#{tok.inspect}'");
+    end
+    tok
+  end
+
+  def eof?
+    @lex.peek_next.nil?
+  end
+
+  def lookahead?(kind)
+    @lex.peek_next.is_a?(kind)
+  end
+
+  def lookaheads?(*kinds)
+    tnext = @lex.peek_next
+    kinds.each do |kind|
+      return true if tnext.is_a?(kind)
+    end
+    false
+  end
+
+  def speculate(kind)
+    if lookahead?(kind)
+      expect(kind)
+      yield
+    end
+  end
+
+  def maybe_skip(kind)
+    if lookahead?(kind)
+      expect(kind)
+    end
+  end
+
+  def err(msg)
+    raise msg
+  end
+
+end
+
+
+class DocCommentHandler
+  def comment_start(lineno); end
+  def comment_end; end
+  def text(text); end
+  def start_paragraph_tag(tag); end
+  def start_inline_tag(tag); end
+  def end_inline_tag; end
+end
+
+
+end # module Parse
+end # module ActionScript

trunk/as2api
tc_doc_comment.rb 199 -> 200
--- trunk/as2api/tc_doc_comment.rb	2005-07-14 12:22:50 UTC (rev 199)
+++ trunk/as2api/tc_doc_comment.rb	2005-07-15 22:05:05 UTC (rev 200)
@@ -45,4 +45,16 @@
     doc.parse(text)
     assert("blat\nping", doc.describe_exception("foo.Bar"))
   end
+
+  def test_package_html
+    [
+      "<html><body>test</body></html>",
+      "<body>te<b>st</b></body>"
+    ].each do |text|
+      PackageHTML.process(text) do |element|
+	a = REXML::XPath.match(element, "descendant::text()").join
+        assert_equal("test", a)
+      end
+    end
+  end
 end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Fri Jul 15 22:06:22 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Fri, 15 Jul 2005 22:06:22 +0000 Subject: [as2api-dev] [CVS trunk] Beat doc_comment.rb until the new comment parser code fits. Message-ID:
Commit in trunk/as2api on MAIN
api_loader.rb+22-13200 -> 201
doc_comment.rb+124-125200 -> 201
+146-138
2 modified files
Beat doc_comment.rb until the new comment parser code fits.

Kinda ugly, but seems to work.

trunk/as2api
api_loader.rb 200 -> 201
--- trunk/as2api/api_loader.rb	2005-07-15 22:05:05 UTC (rev 200)
+++ trunk/as2api/api_loader.rb	2005-07-15 22:06:20 UTC (rev 201)
@@ -3,6 +3,8 @@
 require 'parse/parser'
 require 'api_model'
 require 'doc_comment'
+require 'parse/doccomment_lexer'
+require 'stringio'
 
 # We used to just define the class again to add this attribute, but I want
 # to be compatable with Ruby1.6, which doesn' allow 'class ModName::ClassName'
@@ -100,9 +102,9 @@
 class DocASHandler < ActionScript::Parse::ASHandler
   def initialize
     parse_conf_build = ConfigBuilder.new
-    @method_comment_parser = DocCommentParser.new(parse_conf_build.build_method_config)
-    @field_comment_parser = DocCommentParser.new(parse_conf_build.build_field_config)
-    @type_comment_parser = DocCommentParser.new(parse_conf_build.build_type_config)
+    @method_comment_config = parse_conf_build.build_method_config
+    @field_comment_config = parse_conf_build.build_field_config
+    @type_comment_config = parse_conf_build.build_type_config
   end
 
   def compilation_unit_start
@@ -124,8 +126,7 @@
     @defined_type = ASClass.new(name)
     @type_resolver = LocalTypeResolver.new(@defined_type)
     if @doc_comment
-      input = create_comment_parser_input(@doc_comment)
-      @defined_type.comment = @type_comment_parser.parse(input)
+      @defined_type.comment = parse_comment(@type_comment_config, @doc_comment)
     end
     @defined_type.dynamic = dynamic
     if super_name
@@ -149,8 +150,7 @@
     @defined_type = ASInterface.new(name)
     @type_resolver = LocalTypeResolver.new(@defined_type)
     if @doc_comment
-      input = create_comment_parser_input(@doc_comment)
-      @defined_type.comment = @type_comment_parser.parse(input)
+      @defined_type.comment = parse_comment(@type_comment_config, @doc_comment)
     end
     if super_name
       @defined_type.extends = @type_resolver.resolve(super_name)
@@ -181,8 +181,7 @@
       field.field_type = @type_resolver.resolve(type)
     end
     if @doc_comment
-      input = create_comment_parser_input(@doc_comment)
-      field.comment = @field_comment_parser.parse(input)
+      field.comment = parse_comment(@field_comment_config, @doc_comment)
     end
     @defined_type.add_field(field)
   end
@@ -218,8 +217,7 @@
       method.add_arg(argument)
     end
     if @doc_comment
-      input = create_comment_parser_input(@doc_comment)
-      method.comment = @method_comment_parser.parse(input)
+      method.comment = parse_comment(@method_comment_config, @doc_comment)
     end
     method
   end
@@ -249,8 +247,19 @@
     end
   end
 
-  def create_comment_parser_input(comment_token)
-    CommentInput.new(comment_token.body, comment_token.lineno, @type_resolver)
+  def parse_comment(config, comment_token)
+    comment_data = CommentData.new
+
+    input = StringIO.new(comment_token.body)
+    input.lineno = comment_token.lineno
+    lexer = ActionScript::Parse::DocCommentLexer.new(input)
+    parser = ActionScript::Parse::DocCommentParser.new(lexer)
+    handler = OurDocCommentHandler.new(comment_data, config, @type_resolver)
+    parser.handler = handler
+
+    parser.parse_comment
+
+    comment_data
   end
 end
 

trunk/as2api
doc_comment.rb 200 -> 201
--- trunk/as2api/doc_comment.rb	2005-07-15 22:05:05 UTC (rev 200)
+++ trunk/as2api/doc_comment.rb	2005-07-15 22:06:20 UTC (rev 201)
@@ -1,54 +1,6 @@
 
-class CommentInput
-  def initialize(text, lineno, type_resolver)
-    @text = text
-    @lineno = lineno
-    @type_resolver = type_resolver
-  end
+require 'parse/doccomment_parser'
 
-  attr_accessor :text, :lineno, :type_resolver
-
-  def derive(text, lineno=nil)
-    lineno = @lineno if lineno.nil?
-    return CommentInput.new(text, lineno, @type_resolver)
-  end
-end
-
-
-class DocCommentParser
-  def initialize(config)
-    @config = config
-  end
-
-  def parse(input)
-    data = CommentData.new
-    @config.begin_comment(data)
-    lineno = input.lineno
-    input.text.scan(/[^\n\r]*(?:\n\r|\n|\r)?/) do |text|
-      parse_line(input.derive(strip_stars(text), lineno))
-      lineno += 1
-    end
-    @config.end_comment
-    return data
-  end
-
-  private
-
-  def strip_stars(text)
-    text.sub(/\A\s*\**/, "").sub(/[ \t]*\Z/, "")
-  end
-
-  def parse_line(input)
-    if input.text =~ /^\s*@([a-zA-Z]+)\s*/
-      @config.begin_block($1)
-      @config.parse(input.derive($'))
-    else
-      @config.parse(input)
-    end
-  end
-end
-
-
 class CommentData
   def initialize
     @blocks = []
@@ -69,64 +21,87 @@
   end
 end
 
-
-class DocCommentParserConfig
-  def initialize
-    @block_handlers = {}
-  end
-
-  def begin_comment(comment_data)
+class OurDocCommentHandler < ActionScript::Parse::DocCommentHandler
+  def initialize(comment_data, handler_config, type_resolver)
     @comment_data = comment_data
-    @block = @description_block_handler
-    beginning_of_block
+    @handler_config = handler_config
+    @type_resolver = type_resolver
   end
 
-  def add_block_parser(name, handler)
-    @block_handlers[name] = handler
-    handler.handler = self
+  def comment_start(lineno)
+    @block_handler = @handler_config.initial_block_handler
+    @inline_handler = nil
+    beginning_of_block(lineno)
   end
 
-  def description_handler=(handler)
-    @description_block_handler = handler
+  def comment_end
+    end_of_block
   end
 
-  def end_comment
-    end_of_block
+  def text(text)
+    if @inline_handler
+      @inline_handler.text(text)
+    else
+      @block_handler.text(text)
+    end
   end
 
-  def begin_block(kind)
+  def start_paragraph_tag(tag)
     end_of_block
-    @block = handler_for(kind)
-    beginning_of_block
+    @block_handler = @handler_config.handler_for(tag)
+    beginning_of_block(tag.lineno)
   end
 
-  def parse(text)
-    @block.parse_line(text)
+  def start_inline_tag(tag)
+    @inline_handler = @block_handler.handler_for(tag)
+    @inline_handler.start(@type_resolver, tag.lineno)
   end
 
-  def parse_error(msg)
-    $stderr.puts(msg)
+  def end_inline_tag
+    @block_handler.add_inline(@inline_handler.end)
+    @inline_handler = nil
   end
 
   private
 
+  def beginning_of_block(lineno)
+    @block_handler.begin_block(@type_resolver, lineno)
+  end
+
+  def end_of_block
+    block = @block_handler.end_block
+    @comment_data.add_block(block) unless block.nil?
+  end
+end
+
+class DocCommentParserConfig
+  def initialize
+    @initial_block_handler = nil
+    @block_handlers = {}
+  end
+
+  attr_accessor :initial_block_handler
+
+  def add_block_parser(name, handler)
+    @block_handlers[name] = handler
+    handler.handler = self
+  end
+
   def handler_for(kind)
-    handler = @block_handlers[kind]
+    handler = @block_handlers[kind.body]
     if handler.nil?
-      parse_error("Unknown block tag @#{kind}")
+      parse_error("#{kind.lineno}: Unknown block tag @#{kind.body}")
       handler = NIL_HANDLER
     end
     handler
   end
 
-  def beginning_of_block
-    @block.begin_block
-  end
+  private
 
-  def end_of_block
-    data = @block.end_block
-    @comment_data.add_block(data) unless data.nil?
+  def parse_error(msg)
+    $stderr.puts(msg)
   end
+
 end
 
 
@@ -155,7 +130,13 @@
   end
 
   def add_inline(inline)
-    @inlines << inline
+    # coalesce multiple consecutive strings,
+    last_inline = @inlines.last
+    if inline.is_a?(String) && last_inline.is_a?(String)
+      last_inline << inline
+    else
+      @inlines << inline
+    end
   end
 
   def each_inline
@@ -163,6 +144,10 @@
       yield inline
     end
   end
+
+  def inlines
+    @inlines
+  end
 end
 
 
@@ -185,15 +170,21 @@
 
 
 class InlineParser
-  def parse(block_data, inpu)
-    raise "implement me"
+  def start(type_resolver, lineno)
+    @type_resolver = type_resolver
+    @lineno = lineno
+    @text = ""
   end
+
+  def text(text)
+    @text << text.to_s
+  end
 end
 
 
 # creates a LinkTag inline
-def create_link(input)
-  if input.text =~ /^([^\s]+(?:\([^\)]*\))?)\s*/
+def create_link(type_resolver, text, lineno)
+  if text =~ /^\s*([^\s]+(?:\([^\)]*\))?)\s*/
     target = $1
     text = $'
     # TODO: need a MemberProxy (and maybe Method+Field subclasses) with similar
@@ -208,7 +199,7 @@
     if type_name == ""
       type_proxy = nil
     else
-      type_proxy = input.type_resolver.resolve(type_name, input.lineno)
+      type_proxy = type_resolver.resolve(type_name, lineno)
     end
     return LinkTag.new(type_proxy, member_name, text)
   end
@@ -218,21 +209,19 @@
 
 # handle {@link ...} in comments
 class LinkInlineParser < InlineParser
-  def parse(block_data, input)
-    link = create_link(input)
+  def end
+    link = create_link(@type_resolver, @text, @lineno)
     if link.nil?
-      block_data.add_inline("{@link #{input.text}}")
+      "{@link #{@text}}"
     else
-      block_data.add_inline(link)
+      link
     end
   end
 end
 
 # handle {@code ...} in comments
 class CodeInlineParser < InlineParser
-  def parse(block_data, input)
-    block_data.add_inline(CodeTag.new(input.text))
-  end
+  def end; CodeTag.new(@text); end
 end
 
 
@@ -244,7 +233,9 @@
 
   attr_accessor :handler
 
-  def begin_block
+  def begin_block(type_resolver, lineno)
+    @type_resolver = type_resolver
+    @lineno = lineno
   end
 
   def parse_line(text)
@@ -258,6 +249,18 @@
     @inline_parsers[tag_name] = parser
   end
 
+  def handler_for(tag)
+    inline_parser = @inline_parsers[tag.body]
+  end
+
+  def text(text)
+    add_text(text.to_s)
+  end
+
+  def add_inline(tag)
+    @data.add_inline(tag)
+  end
+
   def parse_inlines(input)
     text = input.text
     while text.length > 0
@@ -281,6 +284,7 @@
   end
 
   def add_text(text)
+    raise "#{self.class.name} has no @data" unless @data
     @data.add_inline(text)
   end
 end
@@ -290,7 +294,8 @@
 
 
 class ParamParser < BlockParser
-  def begin_block
+  def begin_block(type_resolver, lineno)
+    super(type_resolver, lineno)
     @data = ParamBlockTag.new
   end
 
@@ -306,23 +311,27 @@
 
 
 class ThrowsParser < BlockParser
-  def begin_block
+  def begin_block(type_resolver, lineno)
+    super(type_resolver, lineno)
     @data = ThrowsBlockTag.new
   end
 
-  def parse_line(input)
-    if @data.exception_type.nil?
-      input.text =~ /\A\s*([^\s]+)\s+/
-      @data.exception_type = input.type_resolver.resolve($1)
-      input = input.derive($')
-    end
-    parse_inlines(input)
+  def end_block
+      first_inline = @data.inlines[0]
+      if first_inline =~ /\A\s*([^\s]+)\s+/
+	@data.inlines[0] = $'
+        @data.exception_type = @type_resolver.resolve($1)
+	@data
+      else
+	nil
+      end
   end
 end
 
 
 class ReturnParser < BlockParser
-  def begin_block
+  def begin_block(type_resolver, lineno)
+    super(type_resolver, lineno)
     @data = ReturnBlockTag.new
   end
   def parse_line(input)
@@ -332,43 +341,33 @@
 
 
 class DescriptionParser < BlockParser
-  def begin_block
+  def begin_block(type_resolver, lineno)
+    super(type_resolver, lineno)
     @data = BlockTag.new
   end
-  def parse_line(input)
-    parse_inlines(input)
-  end
 end
 
 
 class SeeParser < BlockParser
-  def begin_block
-    @data = nil
+  def begin_block(type_resolver, lineno)
+    super(type_resolver, lineno)
+    @data = SeeBlockTag.new
   end
 
-  def parse_line(input)
-    if @data.nil?
-      @data = SeeBlockTag.new
-      input.text =~ /\A\s*/
+  def end_block
+      @data.inlines.first =~ /\A\s*/
       case $'
 	when /['"]/
 	  # plain, 'string'-like see entry
-	  @data.add_inline(input.text)
 	when /</
 	  # HTML entry
-	  @data.add_inline(input.text)
 	else
 	  # 'link' entry
-	  link = create_link(input)
-	  if link.nil?
-	    @data.add_inline(input.text)
-	  else
-	    @data.add_inline(link)
+	  link = create_link(@type_resolver, @data.inlines.first, @lineno)
+	  unless link.nil?
+	    @data.inlines[0] = link
 	  end
       end
-    else
-      @data.add_inline(input.text)
-    end
   end
 end
 
@@ -405,7 +404,7 @@
   end
 
   def add_standard_block_parsers(config)
-    config.description_handler=build_description_block_parser
+    config.initial_block_handler = build_description_block_parser
     config.add_block_parser("see", build_see_block_parser)
   end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 16 12:09:24 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 16 Jul 2005 12:09:24 +0000 Subject: [as2api-dev] [CVS trunk] Have the NIL_HANDLER really ignore input (rather than raising exceptions) Message-ID:
Commit in trunk/as2api on MAIN
doc_comment.rb+4-1201 -> 202
Have the NIL_HANDLER really ignore input (rather than raising exceptions)

trunk/as2api
doc_comment.rb 201 -> 202
--- trunk/as2api/doc_comment.rb	2005-07-15 22:06:20 UTC (rev 201)
+++ trunk/as2api/doc_comment.rb	2005-07-16 12:09:21 UTC (rev 202)
@@ -289,8 +289,11 @@
   end
 end
 
+class NilBlockParser < BlockParser
+  def add_text(text); end
+end
 
-NIL_HANDLER = BlockParser.new
+NIL_HANDLER = NilBlockParser.new
 
 
 class ParamParser < BlockParser
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 16 14:14:50 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat, 16 Jul 2005 14:14:50 +0000 Subject: [as2api-dev] [CVS trunk] Syntax highlighting for {@code ... } tags. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+66-42202 -> 203
Syntax highlighting for {@code ... } tags.

If a {@code} tag spans multiple lines, it will be rendered with <pre> rather
than <code>

trunk/as2api
html_output.rb 202 -> 203
--- trunk/as2api/html_output.rb	2005-07-16 12:09:21 UTC (rev 202)
+++ trunk/as2api/html_output.rb	2005-07-16 14:14:48 UTC (rev 203)
@@ -472,8 +472,17 @@
 	end
       end
     elsif inline.is_a?(CodeTag)
-      html_code do
-	pcdata(inline.text)
+      input = StringIO.new(inline.text)
+      highlight = CodeHighlighter.new
+      highlight.number_lines = false
+      if inline.text =~ /[\n\r]/
+	html_pre do
+	  highlight.highlight(input, self)
+	end
+      else
+	html_code do
+	  highlight.highlight(input, self)
+	end
       end
     else
       html_em(inline.inspect)
@@ -1646,41 +1655,14 @@
   end
 end
 
+class CodeHighlighter
 
-class SourcePage < BasicPage
-
-  def initialize(conf, type)
-    dir = type.package_name.gsub(/\./, "/")
-    super(conf, type.unqualified_name+".as", dir)
-    @type = type
+  def initialize
+    @number_lines = true
   end
 
-  def generate_body_content
-    html_pre do
-      file = @type.input_file
-      parse(File.join(file.prefix, file.suffix))
-    end
-  end
+  attr_accessor :number_lines
 
-  def parse(file)
-    File.open(File.join(file)) do |io|
-      begin
-	is_utf8 = detect_bom?(io)
-	as_io = ASIO.new(io)
-	lex = ActionScript::Parse::SkipASLexer.new(HighlightASLexer.new(self, as_io))
-	parse = HighlightASParser.new(lex)
-	parse.handler = ActionScript::Parse::ASHandler.new
-	parse.parse_compilation_unit
-      rescue =>e
-	$stderr.puts "#{file}: #{e.message}\n#{e.backtrace.join("\n")}"
-      end
-    end
-  end
-
-  class HighlightASParser < ActionScript::Parse::ASParser
-
-  end
-
   Keywords = [
     ActionScript::Parse::AsToken,
     ActionScript::Parse::BreakToken,
@@ -1734,6 +1716,8 @@
       @out = out
     end
 
+    attr_accessor :number_lines
+
     def get_next
       tok = super
       out(tok)
@@ -1741,7 +1725,7 @@
     end
 
     def out(tok)
-      mark_lineno if @lineno == 0
+      mark_lineno if @number_lines && @lineno == 0
       if Keywords.include?(tok.class)
 	pp_tok(tok, "key")
 	return
@@ -1771,15 +1755,19 @@
       end
     end
     def p_tok(tok)
-      txt = StringScanner.new(tok.to_s)
-      until txt.eos?
-	if match = txt.scan_until(/\r\n|\n|\r/)
-	  p_str(match)
-	  mark_lineno
-	else
-	  p_str(txt.rest)
-	  txt.terminate
+      if @number_lines
+	txt = StringScanner.new(tok.to_s)
+	until txt.eos?
+	  if match = txt.scan_until(/\r\n|\n|\r/)
+	    p_str(match)
+	    mark_lineno
+	  else
+	    p_str(txt.rest)
+	    txt.terminate
+	  end
 	end
+      else
+	p_str(tok.to_s)
       end
     end
 
@@ -1795,6 +1783,42 @@
     end
   end
 
+  def highlight(input, output)
+    lex = HighlightASLexer.new(output, input)
+    lex.number_lines = @number_lines
+    while lex.get_next; end
+  end
+end
+
+class SourcePage < BasicPage
+
+  def initialize(conf, type)
+    dir = type.package_name.gsub(/\./, "/")
+    super(conf, type.unqualified_name+".as", dir)
+    @type = type
+  end
+
+  def generate_body_content
+    html_pre do
+      file = @type.input_file
+      parse(File.join(file.prefix, file.suffix))
+    end
+  end
+
+  def parse(file)
+    File.open(File.join(file)) do |io|
+      begin
+	is_utf8 = detect_bom?(io)
+	as_io = ASIO.new(io)
+	highlight = CodeHighlighter.new
+	highlight.highlight(as_io, self)
+      rescue =>e
+	$stderr.puts "#{file}: #{e.message}\n#{e.backtrace.join("\n")}"
+      end
+    end
+  end
+
+
   def navigation
     html_ul("class"=>"main_nav") do
       html_li do
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 17 14:10:17 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 17 Jul 2005 14:10:17 +0000 Subject: [as2api-dev] [CVS trunk] Fix an apparent out-by-one error in line number reporting. Message-ID:
Commit in trunk/as2api/parse on MAIN
aslexer.rb+6-6203 -> 204
doccomment_lexer.rb+3-3203 -> 204
+9-9
2 modified files
Fix an apparent out-by-one error in line number reporting.

We've already read the tokens from the line by the time we inspect io.lineno,
so it's actually reporting the line number for the line _after_ the token
object we're constructing.

trunk/as2api/parse
aslexer.rb 203 -> 204
--- trunk/as2api/parse/aslexer.rb	2005-07-16 14:14:48 UTC (rev 203)
+++ trunk/as2api/parse/aslexer.rb	2005-07-17 14:10:14 UTC (rev 204)
@@ -221,19 +221,19 @@
 
 
   def lex_simple_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(io.lineno)
+    ActionScript::Parse.const_get(class_sym).new(io.lineno-1)
   end
 
   def lex_simplebody_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
+    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno-1)
   end
 
   def lex_singlelinecoomment_token(class_sym, match, io)
-    SingleLineCommentToken.new(match[1], io.lineno)
+    SingleLineCommentToken.new(match[1], io.lineno-1)
   end
 
   def lex_multilinecomment_token(class_sym, match, io)
-    lineno = io.lineno
+    lineno = io.lineno-1
     line = match.post_match
     comment = ''
     until line =~ /\*\//o
@@ -246,7 +246,7 @@
   end
 
   def lex_string1_token(class_sym, match, io)
-    lineno = io.lineno
+    lineno = io.lineno-1
     line = match.post_match
     str = ''
     until line =~ /#{STRING_END1}/o
@@ -260,7 +260,7 @@
   end
 
   def lex_string2_token(class_sym, match, io)
-    lineno = io.lineno
+    lineno = io.lineno-1
     line = match.post_match
     str = ''
     until line =~ /#{STRING_END2}/o

trunk/as2api/parse
doccomment_lexer.rb 203 -> 204
--- trunk/as2api/parse/doccomment_lexer.rb	2005-07-16 14:14:48 UTC (rev 203)
+++ trunk/as2api/parse/doccomment_lexer.rb	2005-07-17 14:10:14 UTC (rev 204)
@@ -30,15 +30,15 @@
 
 class DocCommentLexer < AbstractLexer
   def lex_simple_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(io.lineno)
+    ActionScript::Parse.const_get(class_sym).new(io.lineno-1)
   end
 
   def lex_simplebody_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno)
+    ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno-1)
   end
 
   def lex_simplecapture_token(class_sym, match, io)
-    ActionScript::Parse.const_get(class_sym).new(match[1], io.lineno)
+    ActionScript::Parse.const_get(class_sym).new(match[1], io.lineno-1)
   end
 end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 18 16:18:17 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 18 Jul 2005 16:18:17 +0000 Subject: [as2api-dev] [CVS trunk] Skip sections listing methods / fields if they're going to be empty anyway Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+41-6204 -> 205
Skip sections listing methods / fields if they're going to be empty anyway

trunk/as2api
html_output.rb 204 -> 205
--- trunk/as2api/html_output.rb	2005-07-17 14:10:14 UTC (rev 204)
+++ trunk/as2api/html_output.rb	2005-07-18 16:18:16 UTC (rev 205)
@@ -561,13 +561,31 @@
 	end
       end
       
-      field_index_list(@type) if @type.fields? && @type.inherited_fields?
-      method_index_list(@type) if @type.methods?
+      field_index_list(@type) if has_or_inherits_documentable_fields?(@type)
+      method_index_list(@type) if has_or_inherits_documentable_methods?(@type)
       constructor_detail(@type) if @type.constructor? && document_member?(@type.constructor)
-      field_detail_list(@type) if @type.fields?
-      method_detail_list(@type) if @type.methods?
+      field_detail_list(@type) if has_documentable_fields?(@type)
+      method_detail_list(@type) if has_documentable_methods?(@type)
   end
 
+  def has_or_inherits_documentable_fields?(astype)
+    return true if has_documentable_fields?(astype)
+    astype.each_ancestor do |ancestor|
+      return true if has_documentable_fields?(ancestor)
+    end
+
+    false
+  end
+
+  def has_or_inherits_documentable_methods?(astype)
+    return true if has_documentable_methods?(astype)
+    astype.each_ancestor do |ancestor|
+      return true if has_documentable_methods?(ancestor)
+    end
+
+    false
+  end
+
   def navigation
     html_ul("class"=>"main_nav") do
       html_li do
@@ -618,7 +636,7 @@
       list_fields(type)
       if type.has_ancestor?
 	type.each_ancestor do |type|
-	  if type.fields?
+	  if has_documentable_fields?(type)
 	    html_h4 do
 	      pcdata("Inherited from ")
 	      link_type(type)
@@ -632,6 +650,15 @@
     end
   end
 
+  def has_documentable_fields?(astype)
+    return false if astype.is_a?(ASInterface)
+    astype.each_field do |asfield|
+      return true if document_member?(asfield)
+    end
+
+    false
+  end
+
   def list_fields(type, href_prefix="")
     fields = type.fields.sort
     index = 0
@@ -658,7 +685,7 @@
       list_methods(type, known_method_names)
       if type.has_ancestor?
 	type.each_ancestor do |type|
-	  if type.methods?
+	  if has_documentable_methods?(type)
 	    html_h4 do
 	      pcdata("Inherited from ")
 	      link_type(type)
@@ -672,6 +699,14 @@
     end
   end
 
+  def has_documentable_methods?(astype)
+    astype.methods.each do |asmethod|
+      return true if document_member?(asmethod)
+    end
+
+    false
+  end
+
   def list_methods(type, known_method_names, href_prefix="")
     methods = type.methods.select do |method|
       !known_method_names.include?(method.name) && document_member?(method)
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Mon Jul 18 16:31:53 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Mon, 18 Jul 2005 16:31:53 +0000 Subject: [as2api-dev] [CVS trunk] Ignore overidden methods when working out if a method list will be required Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+3-3205 -> 206
Ignore overidden methods when working out if a method list will be required

trunk/as2api
html_output.rb 205 -> 206
--- trunk/as2api/html_output.rb	2005-07-18 16:18:16 UTC (rev 205)
+++ trunk/as2api/html_output.rb	2005-07-18 16:31:52 UTC (rev 206)
@@ -685,7 +685,7 @@
       list_methods(type, known_method_names)
       if type.has_ancestor?
 	type.each_ancestor do |type|
-	  if has_documentable_methods?(type)
+	  if has_documentable_methods?(type, known_method_names)
 	    html_h4 do
 	      pcdata("Inherited from ")
 	      link_type(type)
@@ -699,9 +699,9 @@
     end
   end
 
-  def has_documentable_methods?(astype)
+  def has_documentable_methods?(astype, ignore_method_names=[])
     astype.methods.each do |asmethod|
-      return true if document_member?(asmethod)
+      return true if document_member?(asmethod) && !ignore_method_names.include?(asmethod.name)
     end
 
     false
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sun Jul 24 22:59:40 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sun, 24 Jul 2005 22:59:40 +0000 Subject: [as2api-dev] [CVS trunk] A small lexer optimisation. Message-ID:
Commit in trunk/as2api/parse on MAIN
aslexer.rb+20-3206 -> 207
lexer.rb+15-1206 -> 207
+35-4
2 modified files
A small lexer optimisation.

Rather than having the lexer scan for every possible keyword token, simply
match all keywords / identifiers with the same rule, and have the lexical
action classify the input when the rule is matched.

This is a seedup because at any point in the input, the number of different
rules we have to test to recognise the next token is quite a lot smaller.
The lexical action can then try to lookup the matched text in a hashtable,
which should be faster that the previous linear search through all the
keyword.

My completely trivial test case went from about 37 seconds to 34 with this
change.

trunk/as2api/parse
aslexer.rb 206 -> 207
--- trunk/as2api/parse/aslexer.rb	2005-07-18 16:31:52 UTC (rev 206)
+++ trunk/as2api/parse/aslexer.rb	2005-07-24 22:59:39 UTC (rev 207)
@@ -219,11 +219,24 @@
 
 class ASLexer < AbstractLexer
 
-
   def lex_simple_token(class_sym, match, io)
     ActionScript::Parse.const_get(class_sym).new(io.lineno-1)
   end
 
+  def lex_key_or_ident_token(match, io)
+    body = match[0]
+    class_sym = @@keyword_tokens[body]
+    if class_sym
+      lex_simple_token(class_sym, match, io)
+    else
+      lex_simplebody_token(:IdentifierToken, match, io)
+    end
+  end
+
+  def self.keyword_tokens=(toks)
+    @@keyword_tokens = toks
+  end
+
   def lex_simplebody_token(class_sym, match, io)
     ActionScript::Parse.const_get(class_sym).new(match[0], io.lineno-1)
   end
@@ -287,15 +300,19 @@
 
   builder.add_match(OMULTI_LINE_COMMENT, :lex_multilinecomment_token, :MultiLineCommentToken)
 
+  keyword_tokens = {}
   Keywords.each do |keyword|
-    builder.make_keyword_token(keyword)
+    builder.create_keytoken_class(keyword)
+    keyword_tokens[keyword] = "#{keyword.capitalize}Token".to_sym
   end
 
+  ASLexer.keyword_tokens = keyword_tokens
+
   Punctuation.each do |punct|
     builder.make_punctuation_token(*punct)
   end
 
-  builder.add_match(IDENT, :lex_simplebody_token, :IdentifierToken)
+  builder.add_match(IDENT, :lex_key_or_ident_token, nil)
 
   builder.add_match(STRING_START1, :lex_string1_token, :StringToken)
 

trunk/as2api/parse
lexer.rb 206 -> 207
--- trunk/as2api/parse/lexer.rb	2005-07-18 16:31:52 UTC (rev 206)
+++ trunk/as2api/parse/lexer.rb	2005-07-24 22:59:39 UTC (rev 207)
@@ -86,6 +86,16 @@
     @matches << [make_match(match), lex_meth_sym, tok_class_sym]
   end
 
+  def create_keytoken_class(name)
+    the_class = Class.new(ASToken)
+    the_class.class_eval <<-EOE
+    def initialize(lineno)
+      super("#{name}", lineno)
+    end
+    EOE
+    ActionScript::Parse.const_set("#{name.capitalize}Token".to_sym, the_class)
+  end
+
   def make_simple_token(name, value, match)
     class_name = "#{name}Token"
     the_class = Class.new(ASToken)
@@ -116,7 +126,11 @@
     @matches.each_with_index do |token_match, index|
       re, lex_method, tok_class = token_match
       text << "if line.scan(/#{re}/)\n"
-      text << "  emit(#{lex_method.to_s}(:#{tok_class.to_s}, line, @io))\n"
+      if tok_class
+      	text << "  emit(#{lex_method.to_s}(:#{tok_class.to_s}, line, @io))\n"
+      else
+      	text << "  emit(#{lex_method.to_s}(line, @io))\n"
+      end
       text << "  next\n"
       text << "end\n"
     end
CVSspam 0.2.11
From caleb at yahoo-inc.com Mon Jul 25 22:11:09 2005 From: caleb at yahoo-inc.com (Caleb) Date: Mon, 25 Jul 2005 15:11:09 -0700 Subject: [as2api-dev] "No source files matching specified packages" Message-ID: <200507252211.j6PMBAtv081484@mrout3.yahoo.com> This is a multi-part message in MIME format. ------=_NextPart_000_002A_01C5912B.16F9D460 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit "No source files matching specified packages" That is the only output I am able to get from as2api Hello, My name is Caleb and I am a software engineer on Yahoo!'s Media Innovation team. I have been trying to use your product, as2api for some time now, and have yet to be able to generate one piece of documentation. I'm specifying a valid classpath, yet it still says "No source files matching specified packages". Even if I don't specifiy a classpath and only specify which packages are to be documented, I get the ambiguous "No source files matching specified packages" error again. I'm using the win32 standalone version. Please, tell me if I should just give up now. Has anyone been able to get it to work? Thank you in advance, Caleb ------=_NextPart_000_002A_01C5912B.16F9D460 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

“No source files matching specified = packages”

 

That is the only output I am able to get from = as2api

 

 

Hello,

 

My name is Caleb and I am a software engineer on = Yahoo!’s Media Innovation team.  I have been trying to use your product, = as2api for some time now, and have yet to be able to generate one piece of = documentation.  I’m specifying a valid classpath, yet it still says “No source files = matching specified packages”.  Even if I don’t specifiy a = classpath and only specify which packages are to be documented, I get the ambiguous = “No source files matching specified packages” error = again.

 

I’m using the win32 standalone = version.

Please, tell me if I should just give up now.  = Has anyone been able to get it to work?

 

 

Thank you in advance,

Caleb

------=_NextPart_000_002A_01C5912B.16F9D460-- From dave at badgers-in-foil.co.uk Tue Jul 26 08:02:36 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 26 Jul 2005 08:02:36 +0000 Subject: [as2api-dev] "No source files matching specified packages" In-Reply-To: <200507252211.j6PMBAtv081484@mrout3.yahoo.com> References: <200507252211.j6PMBAtv081484@mrout3.yahoo.com> Message-ID: <20050726080236.GA6414@vhost.badgers-in-foil.co.uk> On Mon, Jul 25, 2005 at 03:11:09PM -0700, Caleb wrote: > "No source files matching specified packages" > > That is the only output I am able to get from as2api > I'm using the win32 standalone version. > > Please, tell me if I should just give up now. Has anyone been able to get > it to work? I will send you another version of as2api by private mail. Could you give that a try and see if it works (or at least prints a different message), at let us know your results? Thanks for reporting the problem! dave -- http://david.holroyd.me.uk/ From dave at badgers-in-foil.co.uk Tue Jul 26 21:07:46 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 26 Jul 2005 21:07:46 +0000 Subject: [as2api-dev] [CVS trunk] Make line number information available in objects representing javadoc tags Message-ID:
Commit in trunk/as2api on MAIN
doc_comment.rb+31-7207 -> 208
html_output.rb+10-3207 -> 208
+41-10
2 modified files
Make line number information available in objects representing javadoc tags

trunk/as2api
doc_comment.rb 207 -> 208
--- trunk/as2api/doc_comment.rb	2005-07-24 22:59:39 UTC (rev 207)
+++ trunk/as2api/doc_comment.rb	2005-07-26 21:07:43 UTC (rev 208)
@@ -58,7 +58,8 @@
   end
 
   def end_inline_tag
-    @block_handler.add_inline(@inline_handler.end)
+    tag = @inline_handler.end
+    @block_handler.add_inline(tag) if tag
     @inline_handler = nil
   end
 
@@ -105,8 +106,17 @@
 end
 
 
-class LinkTag
-  def initialize(target, member, text)
+class Tag
+  def initialize(lineno)
+    @lineno = lineno
+  end
+
+  attr_accessor :lineno
+end
+
+class LinkTag < Tag
+  def initialize(lineno, target, member, text)
+    super(lineno)
     @target = target
     @member = member
     @text = text
@@ -115,8 +125,9 @@
   attr_accessor :target, :member, :text
 end
 
-class CodeTag
-  def initialize(text)
+class CodeTag < Tag
+  def initialize(lineno, text)
+    super(lineno)
     @text = text
   end
 
@@ -201,7 +212,7 @@
     else
       type_proxy = type_resolver.resolve(type_name, lineno)
     end
-    return LinkTag.new(type_proxy, member_name, text)
+    return LinkTag.new(lineno, type_proxy, member_name, text)
   end
   return nil
 end
@@ -221,7 +232,7 @@
 
 # handle {@code ...} in comments
 class CodeInlineParser < InlineParser
-  def end; CodeTag.new(@text); end
+  def end; CodeTag.new(@lineno, @text); end
 end
 
 
@@ -251,6 +262,12 @@
 
   def handler_for(tag)
     inline_parser = @inline_parsers[tag.body]
+    if inline_parser.nil?
+      $stderr.puts("#{tag.lineno}: Unknown inline tag #{tag.body.inspect} for #{self.class.name}")
+      NIL_INLINE_PARSER
+    else
+      inline_parser
+    end
   end
 
   def text(text)
@@ -291,11 +308,18 @@
 
 class NilBlockParser < BlockParser
   def add_text(text); end
+  def handler_for(tag); NIL_INLINE_PARSER; end
 end
 
 NIL_HANDLER = NilBlockParser.new
 
 
+class NilInlineParser < InlineParser
+  def end; nil; end
+end
+
+NIL_INLINE_PARSER = NilInlineParser.new
+
 class ParamParser < BlockParser
   def begin_block(type_resolver, lineno)
     super(type_resolver, lineno)

trunk/as2api
html_output.rb 207 -> 208
--- trunk/as2api/html_output.rb	2005-07-24 22:59:39 UTC (rev 207)
+++ trunk/as2api/html_output.rb	2005-07-26 21:07:43 UTC (rev 208)
@@ -411,6 +411,8 @@
     @type = nil
   end
 
+  def astype; @type; end
+
   def generate_content
     html_body do
       # accessability; make a link to skip over the initial navigation elements
@@ -473,6 +475,7 @@
       end
     elsif inline.is_a?(CodeTag)
       input = StringIO.new(inline.text)
+      input.lineno = inline.lineno
       highlight = CodeHighlighter.new
       highlight.number_lines = false
       if inline.text =~ /[\n\r]/
@@ -1819,9 +1822,13 @@
   end
 
   def highlight(input, output)
-    lex = HighlightASLexer.new(output, input)
-    lex.number_lines = @number_lines
-    while lex.get_next; end
+    begin
+      lex = HighlightASLexer.new(output, input)
+      lex.number_lines = @number_lines
+      while lex.get_next; end
+    rescue => e
+      $stderr.puts "#{output.astype.input_filename}:#{e.message}"
+    end
   end
 end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Tue Jul 26 22:42:04 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 26 Jul 2005 22:42:04 +0000 Subject: [as2api-dev] [CVS trunk] Do away with the top-nav bar, and glue the bottom-nav to the top of the screen with CSS Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+11-9208 -> 209
Do away with the top-nav bar, and glue the bottom-nav to the top of the screen with CSS

trunk/as2api
html_output.rb 208 -> 209
--- trunk/as2api/html_output.rb	2005-07-26 21:07:43 UTC (rev 208)
+++ trunk/as2api/html_output.rb	2005-07-26 22:42:03 UTC (rev 209)
@@ -54,9 +54,19 @@
 	background-color: #eeeeee;
 }
 
+body {
+	/* make some space for the navigation */
+	padding-top: 2em;
+}
 .main_nav {
 	background-color: #EEEEFF;
-	padding: 4px;
+	position: fixed;
+	top: 0;
+	display: block;
+	width: 100%;
+	margin: 0;
+	padding: .5em;
+	border-top: .5em solid white;
 }
 .main_nav li {
 	font-family: sans-serif;
@@ -415,14 +425,6 @@
 
   def generate_content
     html_body do
-      # accessability; make a link to skip over the initial navigation elements
-      html_div do
-	html_a("", {"href"=>"#skip_nav", "title"=>"Skip navigation"})
-      end
-      navigation
-      html_div do
-	html_a("", {"name"=>"skip_nav"})
-      end
       generate_body_content
       navigation
       generate_footer
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Tue Jul 26 22:42:54 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 26 Jul 2005 22:42:54 +0000 Subject: [as2api-dev] [CVS trunk] Do a better job at finding the initial sentence a a comment, for summaries. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+1-3209 -> 210
Do a better job at finding the initial sentence a a comment, for summaries.

trunk/as2api
html_output.rb 209 -> 210
--- trunk/as2api/html_output.rb	2005-07-26 22:42:03 UTC (rev 209)
+++ trunk/as2api/html_output.rb	2005-07-26 22:42:54 UTC (rev 210)
@@ -497,9 +497,7 @@
   def output_doccomment_initial_sentence(block)
     block.each_inline do |inline|
       if inline.is_a?(String)
-	if inline =~ /[\.:]\s+[A-Z]/ ||
-	   inline =~ /[\.:]\s+\Z/ ||
-	   inline =~ /<\/?[Pp]\b/
+	if inline =~ /(?:[\.:]\s+[A-Z])|(?:[\.:]\s+\Z)|(?:<\/?[Pp]\b)/
 	  output_doccomment_inlinetag($`)
 	  return
 	else
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Tue Jul 26 22:56:45 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Tue, 26 Jul 2005 22:56:45 +0000 Subject: [as2api-dev] [CVS trunk] Fix breakage of @param handling caused by doc-comment parser rewrite Message-ID:
Commit in trunk/as2api on MAIN
doc_comment.rb+5-5210 -> 211
Fix breakage of @param handling caused by doc-comment parser rewrite

trunk/as2api
doc_comment.rb 210 -> 211
--- trunk/as2api/doc_comment.rb	2005-07-26 22:42:54 UTC (rev 210)
+++ trunk/as2api/doc_comment.rb	2005-07-26 22:56:45 UTC (rev 211)
@@ -326,13 +326,13 @@
     @data = ParamBlockTag.new
   end
 
-  def parse_line(input)
-    if @data.param_name.nil?
-      input.text =~ /\s*([^\s]+)\s+/
+  def end_block
+    first_inline = @data.inlines[0]
+    if first_inline =~ /\s*([^\s]+)\s+/
+      @data.inlines[0] = $'
       @data.param_name = $1
-      input = input.derive($')
     end
-    parse_inlines(input)
+    @data
   end
 end
 
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 27 22:48:08 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 27 Jul 2005 22:48:08 +0000 Subject: [as2api-dev] [CVS trunk] Shimmy main_nav up against the left of the window Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+1211 -> 212
Shimmy main_nav up against the left of the window

trunk/as2api
html_output.rb 211 -> 212
--- trunk/as2api/html_output.rb	2005-07-26 22:56:45 UTC (rev 211)
+++ trunk/as2api/html_output.rb	2005-07-27 22:48:06 UTC (rev 212)
@@ -62,6 +62,7 @@
 	background-color: #EEEEFF;
 	position: fixed;
 	top: 0;
+	left: 0;
 	display: block;
 	width: 100%;
 	margin: 0;
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 27 23:00:15 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 27 Jul 2005 23:00:15 +0000 Subject: [as2api-dev] [CVS trunk] Prevent parser balking when 'package' is used as an identifier Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb-1212 -> 213
parse/aslexer.rb+1-1212 -> 213
+1-2
2 modified files
Prevent parser balking when 'package' is used as an identifier

trunk/as2api
html_output.rb 212 -> 213
--- trunk/as2api/html_output.rb	2005-07-27 22:48:06 UTC (rev 212)
+++ trunk/as2api/html_output.rb	2005-07-27 23:00:13 UTC (rev 213)
@@ -1729,7 +1729,6 @@
     ActionScript::Parse::IntrinsicToken,
     ActionScript::Parse::NewToken,
     ActionScript::Parse::NullToken,
-    ActionScript::Parse::PackageToken,
     ActionScript::Parse::PrivateToken,
     ActionScript::Parse::PublicToken,
     ActionScript::Parse::ReturnToken,

trunk/as2api/parse
aslexer.rb 212 -> 213
--- trunk/as2api/parse/aslexer.rb	2005-07-27 22:48:06 UTC (rev 212)
+++ trunk/as2api/parse/aslexer.rb	2005-07-27 23:00:13 UTC (rev 213)
@@ -104,7 +104,7 @@
 #  "namespace",  # not a keyword in AS
   "new",
   "null",
-  "package",
+#  "package",    # can be an identifier is AS
   "private",
   "public",
   "return",
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 27 23:09:50 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 27 Jul 2005 23:09:50 +0000 Subject: [as2api-dev] [CVS trunk] Don't bother differentiating between field anchors and method anchors. Message-ID:
Commit in trunk/as2api on MAIN
html_output.rb+8-8213 -> 214
Don't bother differentiating between field anchors and method anchors.
ActionScript keeps both kinds of class member in the same namespace anyhow.

trunk/as2api
html_output.rb 213 -> 214
--- trunk/as2api/html_output.rb	2005-07-27 23:00:13 UTC (rev 213)
+++ trunk/as2api/html_output.rb	2005-07-27 23:09:49 UTC (rev 214)
@@ -390,9 +390,9 @@
 
   def link_for_field(field)
     if @type == field.containing_type
-      "#field_#{field.name}"
+      "##{field.name}"
     else
-      "#{link_for_type(field.containing_type)}#field_#{field.name}"
+      "#{link_for_type(field.containing_type)}##{field.name}"
     end
   end
 
@@ -453,9 +453,9 @@
 	if inline.target.resolved?
 	  href = link_for_type(inline.target.resolved_type)
 	  if inline.member =~ /\(/
-	    target = "#method_#{$`}"
+	    target = "##{$`}"
 	  else
-	    target = "#field_#{inline.member}"
+	    target = "##{inline.member}"
 	  end
 	  href << target
 	  html_a("href"=>href) do
@@ -468,9 +468,9 @@
 	link_type_proxy(inline.target)
       else
 	if inline.member =~ /\(/
-	  target = "#method_#{$`}"
+	  target = "##{$`}"
 	else
-	  target = "#field_#{inline.member}"
+	  target = "##{inline.member}"
 	end
 	html_a("href"=>target) do
 	  pcdata(inline.member)
@@ -740,7 +740,7 @@
   end
 
   def document_field(field)
-    html_a("", "name"=>"field_#{field.name}")
+    html_a("", "name"=>"#{field.name}")
     html_h3(field.name)
     html_div("class"=>"field_details") do
       field_synopsis(field)
@@ -774,7 +774,7 @@
     css_class = "method_details"
     css_class << " alt_row" if alt_row
     html_div("class"=>css_class) do
-      html_a("", "name"=>"method_#{method.name}")
+      html_a("", "name"=>"#{method.name}")
       html_h3(method.name)
       method_synopsis(method)
       html_div("class"=>"method_info") do
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Wed Jul 27 23:36:46 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Wed, 27 Jul 2005 23:36:46 +0000 Subject: [as2api-dev] [CVS trunk] Hack in a way to specify that classes in the default package be documented Message-ID:
Commit in trunk/as2api/ui on MAIN
cli.rb+9214 -> 215
Hack in a way to specify that classes in the default package be documented

trunk/as2api/ui
cli.rb 214 -> 215
--- trunk/as2api/ui/cli.rb	2005-07-27 23:09:49 UTC (rev 214)
+++ trunk/as2api/ui/cli.rb	2005-07-27 23:36:46 UTC (rev 215)
@@ -36,7 +36,14 @@
   end
 end
 
+# allows classes in the default (top-level) namespace
+class DefaultPackageFilter
+  def matches?(source_file)
+    source_file =~ /^[^\/]+$/
+  end
+end
 
+
 class VerboseProgressListener < NullProgressListener
   def parsing_sources(total_files)
     @total = total_files
@@ -136,6 +143,8 @@
     case package_spec
       when /\.\*$/
 	PackageGlobFilter.new($`)
+      when /\(default\)/i
+	DefaultPackageFilter.new
       else
 	PackageFilter.new(package_spec)
     end
CVSspam 0.2.11
From dave at badgers-in-foil.co.uk Sat Jul 30 16:45:48 2005 From: dave at badgers-in-foil.co.uk (David Holroyd) Date: Sat Jul 30 16:57:11 2005 Subject: [as2api-dev] [CVS trunk] Add support for hexadecimal constants Message-ID: An HTML attachment was scrubbed... URL: http://lists.badgers-in-foil.co.uk/pipermail/as2api-dev/attachments/20050730/7adeb982/attachment.html