3 local table = require "table"
5 function _parse_ref( r )
6 local k, v = r:match("([^.]+)%.([^.]+)")
7 return k and self:_section_filename(k, v)
10 function _parse_dep( r, c, s, o )
18 for v in r:gmatch("[^.]+") do
19 ref[#ref+1] = (v:gsub( "%$(.+)", vars ))
23 table.insert(ref, 1, s or '$section')
26 table.insert(ref, 1, c or '$config')
29 return self:_variable_target(unpack(ref))
33 <h1 class="section-title"><%=scheme-%>
34 <%-if package.title then%>: <%=package.title%><%end%></h1>
35 <h2 class="section-subtitle"><%=type-%>
36 <%-if section.title then%>: <%=section.title%><%end%></h2>
37 <div class="section-description"><%=section.description%></div>
39 <h3 class="section-attributes">Attributes:</h3>
40 <ul class="section-attributes-index">
42 if section.required then %>
43 <li class="section-attributes-required">required: <dfn>A section of this type is required.</dfn></li>
45 if section.unique then %>
46 <li class="section-attributes-unique">unique: <dfn>There can be only one section of this type.</dfn></li>
48 <li class="section-attributes-multiple">multiple: <dfn>There can be more than one section of this type.</dfn></li>
50 if section.dynamic then %>
51 <li class="section-attributes-dynamic">dynamic: <dfn>Sections of this type may contain user-defined options.</dfn></li>
53 if section.named then %>
54 <li class="section-attributes-named">named: <dfn>Sections of this type require a name.</dfn></li>
58 <% if section.depends then %>
59 <h3 class="section-depends">Requirements (one of):</h3>
60 <ul class="section-depends-index">
61 <% for i, d in ipairs(section.depends) do
64 <% for k2, v in luci.util.kspairs(d) do
65 local t = _parse_dep(k2, scheme, type)
67 <% if nf then %>and<% end %>
68 <%if t then%><a href="<%=t%>"><%end%><%=k2%><%if t then%></a><%end%><%if v~="" then%>=<%=v%><%end%>
76 <h3 class="section-variables">Options:</h3>
77 <table class="section-variables-index">
78 <% for k, v in luci.util.kspairs(package.variables[type]) do
80 <tr class="section-variable-required">
81 <td><a href="#variable.<%=k%>"><%=k%></a></td>
85 for k, v in luci.util.kspairs(package.variables[type]) do
86 if not v.required then%>
87 <tr class="section-variable-mixed">
88 <td><a href="#variable.<%=k%>"><%=k%></a></td>
94 <h3 class="section-variables">Options:</h3>
97 for k, v in luci.util.kspairs(package.variables[type]) do
98 if (i==0) == v.required then
101 <div class="variable-documentation">
102 <a name="variable.<%=k%>" />
103 <h4 class="variable-title"><%=k-%>
104 <%-if v.title then%>: <%=v.title%><%end%></h4>
105 <div class="variable-description"><%=v.description%></div>
106 <h5 class="variable-attributes">Attributes:</h5>
107 <ul class="varaible-attributes-index">
108 <% if v.required then %>
109 <li class="variable-attribute-required"><strong>required</strong></li>
111 <li class="variable-attribute-type"><strong>Type:</strong> <%=v.type%></li>
112 <li class="variable-attribute-datatype"><strong>Datatype:</strong> <%=v.datatype%></li>
114 <% if v.depends then %>
115 <h5 class="variable-depends">Dependencies (one of):</h5>
116 <ul class="variable-depends-index">
117 <% for i, d in ipairs(v.depends) do
120 <% for k2, v in luci.util.kspairs(d) do
121 local t = _parse_dep(k2, scheme, type, k)
123 <% if nf then %>and<% end %>
124 <%if t then%><a href="<%=t%>"><%end%><%=k2%><%if t then%></a><%end%><%if v~="" then%>=<%=v%><%end%>
131 <% if v.type == "enum" then %>
132 <h5 class="variable-values">Possible Values:</h5>
133 <ul class="variable-values-index">
134 <% for k, d in pairs(v.values) do %>
135 <li><strong><%=k%></strong><%if d then%> (<%=d%>)<%end%></li>
138 <% elseif v.type == "reference" then %>
139 <h5 class="variable-reference">Value references:</h5>
140 <ul class="variable-reference-index">
141 <% for k, d in ipairs(v.valueof) do %>
143 <% local t = _parse_ref(d)
144 if t then %>Section of type <a href="<%=t%>"><% end %>
146 <% if t then%></a><% end %>