lib/rdoc/generator/template/sdoc/_context.rhtml in sdoc-0.3.8 vs lib/rdoc/generator/template/sdoc/_context.rhtml in sdoc-0.3.9

- old
+ new

@@ -1,173 +1,209 @@ <div id="content"> - <% unless (desc = context.description).empty? %> + <% unless (description = context.description).empty? %> <div class="description"> - <%= desc %> + <%= description %> </div> - <% end %> + <% end %> - <% unless context.requires.empty? %> + + <% unless context.requires.empty? %> + <!-- File only: requires --> <div class="sectiontitle">Required Files</div> <ul> - <% context.requires.each do |req| %> + <% context.requires.each do |req| %> <li><%= h req.name %></li> - <% end %> + <% end %> </ul> - <% end %> + <% end %> - <% sections = context.sections.select { |section| section.title } %> - <% unless sections.empty? %> - <div class="sectiontitle">Contents</div> + + <% sections = context.sections.select { |s| s.title }.sort_by{ |s| s.title.to_s } %> + <% unless sections.empty? then %> + <!-- Sections --> + <div class="sectiontitle">Sections</div> <ul> - <% sections.each do |section| %> - <li><a href="#<%= section.sequence %>"><%= h section.title %></a></li> - <% end %> + <% sections.each do |section| %> + <li><a href="#<%= section.aref %>"><%= h section.title %></a></li> + <% end %> </ul> - <% end %> + <% end %> - <% - list = context.method_list - list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation } - %> - <% unless list.empty? %> + + <% unless context.classes_and_modules.empty? %> + <!-- Namespace --> + <div class="sectiontitle">Namespace</div> + <ul> + <% (context.modules.sort + context.classes.sort).each do |mod| %> + <li> + <span class="type"><%= mod.type.upcase %></span> + <a href="<%= context.aref_to mod.path %>"><%= mod.full_name %></a> + </li> + <% end %> + </ul> + <% end %> + + + <% unless context.method_list.empty? %> + <!-- Method ref --> <div class="sectiontitle">Methods</div> <dl class="methods"> - <% each_letter_group(list) do |group| %> + <% each_letter_group(context.method_list) do |group| %> <dt><%= group[:name] %></dt> <dd> - <ul> - <% group[:methods].each_with_index do |method, i| %> - <li><a href="#<%= method.aref %>"><%= method.name %></a><%= ',' unless group[:methods].size == i+1 %></li> - <% end %> - </ul> + <ul> + <% group[:methods].each_with_index do |method, i| %> + <% + comma = group[:methods].size == i+1 ? '' : ',' + %> + <li> + <a href="#<%= method.aref %>"><%= h method.name %></a><%= comma %> + </li> + <% end %> + </ul> </dd> - <% end %> + <% end %> </dl> - <% end %> + <% end %> - <% unless context.includes.empty? %> + <% unless context.includes.empty? %> + <!-- Includes --> <div class="sectiontitle">Included Modules</div> <ul> - <% context.includes.each do |inc| %> + <% context.includes.each do |inc| %> <li> - <% unless String === inc.module %> - <a href="<%= context.aref_to inc.module.path %>"><%= h inc.module.full_name %></a> - <% else %> - <span><%= h inc.name %></span> - <% end %> - START:includes + <% unless String === inc.module %> + <a href="<%= context.aref_to inc.module.path %>"> + <%= h inc.module.full_name %> + </a> + <% else %> + <%= h inc.name %> + <% end %> </li> - <% end %> + <% end %> </ul> - <% end %> + <% end %> - <% sections.each do |section| %> - <div class="sectiontitle"><a name="<%= h section.sequence %>"><%= h section.title %></a></div> - <% unless (description = section.description).empty? %> - <div class="description"> - <%= description %> - </div> + + + <% context.each_section do |section, constants, attributes| %> + + <% if section.title then %> + <div class="contenttitle" id="<%= h section.aref %>"> + <%= h section.title %> + </div> <% end %> - <% end %> - <% unless context.classes_and_modules.empty? %> - <div class="sectiontitle">Classes and Modules</div> - <ul> - <% (context.modules.sort + context.classes.sort).each do |mod| %> - <li><span class="type"><%= mod.type.upcase %></span> <a href="<%= context.aref_to mod.path %>"><%= mod.full_name %></a></li> - <% end %> - </ul> + <% if section.comment then %> + <div class="description"> + <%= section.description %> + </div> <% end %> - <% unless context.constants.empty? %> - <div class="sectiontitle">Constants</div> - <table border='0' cellpadding='5'> + <% unless constants.empty? %> + <!-- Section constants --> + <div class="sectiontitle">Constants</div> + <table border='0' cellpadding='5'> <% context.each_constant do |const| %> - <tr valign='top'> + <tr valign='top'> <td class="attr-name"><%= h const.name %></td> <td>=</td> <td class="attr-value"><%= h const.value %></td> - </tr> - <% unless (description = const.description).empty? %> - <tr valign='top'> - <td>&nbsp;</td> - <td colspan="2" class="attr-desc"><%= description %></td> - </tr> + </tr> + <% if const.comment %> + <tr valign='top'> + <td>&nbsp;</td> + <td colspan="2" class="attr-desc"><%= const.description.strip %></td> + </tr> + <% end %> <% end %> - <% end %> - </table> + </table> <% end %> - <% unless context.attributes.empty? %> - <div class="sectiontitle">Attributes</div> - <table border='0' cellpadding='5'> - <% context.each_attribute do |attrib| %> - <tr valign='top'> + + <% unless attributes.empty? %> + <!-- Section attributes --> + <div class="sectiontitle">Attributes</div> + <table border='0' cellpadding='5'> + <% attributes.each do |attrib| %> + <tr valign='top'> <td class='attr-rw'> - [<%= attrib.rw %>] + [<%= attrib.rw %>] </td> <td class='attr-name'><%= h attrib.name %></td> <td class='attr-desc'><%= attrib.description.strip %></td> - </tr> + </tr> <% end %> - </table> + </table> <% end %> - <% context.methods_by_type.each do |type, visibilities| + + <!-- Methods --> + <% + context.methods_by_type(section).each do |type, visibilities| next if visibilities.empty? + visibilities.each do |visibility, methods| - next if methods.empty? - next unless visibility == :public || visibility == :protected || methods.any? {|m| m.force_documentation } - %> - <div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div> - <% methods.each do |method| %> - <div class="method"> - <div class="title method-title" id="<%= method.aref %>"> - <% if method.call_seq %> - <a name="<%= method.aref %>"></a><b><%= method.call_seq.gsub(/->/, '&rarr;') %></b> - <% else %> - <a name="<%= method.aref %>"></a><b><%= h method.name %></b><%= h method.params %> - <% end %> - </div> - <% unless (description = method.description).empty? %> - <div class="description"> - <%= description %> - </div> + next if methods.empty? + %> + <div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div> + <% methods.each do |method| %> + <div class="method"> + <div class="title method-title" id="<%= method.aref %>"> + <% if method.call_seq %> + <a name="<%= method.aref %>"></a><b><%= method.call_seq.gsub(/->/, '&rarr;') %></b> + <% else %> + <a name="<%= method.aref %>"></a><b><%= h method.name %></b><%= h method.params %> + <% end %> + </div> + + <% unless method.comment %> + <div class="description"> + <%= method.description.strip %> + </div> + <% end %> + + <% unless method.aliases.empty? %> + <div class="aka"> + Also aliased as: <%= method.aliases.map do |aka| + if aka.parent then # HACK lib/rexml/encodings + %{<a href="#{context.aref_to aka.path}">#{h aka.name}</a>} + else + h aka.name + end + end.join ", " %> + </div> + <% end %> + + <% if method.token_stream %> + <% markup = method.sdoc_markup_code %> + <div class="sourcecode"> + <% + # generate github link + github = if options.github + if markup =~ /File\s(\S+), line (\d+)/ + path = $1 + line = $2.to_i + end + path && github_url(path) + else + false + end + %> + <p class="source-link"> + Source: + <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a> + <% if github %> + | <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a> <% end %> - <% unless method.aliases.empty? %> - <div class="aka"> - This method is also aliased as - <% method.aliases.each do |aka| %> - <a href="<%= context.aref_to aka.path %>"><%= h aka.name %></a> - <% end %> - </div> - <% end %> - <% if method.token_stream %> - <% markup = method.sdoc_markup_code %> - <div class="sourcecode"> - <p class="source-link"> - Source: <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a> - <% - if markup =~ /File\s(\S+), line (\d+)/ - path = $1 - line = $2.to_i - end - %> - <% - if options.github && path - github = github_url(path) - if github - %> - | <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a> - <% end end %> - </p> - <div id="<%= method.aref %>_source" class="dyn-source"> - <pre><%= markup %></pre> - </div> - </div> - <% end %> + </p> + <div id="<%= method.aref %>_source" class="dyn-source"> + <pre><%= markup %></pre> + </div> </div> - <% end - end - end - %> + <% end %> + </div> + <% end #methods.each %> + <% end #visibilities.each %> + <% end #context.methods_by_type %> + <% end #context.each_section %> </div> \ No newline at end of file