Move to an AST like data structure #76

Merged
Aire-One merged 39 commits from feat/refactor-ast into master 2023-08-03 21:03:16 +02:00
1 changed files with 65 additions and 0 deletions
Showing only changes of commit efb54bf92b - Show all commits

View File

@ -231,6 +231,71 @@ describe("Scrap documentation", function()
})
end)
it("should provide a Function node with the `self` as the first positional parameter", function()
local ast <const> = get_doc_from_page([[
<h2 class="section-header"><a name="Object_methods"></a>Object methods</h2>
<dl class="function">
<dt>
<a class="copy-link js-copy-link" name="swap" href="#swap">🔗</a>
<strong
>:swap <span class="function_args"> <b>(</b>tag2<b>)</b></span></strong
>
<span class="proptype"></span>
<span class="baseclass"> </span>
</dt>
<dd>
<h3>Parameters:</h3>
<table class="see_also">
<tbody>
<tr class="param_header">
<th>Name</th>
<th></th>
<th>Type(s)</th>
<th>Description</th>
</tr>
<tr>
<td><span class="parameter">tag2</span></td>
<td></td>
<td>
<span class="types"><span class="type">tag</span></span>
</td>
<td class="see_also_description">The second tag</td>
</tr>
</tbody>
</table>
</dd>
</dl>
]], "awful.tag")
assert.same(ast, {
children = {
{
children = {},
name = "Signal",
token = "enum",
},
{
parameters = {
{
types = { "Tag" },
name = "self",
token = "variable",
},
{
types = { "tag" }, -- This needs to be fixed : tag -> Tag
name = "tag2",
token = "variable",
}
},
return_types = {},
name = "swap",
token = "function",
},
},
name = "Tag",
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>