3 local table = require "table"
5 function _parse_ref( r )
6 local k, v, h = r:match("([^.]+)%.([^.]+)%.([^.]+)")
8 k, v = r:match("([^.]+)%.([^.]+)")
12 return self:_variable_target(k, v, h), true
14 return self:_section_filename(k, v)
19 function _parse_dep( r, c, s, o )
27 for v in r:gmatch("[^.]+") do
28 ref[#ref+1] = (v:gsub( "%$(.+)", vars ))
32 table.insert(ref, 1, s or '$section')
35 table.insert(ref, 1, c or '$config')
38 return self:_variable_target(unpack(ref))
42 <h1 class="section-title"><%=scheme-%>
43 <%-if package.title then%>: <%=package.title%><%end%></h1>
44 <h2 class="section-subtitle"><%=type-%>
45 <%-if section.title then%>: <%=section.title%><%end%></h2>
46 <div class="section-description"><%=section.description%></div>
48 <h3 class="section-attributes">Attributes:</h3>
49 <ul class="section-attributes-index">
51 if section.required then %>
52 <li class="section-attributes-required">required: <dfn>A section of this type is required.</dfn></li>
54 if section.unique then %>
55 <li class="section-attributes-unique">unique: <dfn>There can be only one section of this type.</dfn></li>
57 <li class="section-attributes-multiple">multiple: <dfn>There can be more than one section of this type.</dfn></li>
59 if section.dynamic then %>
60 <li class="section-attributes-dynamic">dynamic: <dfn>Sections of this type may contain user-defined options.</dfn></li>
62 if section.named then %>
63 <li class="section-attributes-named">named: <dfn>Sections of this type require a name.</dfn></li>
67 <% if section.depends then %>
68 <h3 class="section-depends">Requirements (one of):</h3>
69 <ul class="section-depends-index">
70 <% for i, d in ipairs(section.depends) do
73 <% for k2, v in luci.util.kspairs(d) do
74 local t = _parse_dep(k2, scheme, type)
76 <% if nf then %>and<% end %>
77 <%if t then%><a href="<%=t%>"><%end%><%=k2%><%if t then%></a><%end%><%if v~="" then%>=<%=v%><%end%>
85 <h3 class="section-variables">Options:</h3>
86 <table class="section-variables-index">
87 <% for k, v in luci.util.kspairs(package.variables[type]) do
89 <tr class="section-variable-required">
90 <td><a href="#variable.<%=k%>"><%=k%></a></td>
94 for k, v in luci.util.kspairs(package.variables[type]) do
95 if not v.required then%>
96 <tr class="section-variable-mixed">
97 <td><a href="#variable.<%=k%>"><%=k%></a></td>
103 <h3 class="section-variables">Options:</h3>
106 for k, v in luci.util.kspairs(package.variables[type]) do
107 if (i==0) == v.required then
110 <div class="variable-documentation">
111 <a name="variable.<%=k%>" />
112 <h4 class="variable-title"><%=k-%>
113 <%-if v.title then%>: <%=v.title%><%end%></h4>
114 <div class="variable-description"><%=v.description%></div>
115 <h5 class="variable-attributes">Attributes:</h5>
116 <ul class="varaible-attributes-index">
117 <% if v.required then %>
118 <li class="variable-attribute-required"><strong>required</strong></li>
120 <li class="variable-attribute-type"><strong>Type:</strong> <%=v.type%></li>
121 <li class="variable-attribute-datatype"><strong>Datatype:</strong> <%=v.datatype%></li>
123 <% if v.depends then %>
124 <h5 class="variable-depends">Dependencies (one of):</h5>
125 <ul class="variable-depends-index">
126 <% for i, d in ipairs(v.depends) do
129 <% for k2, v in luci.util.kspairs(d) do
130 local t = _parse_dep(k2, scheme, type, k)
132 <% if nf then %>and<% end %>
133 <%if t then%><a href="<%=t%>"><%end%><%=k2%><%if t then%></a><%end%><%if v~="" then%>=<%=v%><%end%>
140 <% if v.type == "enum" then %>
141 <h5 class="variable-values">Possible Values:</h5>
142 <ul class="variable-values-index">
143 <% for k, d in pairs(v.values) do %>
144 <li><strong><%=k%></strong><%if d then%> (<%=d%>)<%end%></li>
147 <% elseif v.type == "reference" then %>
148 <h5 class="variable-reference">Value references:</h5>
149 <ul class="variable-reference-index">
150 <% for k, d in ipairs(v.valueof) do %>
152 <% local t, x = _parse_ref(d)
153 if t then %><%=x and "Value of" or "Section of type"%> <a href="<%=t%>"><% end %>
155 <% if t then%></a><% end %>