summaryrefslogtreecommitdiff
path: root/giscanner/doctemplates/devdocs/Gjs/_index.tmpl
blob: 8d45e871e2e787d5a7b16c7e400d1dd3509308d7 (plain)
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
<%
  ancestors = []
  if isinstance(node, ast.Class):
    ancestors = formatter.get_inheritable_types(node)

  def get_ancestor_counts(*kinds):
    counts = {}
    for a in ancestors:
      count = sum([len(getattr(a, kind, [])) for kind in kinds])
      if count:
        counts[a] = count
    return counts

  def should_render(*kinds):
    has_nonempty = any([getattr(node, kind, []) for kind in kinds])
    return has_nonempty or get_ancestor_counts(*kinds)
%>

<%def name="inherited(*kinds)">
  <% counts = get_ancestor_counts(*kinds) %>
  % if counts:
    <%
      links = ', '.join(['{} ({})'.format(formatter.format_xref(a), count)
        for a, count in counts.items()])
    %>
    ${formatter.format(node, '**Inherited:** ' + links)}
  % endif
</%def>

% if should_render('static_methods', 'constructors', 'methods'):
  <h2 id="index-methods">Methods</h2>
  ${inherited('static_methods', 'constructors', 'methods')}
  <%
    static_methods = getattr(node, 'static_methods', []) + getattr(node, 'constructors', [])
    methods = static_methods + getattr(node, 'methods', [])
  %>
  % if methods:
    <table>
      <tbody>
      % for m in methods:
        <tr>
          % if m in static_methods:
            <td class="static-method-indicator">static</td>
          % else:
            <td></td>
          % endif
          <td>
            <a href="#${formatter.make_anchor(m)}">
              ${formatter.format_function_name(m)}<!-- no space
            --></a><!-- no space
            -->(${formatter.format_in_parameters(m)})
          </td>
        </tr>
      % endfor
      </tbody>
    </table>
  % endif
% endif

% if should_render('virtual_methods'):
  <h2 id="index-vfuncs">Virtual methods</h2>
  ${inherited('virtual_methods')}
  % if getattr(node, 'virtual_methods', []):
    <table>
      <tbody>
      % for m in node.virtual_methods:
        <tr>
          <td>
            <a href="#${formatter.make_anchor(m)}">
              ${formatter.format_function_name(m)}<!-- no space
            --></a><!-- no space
            -->(${formatter.format_in_parameters(m)})
          </td>
        </tr>
      % endfor
      </tbody>
    </table>
  % endif
% endif

% if should_render('properties'):
  <h2 id="index-properties">Properties</h2>
  ${inherited('properties')}
  % if getattr(node, 'properties', []):
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Type</th>
          <th>Flags</th>
        </tr>
      </thead>
      <tbody>
      % for p in node.properties:
        <tr>
          <td><a href="#${formatter.make_anchor(p)}">${p.name}</a></td>
          <td>${formatter.format_type(p.type)}</td>
          <td>${formatter.format_property_flags(p, abbrev=True)}</td>
        </tr>
      % endfor
      </tbody>
    </table>
  % endif
% endif

% if should_render('signals'):
  <h2 id="index-signals">Signals</h2>
  ${inherited('signals')}
  % if getattr(node, 'signals', []):
    <table>
      <tbody>
      % for s in node.signals:
        <tr>
          <td>
            <a href="#${formatter.make_anchor(s)}">${s.name}</a><!-- no space
            -->(${formatter.format_in_parameters(s)})
          </td>
        </tr>
      % endfor
      </tbody>
    </table>
  % endif
% endif

% if should_render('fields'):
  <h2 id="index-fields">Fields</h2>
  ${inherited('fields')}
  % if getattr(node, 'fields', []):
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Type</th>
          <th>Access</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
      % for f in node.fields:
        <tr>
          <td><span class="entry" href="#${formatter.make_anchor(f)}">${f.name}</span></td>
          <td>${formatter.format_type(f.type)}</td>
          <td>${formatter.format_property_flags(f, abbrev=True)}</td>
          ## Fields almost never warrant a detailed entry, we'll just make this
          ## the entry to be indexed by DevDocs
          <td>
          % if f.doc:
            ${formatter.format_inline(node, f.doc)}
          % endif
          </td>
        </tr>
      % endfor
      </tbody>
    </table>
  % endif
% endif