Skip to content

Commit bc5331d

Browse files
committed
Drop IDL extended attributes from data-type values
This is a fix for speced#2705, where the problem is that Bikeshed dies on argumentdef tables when a spec defines an IDL interface attribute or a dictionary member that comes with extended attributes, something like ``` dictionary test { required [EnforceRange] short member1; } ``` To produce the ", of type foo" content that appears next to the term in the table, Bikeshed relies on the `data-type` attribute set in the IDL block. The value of that attribute comes from a `type` field returned by widlparser. The code in Bikeshed expected that value to be a real IDL type (a simple type or a union) but that construct in widlparser is a "type with extended attributes": https://github.com/plinss/widlparser/blob/6c91beb68806fd6c206c57cecd15e455b0b6c1c1/widlparser/productions.py#L1294 As a result, the type Bikeshed sees is `[EnforceRange] short` in the above example, which cannot be directly associated with a type in Web IDL. This update gets back to actual IDL types in the `data-type` attribute, which effectively solves the problem of the ", of type foo" content generation. A new idl008 test was added to check extended attributes. One side effect of that update is that `data-type` attribute values no longer contain trailing spaces. That seems a good thing (spaces where already stripped for attributes, but not for dictionary members), but required re-generating a bunch of reference tests.
1 parent 42fedad commit bc5331d

File tree

107 files changed

+4063
-2476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4063
-2476
lines changed

bikeshed/idl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ def markup_name(
271271
readonly = "data-readonly"
272272
else:
273273
readonly = ""
274-
extraParameters = '{} data-type="{}"'.format(readonly, str(rest.type).strip())
274+
extraParameters = '{} data-type="{}"'.format(readonly, str(rest.type.type) + str(rest.type.suffix or ''))
275275
elif idlType == "dict-member":
276276
assert isinstance(construct, widlparser.DictionaryMember)
277-
extraParameters = f'data-type="{construct.type}"'
277+
extraParameters = 'data-type="{}"'.format(str(construct.type.type) + str(construct.type.suffix or ''))
278278
if construct.default is not None:
279279
value = str(construct.default).split("=", 1)[1].strip()
280280
if value.startswith("["):

tests/dict-type.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
728728
<main>
729729
<h2 class="heading settled" data-level="1" id="test"><span class="secno">1. </span><span class="content">Test</span><a class="self-link" href="#test"></a></h2>
730730
<pre class="idl highlight def"><c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-dictwithdefaults"><code><c- g>DictWithDefaults</c-></code></dfn> {
731-
<a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence" id="ref-for-idl-sequence"><c- b>sequence</c-></a>&lt;<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-long" id="ref-for-idl-long"><c- b>long</c-></a>> <a class="idl-code" data-default="[]" data-link-type="dict-member" data-type="sequence<long> " href="#dom-dictwithdefaults-arraywithdefaultempty" id="ref-for-dom-dictwithdefaults-arraywithdefaultempty"><c- g>arrayWithDefaultEmpty</c-></a> = [];
732-
<a data-link-type="idl-name" href="#dictdef-dictwithdefaults" id="ref-for-dictdef-dictwithdefaults"><c- n>DictWithDefaults</c-></a> <a class="idl-code" data-default="{}" data-link-type="dict-member" data-type="DictWithDefaults " href="#dom-dictwithdefaults-dictwithdefaultempty" id="ref-for-dom-dictwithdefaults-dictwithdefaultempty"><c- g>dictWithDefaultEmpty</c-></a> = {};
731+
<a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence" id="ref-for-idl-sequence"><c- b>sequence</c-></a>&lt;<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-long" id="ref-for-idl-long"><c- b>long</c-></a>> <a class="idl-code" data-default="[]" data-link-type="dict-member" data-type="sequence<long>" href="#dom-dictwithdefaults-arraywithdefaultempty" id="ref-for-dom-dictwithdefaults-arraywithdefaultempty"><c- g>arrayWithDefaultEmpty</c-></a> = [];
732+
<a data-link-type="idl-name" href="#dictdef-dictwithdefaults" id="ref-for-dictdef-dictwithdefaults"><c- n>DictWithDefaults</c-></a> <a class="idl-code" data-default="{}" data-link-type="dict-member" data-type="DictWithDefaults" href="#dom-dictwithdefaults-dictwithdefaultempty" id="ref-for-dom-dictwithdefaults-dictwithdefaultempty"><c- g>dictWithDefaultEmpty</c-></a> = {};
733733
};
734734
</pre>
735735
<dl>
@@ -765,8 +765,8 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
765765
</dl>
766766
<h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2>
767767
<pre class="idl highlight def"><c- b>dictionary</c-> <a href="#dictdef-dictwithdefaults"><code><c- g>DictWithDefaults</c-></code></a> {
768-
<a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence"><c- b>sequence</c-></a>&lt;<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-long"><c- b>long</c-></a>> <a class="idl-code" data-default="[]" data-link-type="dict-member" data-type="sequence<long> " href="#dom-dictwithdefaults-arraywithdefaultempty"><c- g>arrayWithDefaultEmpty</c-></a> = [];
769-
<a data-link-type="idl-name" href="#dictdef-dictwithdefaults"><c- n>DictWithDefaults</c-></a> <a class="idl-code" data-default="{}" data-link-type="dict-member" data-type="DictWithDefaults " href="#dom-dictwithdefaults-dictwithdefaultempty"><c- g>dictWithDefaultEmpty</c-></a> = {};
768+
<a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence"><c- b>sequence</c-></a>&lt;<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-long"><c- b>long</c-></a>> <a class="idl-code" data-default="[]" data-link-type="dict-member" data-type="sequence<long>" href="#dom-dictwithdefaults-arraywithdefaultempty"><c- g>arrayWithDefaultEmpty</c-></a> = [];
769+
<a data-link-type="idl-name" href="#dictdef-dictwithdefaults"><c- n>DictWithDefaults</c-></a> <a class="idl-code" data-default="{}" data-link-type="dict-member" data-type="DictWithDefaults" href="#dom-dictwithdefaults-dictwithdefaultempty"><c- g>dictWithDefaultEmpty</c-></a> = {};
770770
};
771771

772772
</pre>

tests/github/WICG/app-history/spec.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,14 +1054,14 @@ <h2 class="heading settled" data-level="2" id="navigate-event"><span class="secn
10541054
};
10551055

10561056
<c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-apphistorynavigateeventinit"><code><c- g>AppHistoryNavigateEventInit</c-></code></dfn> : <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit" id="ref-for-dictdef-eventinit"><c- n>EventInit</c-></a> {
1057-
<a data-link-type="idl-name" href="#enumdef-apphistorynavigationtype" id="ref-for-enumdef-apphistorynavigationtype①"><c- n>AppHistoryNavigationType</c-></a> <dfn class="dfn-paneled idl-code" data-default="&quot;push&quot;" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="AppHistoryNavigationType " id="dom-apphistorynavigateeventinit-navigationtype"><code><c- g>navigationType</c-></code></dfn> = "push";
1058-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑤"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-apphistorynavigateeventinit-canrespond"><code><c- g>canRespond</c-></code></dfn> = <c- b>false</c->;
1059-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑥"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-apphistorynavigateeventinit-userinitiated"><code><c- g>userInitiated</c-></code></dfn> = <c- b>false</c->;
1060-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑦"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-apphistorynavigateeventinit-hashchange"><code><c- g>hashChange</c-></code></dfn> = <c- b>false</c->;
1057+
<a data-link-type="idl-name" href="#enumdef-apphistorynavigationtype" id="ref-for-enumdef-apphistorynavigationtype①"><c- n>AppHistoryNavigationType</c-></a> <dfn class="dfn-paneled idl-code" data-default="&quot;push&quot;" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="AppHistoryNavigationType" id="dom-apphistorynavigateeventinit-navigationtype"><code><c- g>navigationType</c-></code></dfn> = "push";
1058+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑤"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean" id="dom-apphistorynavigateeventinit-canrespond"><code><c- g>canRespond</c-></code></dfn> = <c- b>false</c->;
1059+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑥"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean" id="dom-apphistorynavigateeventinit-userinitiated"><code><c- g>userInitiated</c-></code></dfn> = <c- b>false</c->;
1060+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean" id="ref-for-idl-boolean⑦"><c- b>boolean</c-></a> <dfn class="dfn-paneled idl-code" data-default="false" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="boolean" id="dom-apphistorynavigateeventinit-hashchange"><code><c- g>hashChange</c-></code></dfn> = <c- b>false</c->;
10611061
// required AppHistoryEntry destination;
10621062
// required AbortSignal signal;
1063-
<a data-link-type="idl-name" href="https://xhr.spec.whatwg.org/#formdata" id="ref-for-formdata①"><c- n>FormData</c-></a>? <dfn class="dfn-paneled idl-code" data-default="null" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="FormData? " id="dom-apphistorynavigateeventinit-formdata"><code><c- g>formData</c-></code></dfn> = <c- b>null</c->;
1064-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-any" id="ref-for-idl-any①"><c- b>any</c-></a> <dfn class="dfn-paneled idl-code" data-default="null" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="any " id="dom-apphistorynavigateeventinit-info"><code><c- g>info</c-></code></dfn> = <c- b>null</c->;
1063+
<a data-link-type="idl-name" href="https://xhr.spec.whatwg.org/#formdata" id="ref-for-formdata①"><c- n>FormData</c-></a>? <dfn class="dfn-paneled idl-code" data-default="null" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="FormData?" id="dom-apphistorynavigateeventinit-formdata"><code><c- g>formData</c-></code></dfn> = <c- b>null</c->;
1064+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-any" id="ref-for-idl-any①"><c- b>any</c-></a> <dfn class="dfn-paneled idl-code" data-default="null" data-dfn-for="AppHistoryNavigateEventInit" data-dfn-type="dict-member" data-export data-type="any" id="dom-apphistorynavigateeventinit-info"><code><c- g>info</c-></code></dfn> = <c- b>null</c->;
10651065
};
10661066

10671067
<c- b>enum</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="enum" data-export id="enumdef-apphistorynavigationtype"><code><c- g>AppHistoryNavigationType</c-></code></dfn> {
@@ -1852,14 +1852,14 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
18521852
};
18531853

18541854
<c- b>dictionary</c-> <a href="#dictdef-apphistorynavigateeventinit"><code><c- g>AppHistoryNavigateEventInit</c-></code></a> : <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit"><c- n>EventInit</c-></a> {
1855-
<a data-link-type="idl-name" href="#enumdef-apphistorynavigationtype"><c- n>AppHistoryNavigationType</c-></a> <a data-default="&quot;push&quot;" data-type="AppHistoryNavigationType " href="#dom-apphistorynavigateeventinit-navigationtype"><code><c- g>navigationType</c-></code></a> = "push";
1856-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-apphistorynavigateeventinit-canrespond"><code><c- g>canRespond</c-></code></a> = <c- b>false</c->;
1857-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-apphistorynavigateeventinit-userinitiated"><code><c- g>userInitiated</c-></code></a> = <c- b>false</c->;
1858-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-apphistorynavigateeventinit-hashchange"><code><c- g>hashChange</c-></code></a> = <c- b>false</c->;
1855+
<a data-link-type="idl-name" href="#enumdef-apphistorynavigationtype"><c- n>AppHistoryNavigationType</c-></a> <a data-default="&quot;push&quot;" data-type="AppHistoryNavigationType" href="#dom-apphistorynavigateeventinit-navigationtype"><code><c- g>navigationType</c-></code></a> = "push";
1856+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean" href="#dom-apphistorynavigateeventinit-canrespond"><code><c- g>canRespond</c-></code></a> = <c- b>false</c->;
1857+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean" href="#dom-apphistorynavigateeventinit-userinitiated"><code><c- g>userInitiated</c-></code></a> = <c- b>false</c->;
1858+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-boolean"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean" href="#dom-apphistorynavigateeventinit-hashchange"><code><c- g>hashChange</c-></code></a> = <c- b>false</c->;
18591859
// required AppHistoryEntry destination;
18601860
// required AbortSignal signal;
1861-
<a data-link-type="idl-name" href="https://xhr.spec.whatwg.org/#formdata"><c- n>FormData</c-></a>? <a data-default="null" data-type="FormData? " href="#dom-apphistorynavigateeventinit-formdata"><code><c- g>formData</c-></code></a> = <c- b>null</c->;
1862-
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-any"><c- b>any</c-></a> <a data-default="null" data-type="any " href="#dom-apphistorynavigateeventinit-info"><code><c- g>info</c-></code></a> = <c- b>null</c->;
1861+
<a data-link-type="idl-name" href="https://xhr.spec.whatwg.org/#formdata"><c- n>FormData</c-></a>? <a data-default="null" data-type="FormData?" href="#dom-apphistorynavigateeventinit-formdata"><code><c- g>formData</c-></code></a> = <c- b>null</c->;
1862+
<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-any"><c- b>any</c-></a> <a data-default="null" data-type="any" href="#dom-apphistorynavigateeventinit-info"><code><c- g>info</c-></code></a> = <c- b>null</c->;
18631863
};
18641864

18651865
<c- b>enum</c-> <a href="#enumdef-apphistorynavigationtype"><code><c- g>AppHistoryNavigationType</c-></code></a> {

0 commit comments

Comments
 (0)