[as2api-dev] [CVS trunk] output_doccomment_initial_sentence() generates per-type text for package summary

David Holroyd dave at badgers-in-foil.co.uk
Fri, 01 Jul 2005 22:45:50 +0000


<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>trunk/as2api</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">html_output.rb</a></tt></td><td align="right" id="added">+84</td><td align="right" id="removed">-63</td><td nowrap="nowrap" align="center"><a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb?rev=166&amp;content-type=text/vnd.viewcvs-markup">166</a> <a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb.diff?r1=166&amp;r2=167">-&gt;</a> <a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb?rev=167&amp;content-type=text/vnd.viewcvs-markup">167</a></td></tr>
</table>
<pre class="comment">
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
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a
href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk">trunk</a>/<a
href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api">as2api</a></span><br />
<div class="fileheader"><big><b>html_output.rb</b></big> <small id="info"><a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb?rev=166&amp;content-type=text/vnd.viewcvs-markup">166</a> <a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb.diff?r1=166&amp;r2=167">-&gt;</a> <a href="http://svn.badgers-in-foil.co.uk/viewcvs.cgi/as2api/trunk/as2api/html_output.rb?rev=167&amp;content-type=text/vnd.viewcvs-markup">167</a></small></div>
<pre class="diff"><small id="info">--- 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 @@
</small></pre><pre class="diff" id="context">     end
   end
 
</pre><pre class="diff" id="added">+  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"=&gt;"unresolved_type_name"})
+    end
+  end
+
</pre><pre class="diff" id="context">   def signature_for_method(method)
     sig = ""
     if method.access.is_static
</pre><pre class="diff"><small id="info">@@ -349,6 +357,70 @@
</small></pre><pre class="diff" id="context">       html_a("as2api", {"href"=&gt;PROJECT_PAGE, "title"=&gt;"ActionScript 2 API Documentation Generator"})
     end
   end
</pre><pre class="diff" id="added">+
+  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 &amp;&amp; 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 &lt;&lt; target
+	  html_a("href"=&gt;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"=&gt;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 =~ /&lt;\/?[Pp]\b/
+	  output_doccomment_inlinetag($`)
+	  return
+	else
+	  output_doccomment_inlinetag(inline)
+	end
+      else
+	output_doccomment_inlinetag(inline)
+      end
+    end
+  end
</pre><pre class="diff" id="context"> end
 
 class TypePage &lt; BasicPage
</pre><pre class="diff"><small id="info">@@ -736,53 +808,6 @@
</small></pre><pre class="diff" id="context">     return comment_has_method_additional_info?(comment_data) || !spec_method.nil?
   end
 
</pre><pre class="diff" id="removed">-  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 &amp;&amp; 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 &lt;&lt; target
-	  html_a("href"=&gt;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"=&gt;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
-
</pre><pre class="diff" id="context">   def method_synopsis(method)
     html_code("class"=&gt;"method_synopsis") do
       if method.access.is_static
</pre><pre class="diff"><small id="info">@@ -865,15 +890,7 @@
</small></pre><pre class="diff" id="context">     end
   end
 
</pre><pre class="diff" id="removed">-  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"=&gt;"unresolved_type_name"})
-    end
-  end
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-
</pre><pre class="diff" id="context">   # TODO: All these comment_*() methods obviously want to belong to some new
   #       class, as yet unwritten.
 
</pre><pre class="diff"><small id="info">@@ -983,7 +1000,7 @@
</small></pre><pre class="diff" id="context"> 	interfaces.sort!
 	html_table("class"=&gt;"summary_list", "summary"=&gt;"") do
 	  html_tr do
</pre><pre class="diff" id="removed">-	    html_th("Interface Summary")
</pre><pre class="diff" id="added">+	    html_th("Interface Summary", {"colspan"=&gt;"2"})
</pre><pre class="diff" id="context"> 	  end
 	  interfaces.each do |type|
 	    html_tr do
</pre><pre class="diff"><small id="info">@@ -991,9 +1008,11 @@
</small></pre><pre class="diff" id="context"> 	      html_td do
 		html_a(type.unqualified_name, {"href"=&gt;type.unqualified_name+".html"})
 	      end
</pre><pre class="diff" id="removed">-	      #html_td do
-		# TODO: package description
-	      #end
</pre><pre class="diff" id="added">+	      html_td do
+		if type.comment
+		  output_doccomment_initial_sentence(type.comment[0])
+		end
+	      end
</pre><pre class="diff" id="context"> 	    end
 	  end
 	end
</pre><pre class="diff"><small id="info">@@ -1003,7 +1022,7 @@
</small></pre><pre class="diff" id="context"> 	classes.sort!
 	html_table("class"=&gt;"summary_list", "summary"=&gt;"") do
 	  html_tr do
</pre><pre class="diff" id="removed">-	    html_th("Class Summary")
</pre><pre class="diff" id="added">+	    html_th("Class Summary", {"colspan", "2"})
</pre><pre class="diff" id="context"> 	  end
 	  classes.each do |type|
 	    html_tr do
</pre><pre class="diff"><small id="info">@@ -1011,9 +1030,11 @@
</small></pre><pre class="diff" id="context"> 	      html_td do
 		html_a(type.unqualified_name, {"href"=&gt;type.unqualified_name+".html"})
 	      end
</pre><pre class="diff" id="removed">-	      #html_td do
-		# TODO: package description
-	      #end
</pre><pre class="diff" id="added">+	      html_td do
+		if type.comment
+		  output_doccomment_initial_sentence(type.comment[0])
+		end
+	      end
</pre><pre class="diff" id="context"> 	    end
 	  end
 	end
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.11</small></center>
</body></html>