<div id="content">
    <% unless (desc = context.description).empty? %>
    <div class="description">
        <%= desc %>
    </div>
    <% end %>

    <% unless context.requires.empty? %>
    <div class="sectiontitle">Required Files</div>
    <ul>
        <% context.requires.each do |req| %>
        <li><%= h req.name %></li>
        <% end %>
    </ul>
    <% end %>

    <% sections = context.sections.select { |section| section.title } %>
    <% unless sections.empty? %>
    <div class="sectiontitle">Contents</div>
    <ul>
        <% sections.each do |section| %>
        <li><a href="#<%= section.sequence %>"><%= h section.title %></a></li>
        <% end %>
    </ul>
    <% end %>

    <%
        list = context.method_list
        unless @options.show_all
            list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
        end
    %>
    <% unless list.empty? %>
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
    <% each_letter_group(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>
        </dd>
    <% end %>
    </dl>
    <% end %>

    <% unless context.includes.empty? %>
    <div class="sectiontitle">Included Modules</div>
    <ul>
        <% 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
        </li>
        <% end %>
    </ul>
    <% 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>
    <% 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>
    <% end %>

    <% unless context.constants.empty? %>
    <div class="sectiontitle">Constants</div>
    <table border='0' cellpadding='5'>
        <% context.each_constant do |const| %>
        <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>
        <% end %>
        <% end %>
    </table>
    <% end %>

    <% unless context.attributes.empty? %>
    <div class="sectiontitle">Attributes</div>
    <table border='0' cellpadding='5'>
        <% context.each_attribute do |attrib| %>
        <tr valign='top'>
            <td class='attr-rw'>
                [<%= attrib.rw %>]
            </td>
            <td class='attr-name'><%= h attrib.name %></td>
            <td class='attr-desc'><%= attrib.description.strip %></td>
        </tr>
        <% end %>
    </table>
    <% end %>

    <% context.methods_by_type.each do |type, visibilities|
        next if visibilities.empty?
        visibilities.each do |visibility, methods|
            next if methods.empty?
            next unless @options.show_all || 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" 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>
                <% 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 && @options.open_source %>
                <% markup = method.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
                            github = github_url(path)
                            if github
                        %>
                        | <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a>
                        <% end %>
                    </p>
                    <div id="<%= method.aref %>_source" class="dyn-source">
                        <pre><%= method.markup_code %></pre>
                    </div>
                </div>
                <% end %>
            </div>
            <%      end
        end
    end
    %>
</div>