Skip to content

Commit

Permalink
Properly tag descriptor autolinks in the descriptor index with the at…
Browse files Browse the repository at this point in the history
…-rule they belong to, so they don't cause unfixable link errors.
  • Loading branch information
tabatkins committed Jan 23, 2020
1 parent 20a4b94 commit 71e151f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
26 changes: 17 additions & 9 deletions bikeshed/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,13 @@ def extractKeyValFromRow(tr, table):
for desc in atRules.values():
desc.sort(key=lambda x:x["Name"])

def createRow(prop, linkType):
def createRow(prop, linkType, for_=None):
attrs = {"data-link-type":linkType}
if for_:
attrs["data-link-for"] = for_
return E.tr(
E.th({"scope":"row"},
E.a({"data-link-type":linkType}, prop['Name'])),
E.a(attrs, prop['Name'])),
*[E.td(prop.get(column,"")) for column in columns[1:]])
if len(props):
# Set up the initial table columns for properties
Expand Down Expand Up @@ -559,18 +562,23 @@ def formatColumnName(name):
allKeys |= set(desc.keys())
columns.extend(sorted(allKeys - set(columns)))
id = config.simplifyText(atRuleName) + "-descriptor-table"
appendChild(html,
E.h3({"class":"no-num no-ref", "id":safeID(doc, id)},
E.a({"data-link-type":"at-rule"}, atRuleName),
" Descriptors"))
if atRuleName:
appendChild(html,
E.h3({"class":"no-num no-ref", "id":safeID(doc, id)},
E.a({"data-link-type":"at-rule"}, atRuleName),
" Descriptors"))
else:
appendChild(html,
E.h3({"class":"no-num no-ref", "id":safeID(doc, id)},
"Miscellaneous Descriptors"))
appendChild(html,
E.div({"class":"big-element-wrapper"},
E.table({"class":"index"},
E.thead(
E.thead(
E.tr(
*[E.th({"scope":"col"}, column) for column in columns])),
E.tbody(
*[createRow(desc, "descriptor") for desc in descs]))))
E.tbody(
*[createRow(desc, "descriptor", for_=atRuleName) for desc in descs]))))


def addIDLSection(doc):
Expand Down
2 changes: 1 addition & 1 deletion tests/github/w3c/csswg-drafts/css-color-4/Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -5350,7 +5350,7 @@ <h3 class="no-num no-ref heading settled" id="color-profile-descriptor-table"><s
<td>relative-colorimetric | absolute-colorimetric | perceptual | saturation
<td>relative-colorimetric
<tr>
<th scope="row"><a class="css" data-link-type="descriptor">src</a>
<th scope="row"><a class="css" data-link-type="descriptor" href="#descdef-color-profile-src" id="ref-for-descdef-color-profile-src①">src</a>
<td>&lt;url>
<td>n/a
</table>
Expand Down
4 changes: 2 additions & 2 deletions tests/github/w3c/csswg-drafts/css-fonts-4/Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -7625,7 +7625,7 @@ <h3 class="no-num no-ref heading settled" id="font-feature-values-descriptor-tab
<th scope="col">Initial
<tbody>
<tr>
<th scope="row"><a class="css" data-link-type="descriptor" href="#descdef-font-face-font-display" id="ref-for-descdef-font-face-font-display">font-display</a>
<th scope="row"><a class="css" data-link-type="descriptor" href="#descdef-font-feature-values-font-display" id="ref-for-descdef-font-feature-values-font-display">font-display</a>
<td>auto | block | swap | fallback | optional
<td>auto
</table>
Expand All @@ -7644,7 +7644,7 @@ <h3 class="no-num no-ref heading settled" id="font-palette-values-descriptor-tab
<td>&lt;integer> | &lt;string>
<td>N/A
<tr>
<th scope="row"><a class="css" data-link-type="descriptor" href="#descdef-font-face-font-family" id="ref-for-descdef-font-face-font-family">font-family</a>
<th scope="row"><a class="css" data-link-type="descriptor" href="#descdef-font-palette-values-font-family" id="ref-for-descdef-font-palette-values-font-family">font-family</a>
<td>&lt;'font-family'>
<td>N/A
<tr>
Expand Down

0 comments on commit 71e151f

Please sign in to comment.