Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure stable IDs for dfn refs in domintro sections #2094

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bikeshed/dfnpanels.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def addDfnPanels(doc, dfns):
for i, el in enumerate(els):
refID = el.get("id")
if refID is None:
refID = f"ref-for-{id}"
if hasAncestor(el, lambda x: hasClass(x, "domintro")):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather abstract this to a method in h.dom, just to give it a bit more semantic meaning.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since this full conditional block is duplicated in unsortedtext, it would probably be good to shift the entire thing over, to a generateRefId method or something. (Feel free to use a better name.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since this full conditional block is duplicated in unsortedtext, it would probably be good to shift the entire thing over, to a generateRefId method or something. (Feel free to use a better name.)

OK will do — and to be clear, this generateRefId method should best be in h.dom?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather abstract this to a method in h.dom, just to give it a bit more semantic meaning.

OK, done now

refID = f"{id}-dev"
else:
refID = f"ref-for-{id}"
el.set("id", safeID(doc, refID))
if i == 0:
appendChild(
Expand Down
2 changes: 1 addition & 1 deletion bikeshed/h/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def dedupIDs(doc):
continue
if el.get("data-silently-dedup") is not None:
warnAboutDupes = False
if dupeId.startswith("ref-for-"):
if dupeId.startswith("ref-for-") or dupeId.endswith("-dev"):
warnAboutDupes = False
# Try to de-dup the id by appending an integer after it.
if warnAboutDupes:
Expand Down
5 changes: 4 additions & 1 deletion bikeshed/unsortedJunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,10 @@ def decorateAutolink(doc, el, linkType, linkText, ref):
if el.get("id") is None:
_, _, id = ref.url.partition("#")
if id:
el.set("id", f"ref-for-{id}")
if hasAncestor(el, lambda x: hasClass(x, "domintro")):
el.set("id", f"{id}-dev")
else:
el.set("id", f"ref-for-{id}")
el.set("data-silently-dedup", "")

# Get all the values that the type expands to, add it as a title.
Expand Down
286 changes: 143 additions & 143 deletions tests/github/WICG/app-history/spec.html

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions tests/github/WICG/cookie-store/index.html

Large diffs are not rendered by default.

568 changes: 284 additions & 284 deletions tests/github/WICG/file-system-access/index.html

Large diffs are not rendered by default.

174 changes: 87 additions & 87 deletions tests/github/WICG/kv-storage/spec.html

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions tests/github/WICG/local-font-access/index.html

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions tests/github/WICG/shape-detection-api/index-zh-cn.html

Large diffs are not rendered by default.

156 changes: 78 additions & 78 deletions tests/github/WICG/shape-detection-api/index.html

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions tests/github/WICG/shape-detection-api/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,9 @@ <h3 class="heading settled" data-level="2.2" id="text-detection-api"><span class
<dl class="domintro">
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="TextDetector" data-dfn-type="constructor" data-export data-lt="TextDetector()|constructor()" id="dom-textdetector-textdetector"><code>TextDetector()</code></dfn>
<dd>
<div class="note" role="note"> Detectors may potentially allocate and hold significant resources. Where possible, reuse the same <code class="idl"><a data-link-type="idl" href="#textdetector" id="ref-for-textdetector">TextDetector</a></code> for several detections. </div>
<div class="note" role="note"> Detectors may potentially allocate and hold significant resources. Where possible, reuse the same <code class="idl"><a data-link-type="idl" href="#textdetector" id="textdetector-dev">TextDetector</a></code> for several detections. </div>
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="TextDetector" data-dfn-type="method" data-export data-lt="detect(image)" id="dom-textdetector-detect"><code>detect(ImageBitmapSource <var>image</var>)</code></dfn>
<dd>Tries to detect text blocks in the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource" id="ref-for-imagebitmapsource">ImageBitmapSource</a></code> <var>image</var>.
<dd>Tries to detect text blocks in the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource" id="imagebitmapsource-dev">ImageBitmapSource</a></code> <var>image</var>.
</dl>
<h4 class="heading settled" data-level="2.2.1" id="detectedtext-section"><span class="secno">2.2.1. </span><span class="content"><code class="idl"><a data-link-type="idl" href="#dictdef-detectedtext" id="ref-for-dictdef-detectedtext②">DetectedText</a></code></span><a class="self-link" href="#detectedtext-section"></a></h4>
<pre class="idl highlight def"><c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-detectedtext"><code><c- g>DetectedText</c-></code></dfn> {
Expand All @@ -696,12 +696,12 @@ <h4 class="heading settled" data-level="2.2.1" id="detectedtext-section"><span c
};
</pre>
<dl class="domintro">
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-boundingbox"><code>boundingBox</code></dfn>, <span> of type <a data-link-type="idl-name" href="https://drafts.fxtf.org/geometry-1/#domrectreadonly" id="ref-for-domrectreadonly">DOMRectReadOnly</a></span>
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-boundingbox"><code>boundingBox</code></dfn>, <span> of type <a data-link-type="idl-name" href="https://drafts.fxtf.org/geometry-1/#domrectreadonly" id="domrectreadonly-dev">DOMRectReadOnly</a></span>
<dd>A rectangle indicating the position and extent of a detected feature aligned to the image
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-rawvalue"><code>rawValue</code></dfn>, <span> of type <a data-link-type="idl-name" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString">DOMString</a></span>
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-rawvalue"><code>rawValue</code></dfn>, <span> of type <a data-link-type="idl-name" href="https://heycam.github.io/webidl/#idl-DOMString" id="idl-DOMString-dev">DOMString</a></span>
<dd>Raw string detected from the image, where characters are drawn from <a data-link-type="biblio" href="#biblio-iso8859-1">[iso8859-1]</a>.
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-cornerpoints"><code>cornerPoints</code></dfn>, <span> of type FrozenArray&lt;<a data-link-type="idl-name" href="https://w3c.github.io/mediacapture-image/#Point2D" id="ref-for-Point2D">Point2D</a>></span>
<dd>A <a data-link-type="dfn" href="https://heycam.github.io/webidl/#idl-sequence" id="ref-for-idl-sequence">sequence</a> of corner points of the detected feature, in clockwise direction and starting with top-left. This is not necessarily a square due to possible perspective distortions.
<dt><dfn class="dfn-paneled idl-code" data-dfn-for="DetectedText" data-dfn-type="dict-member" data-export id="dom-detectedtext-cornerpoints"><code>cornerPoints</code></dfn>, <span> of type FrozenArray&lt;<a data-link-type="idl-name" href="https://w3c.github.io/mediacapture-image/#Point2D" id="Point2D-dev">Point2D</a>></span>
<dd>A <a data-link-type="dfn" href="https://heycam.github.io/webidl/#idl-sequence" id="idl-sequence-dev">sequence</a> of corner points of the detected feature, in clockwise direction and starting with top-left. This is not necessarily a square due to possible perspective distortions.
</dl>
<h2 class="heading settled" data-level="3" id="examples"><span class="secno">3. </span><span class="content">Examples</span><a class="self-link" href="#examples"></a></h2>
<p><i>This section is non-normative.</i></p>
Expand Down Expand Up @@ -793,19 +793,19 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
<aside class="dfn-panel" data-for="term-for-domrectreadonly">
<a href="https://drafts.fxtf.org/geometry-1/#domrectreadonly">https://drafts.fxtf.org/geometry-1/#domrectreadonly</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-domrectreadonly">2.2.1. DetectedText</a> <a href="#ref-for-domrectreadonly">(2)</a>
<li><a href="#ref-for-domrectreadonly">2.2.1. DetectedText</a> <a href="#domrectreadonly-dev">(2)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="term-for-imagebitmapsource">
<a href="https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource">https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagebitmapsource</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-imagebitmapsource">2.2. Text Detection API</a> <a href="#ref-for-imagebitmapsource①">(2)</a> <a href="#ref-for-imagebitmapsource">(3)</a>
<li><a href="#ref-for-imagebitmapsource">2.2. Text Detection API</a> <a href="#ref-for-imagebitmapsource①">(2)</a> <a href="#imagebitmapsource-dev">(3)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="term-for-idl-DOMString">
<a href="https://heycam.github.io/webidl/#idl-DOMString">https://heycam.github.io/webidl/#idl-DOMString</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-idl-DOMString">2.2.1. DetectedText</a> <a href="#ref-for-idl-DOMString">(2)</a>
<li><a href="#ref-for-idl-DOMString">2.2.1. DetectedText</a> <a href="#idl-DOMString-dev">(2)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="term-for-Exposed">
Expand Down Expand Up @@ -836,7 +836,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
<a href="https://heycam.github.io/webidl/#idl-sequence">https://heycam.github.io/webidl/#idl-sequence</a><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-idl-sequence">2.2. Text Detection API</a>
<li><a href="#ref-for-idl-sequence">2.2.1. DetectedText</a>
<li><a href="#idl-sequence-dev">2.2.1. DetectedText</a>
</ul>
</aside>
<h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
Expand Down Expand Up @@ -900,7 +900,7 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
<aside class="dfn-panel" data-for="textdetector">
<b><a href="#textdetector">#textdetector</a></b><b>Referenced in:</b>
<ul>
<li><a href="#ref-for-textdetector">2.2. Text Detection API</a> <a href="#ref-for-textdetector">(2)</a>
<li><a href="#ref-for-textdetector">2.2. Text Detection API</a> <a href="#textdetector-dev">(2)</a>
</ul>
</aside>
<aside class="dfn-panel" data-for="dom-textdetector-textdetector">
Expand Down
Loading