spec(module_doc): add "Object properties" tests
This commit is contained in:
parent
65320173e5
commit
129f15ea9d
|
@ -37,6 +37,7 @@
|
|||
"Stylua",
|
||||
"sublist",
|
||||
"tablex",
|
||||
"tbody",
|
||||
"tmpl",
|
||||
"wibox",
|
||||
"woodpeckerci",
|
||||
|
|
|
@ -20,6 +20,217 @@ describe("Scrap documentation", function()
|
|||
assert.same(nodes, {})
|
||||
end)
|
||||
|
||||
it("should produce Variable and `property::` Signal nodes", function()
|
||||
local ast <const> = get_doc_from_page([[
|
||||
<h2 class="section-header">
|
||||
<a name="Object_properties"></a>Object properties
|
||||
</h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a class="copy-link js-copy-link" name="value" href="#value">🔗</a>
|
||||
<strong>value</strong>
|
||||
<span class="proptype"><span class="summary_type">number</span></span>
|
||||
<span class="baseclass"> · 1 signal </span>
|
||||
</dt>
|
||||
<dd>
|
||||
<h3>Constraints:</h3>
|
||||
<span class="property_type">
|
||||
<table class="see_also">
|
||||
<tbody><tr class="">
|
||||
<td style="padding-left:0px;">
|
||||
<i>
|
||||
Default value
|
||||
</i>
|
||||
</td>
|
||||
<td>: <code>0</code></td>
|
||||
</tr><tr>
|
||||
</tr><tr class="">
|
||||
<td style="padding-left:0px;">
|
||||
<i>
|
||||
Negative allowed
|
||||
</i>
|
||||
</td>
|
||||
<td>: true</td>
|
||||
</tr><tr>
|
||||
</tr></tbody></table>
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
]], "property_signal")
|
||||
assert.same(ast, {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
{
|
||||
name = "property::value",
|
||||
token = "identifier",
|
||||
},
|
||||
},
|
||||
name = "Signal",
|
||||
token = "enum",
|
||||
},
|
||||
{
|
||||
name = "value",
|
||||
types = { "number" },
|
||||
token = "variable",
|
||||
}
|
||||
},
|
||||
name = "Property_signal",
|
||||
token = "module",
|
||||
})
|
||||
end)
|
||||
|
||||
it("should produce Enum nodes when an Object Property type is a String with constraints", function()
|
||||
local ast <const> = get_doc_from_page([[
|
||||
<h2 class="section-header">
|
||||
<a name="Object_properties"></a>Object properties
|
||||
</h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a
|
||||
class="copy-link js-copy-link"
|
||||
name="horizontal_fit_policy"
|
||||
href="#horizontal_fit_policy"
|
||||
>🔗</a
|
||||
>
|
||||
<strong>horizontal_fit_policy</strong>
|
||||
<span class="proptype"><span class="summary_type">string</span></span>
|
||||
<span class="baseclass"> · 1 signal </span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="property_type">
|
||||
<table class="see_also">
|
||||
<tbody>
|
||||
<tr class="">
|
||||
<td style="padding-left: 0px">
|
||||
<i> Default value </i>
|
||||
</td>
|
||||
<td>: <code>"auto"</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr class="">
|
||||
<td style="padding-left: 0px">
|
||||
<i> Valid values: </i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr class="see_also_sublist">
|
||||
<td style="padding-left: 15px">
|
||||
<i>
|
||||
<code>"auto"</code>
|
||||
</i>
|
||||
</td>
|
||||
<td>
|
||||
: Honor the <code>resize</code> variable and preserve the aspect
|
||||
ratio.
|
||||
</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr class="see_also_sublist">
|
||||
<td style="padding-left: 15px">
|
||||
<i>
|
||||
<code>"none"</code>
|
||||
</i>
|
||||
</td>
|
||||
<td>: Do not resize at all.</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr class="see_also_sublist">
|
||||
<td style="padding-left: 15px">
|
||||
<i>
|
||||
<code>"fit"</code>
|
||||
</i>
|
||||
</td>
|
||||
<td>: Resize to the widget width.</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
]], "property_enum")
|
||||
assert.same(ast, {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
{
|
||||
name = "property::horizontal_fit_policy",
|
||||
token = "identifier",
|
||||
},
|
||||
},
|
||||
name = "Signal",
|
||||
token = "enum",
|
||||
},
|
||||
{
|
||||
children = {
|
||||
{
|
||||
name = "auto",
|
||||
token = "identifier",
|
||||
},
|
||||
{
|
||||
name = "none",
|
||||
token = "identifier",
|
||||
},
|
||||
{
|
||||
name = "fit",
|
||||
token = "identifier",
|
||||
},
|
||||
},
|
||||
name = "Horizontal_fit_policy",
|
||||
token = "enum",
|
||||
},
|
||||
{
|
||||
name = "horizontal_fit_policy",
|
||||
types = { "Horizontal_fit_policy" },
|
||||
token = "variable",
|
||||
},
|
||||
},
|
||||
name = "Property_enum",
|
||||
token = "module",
|
||||
})
|
||||
end)
|
||||
|
||||
it("should produce a `string` typed Variable node when a String Property has no constraint", function()
|
||||
local ast <const> = get_doc_from_page([[
|
||||
<h2 class="section-header">
|
||||
<a name="Object_properties"></a>Object properties
|
||||
</h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a class="copy-link js-copy-link" name="markup" href="#markup">🔗</a>
|
||||
<strong>markup</strong>
|
||||
<span class="proptype"><span class="summary_type">string</span></span>
|
||||
<span class="baseclass"> · 1 signal </span>
|
||||
</dt>
|
||||
<dd>
|
||||
<span class="property_type">string</span>
|
||||
</dd>
|
||||
</dl>
|
||||
]], "property_string")
|
||||
assert.same(ast, {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
{
|
||||
name = "property::markup",
|
||||
token = "identifier",
|
||||
},
|
||||
},
|
||||
name = "Signal",
|
||||
token = "enum",
|
||||
},
|
||||
{
|
||||
name = "markup",
|
||||
types = { "string" },
|
||||
token = "variable",
|
||||
}
|
||||
},
|
||||
name = "Property_string",
|
||||
token = "module",
|
||||
})
|
||||
end)
|
||||
|
||||
it("should produce Signal nodes", function()
|
||||
local ast <const> = get_doc_from_page([[
|
||||
<h2 class="section-header"><a name="Signals"></a>Signals</h2>
|
||||
|
|
|
@ -82,7 +82,7 @@ end
|
|||
local function extract_property_constraints(property_constraint_node: scan.HTMLNode): { string }
|
||||
return scraper_utils.scrape(
|
||||
property_constraint_node:outer_html(),
|
||||
"tr.see_also_sublist",
|
||||
"tr.see_also_sublist i code",
|
||||
extract_node_text
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue