Skip to content

Commit ac0d420

Browse files
committed
Linkify the type lines in argumentdef blocks. Fixes #1252
1 parent 4d52fbb commit ac0d420

File tree

3 files changed

+885
-8
lines changed

3 files changed

+885
-8
lines changed

bikeshed/unsortedJunk.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from urllib import parse
66
from PIL import Image
77

8-
from . import biblio, config, dfnpanels, h, func, t, messages as m
8+
from . import biblio, config, dfnpanels, h, func, t, messages as m, idl
99

1010

1111
class MarkdownCodeSpans(func.Functor):
@@ -1391,19 +1391,26 @@ def formatArgumentdefTables(doc: "t.SpecType"):
13911391
m.die(f"Can't find method '{forMethod}'.", el=table)
13921392
continue
13931393
for tr in h.findAll("tbody > tr", table):
1394-
tds = h.findAll("td", tr)
1395-
argName = h.textContent(tds[0]).strip()
1394+
try:
1395+
argCell, typeCell, nullCell, optCell, descCell = h.findAll("td", tr)
1396+
except:
1397+
m.die(
1398+
f"In the argumentdef table for '{method.full_name}', the '{argName}' line is misformatted, with {len(h.findAll('td', tr))} cells instead of 5.",
1399+
el=table,
1400+
)
1401+
continue
1402+
argName = h.textContent(argCell).strip()
13961403
arg = method.find_argument(argName)
13971404
if arg:
1398-
h.appendChild(tds[1], str(arg.type))
1405+
h.appendChild(typeCell, idl.nodesFromType(arg.type)),
13991406
if str(arg.type).strip().endswith("?"):
1400-
h.appendChild(tds[2], h.E.span({"class": "yes"}, "✔"))
1407+
h.appendChild(nullCell, h.E.span({"class": "yes"}, "✔"))
14011408
else:
1402-
h.appendChild(tds[2], h.E.span({"class": "no"}, "✘"))
1409+
h.appendChild(nullCell, h.E.span({"class": "no"}, "✘"))
14031410
if arg.optional:
1404-
h.appendChild(tds[3], h.E.span({"class": "yes"}, "✔"))
1411+
h.appendChild(optCell, h.E.span({"class": "yes"}, "✔"))
14051412
else:
1406-
h.appendChild(tds[3], h.E.span({"class": "no"}, "✘"))
1413+
h.appendChild(optCell, h.E.span({"class": "no"}, "✘"))
14071414
else:
14081415
m.die(
14091416
f"Can't find the '{argName}' argument of method '{method.full_name}' in the argumentdef block.",

tests/idl007.bs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<pre class=metadata>
2+
Title: Foo
3+
Group: test
4+
Shortname: foo
5+
Level: 1
6+
Status: LS
7+
ED: http://example.com/foo
8+
Abstract: Testing argumentdef blocks.
9+
Editor: Example Editor
10+
Date: 1970-01-01
11+
</pre>
12+
13+
<xmp class=idl>
14+
enum BarEnum { "", "bar" };
15+
interface Foo {
16+
undefined foo(
17+
Promise<(DOMString or unsigned long or BarEnum)?> a,
18+
any b,
19+
([Clamp] unsigned long? or sequence<record<DOMString, [Exposed=(Window, Worker)] short>>) c
20+
);
21+
};
22+
</xmp>
23+
<pre class="argumentdef" for="Foo/foo()">
24+
a: A complex promise
25+
b: A nullable any
26+
c: Unions and HKTs and extended attributes, oh my!
27+
</pre>
28+

0 commit comments

Comments
 (0)