File: _context.rhtml

package info (click to toggle)
ruby-sdoc 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 848 kB
  • sloc: javascript: 4,418; ruby: 629; makefile: 3
file content (216 lines) | stat: -rw-r--r-- 6,644 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<div id="content">
  <% unless (description = context.description).empty? %>
    <div class="description">
      <%= description %>
    </div>
  <% end %>


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


  <% 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.aref %>"><%= h section.title %></a></li>
      <% end %>
    </ul>
  <% end %>


  <% 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(context.method_list) do |group| %>
        <dt><%= group[:name] %></dt>
        <dd>
          <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 %>
    </dl>
  <% end %>

  <% unless context.includes.empty? %>
    <!-- Includes -->
    <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 %>
            <%= h inc.name %>
          <% end %>
        </li>
      <% end %>
    </ul>
  <% end %>



  <% context.each_section do |section, constants, attributes| %>

    <% if section.title then %>
      <div class="contenttitle" id="<%= h section.aref %>">
        <%= h section.title %>
      </div>
    <% end %>

    <% if section.comment then %>
      <div class="description">
        <%= section.description %>
      </div>
    <% end %>

    <% unless constants.empty? %>
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        <% constants.each do |const| %>
          <tr valign='top'>
            <td class="attr-name"><%= h const.name %></td>
            <td>=</td>
            <td class="attr-value"><%= h const.value %></td>
          </tr>
          <% if const.comment %>
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"><%= const.description.strip %></td>
            </tr>
          <% end %>
        <% end %>
      </table>
    <% end %>


    <% 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 %>]
            </td>
            <td class='attr-name'><%= h attrib.name %></td>
            <td class='attr-desc'><%= attrib.description.strip %></td>
          </tr>
        <% end %>
      </table>
    <% end %>


    <!-- Methods -->
    <%
      context.methods_by_type(section).each do |type, visibilities|
        next if visibilities.empty?

        visibilities.each do |visibility, methods|
          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 %>
              <b><%= method.call_seq.gsub(/->/, '&rarr;').gsub(/\n(.)/, '<br />\1') %></b>
            <% else %>
              <b><%= h method.name %></b><%= h method.params %>
            <% end %>
            <a href="<%= "#{rel_prefix}/#{context.path}##{method.aref}"%>" name="<%= method.aref %>" class="permalink">Link</a>
          </div>

          <% if 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.is_alias_for then %>
            <div class="aka">
              Alias for: <a href="<%= context.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
            </div>
          <% end %>

          <% if method.token_stream %>
            <% markup = method.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 %>
              </p>
              <div id="<%= method.aref %>_source" class="dyn-source">
                <pre><%= markup %></pre>
              </div>
            </div>
            <% end %>
          </div>
        <% end %><%# methods.each %>
      <% end %><%# visibilities.each %>
    <% end %><%# context.methods_by_type %>
  <% end %><%# context.each_section %>
</div>