2023-05-04 00:45:39 +02:00
|
|
|
local assert = require("luassert")
|
|
|
|
local scraper = require("scraper").module_doc
|
|
|
|
|
|
|
|
local get_doc_from_page = scraper.get_doc_from_page
|
|
|
|
|
|
|
|
describe("Scrap documentation", function()
|
|
|
|
it("should return a valid AST for an empty module", function()
|
|
|
|
local ast <const>, nodes <const> = get_doc_from_page("", "empty")
|
|
|
|
assert.same(ast, {
|
|
|
|
children = {
|
|
|
|
{
|
|
|
|
children = {},
|
|
|
|
name = "Signal",
|
|
|
|
token = "enum",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
name = "Empty",
|
|
|
|
token = "module",
|
|
|
|
})
|
|
|
|
assert.same(nodes, {})
|
|
|
|
end)
|
2023-05-04 00:46:27 +02:00
|
|
|
|
2023-05-04 00:49:19 +02:00
|
|
|
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)
|
|
|
|
|
2023-05-04 00:46:27 +02:00
|
|
|
it("should produce Signal nodes", function()
|
|
|
|
local ast <const> = get_doc_from_page([[
|
|
|
|
<h2 class="section-header"><a name="Signals"></a>Signals</h2>
|
|
|
|
<dl class="function">
|
|
|
|
<dt>
|
|
|
|
<a
|
|
|
|
class="copy-link js-copy-link"
|
|
|
|
name="widget::layout_changed"
|
|
|
|
href="#widget::layout_changed"
|
|
|
|
>🔗</a
|
|
|
|
>
|
|
|
|
<strong>widget::layout_changed</strong>
|
|
|
|
<span class="baseclass"> · Inherited from wibox.widget.base </span>
|
|
|
|
</dt>
|
|
|
|
<dd></dd>
|
|
|
|
<dt>
|
|
|
|
<a
|
|
|
|
class="copy-link js-copy-link"
|
|
|
|
name="widget::redraw_needed"
|
|
|
|
href="#widget::redraw_needed"
|
|
|
|
>🔗</a
|
|
|
|
>
|
|
|
|
<strong>widget::redraw_needed</strong>
|
|
|
|
<span class="baseclass"> · Inherited from wibox.widget.base </span>
|
|
|
|
</dt>
|
|
|
|
<dd></dd>
|
|
|
|
</dl>
|
|
|
|
]], "signal")
|
|
|
|
assert.same(ast, {
|
|
|
|
children = {
|
|
|
|
{
|
|
|
|
children = {
|
|
|
|
{
|
|
|
|
name = "widget::layout_changed",
|
|
|
|
token = "identifier",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "widget::redraw_needed",
|
|
|
|
token = "identifier",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
name = "Signal",
|
|
|
|
token = "enum",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
name = "Signal",
|
|
|
|
token = "module",
|
|
|
|
})
|
|
|
|
end)
|
2023-05-04 00:45:39 +02:00
|
|
|
end)
|