Skip to content

Commit a842a2e

Browse files
committed
Update restrictReferences logic for removing unused definitions.
Remove unused definitions not defined in this spec.
1 parent ca800b3 commit a842a2e

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

common/common.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
//
66
// Add class "preserve" to a definition to ensure it is not removed.
77
//
8-
// the termlist is in a block of class "termlist", so make sure that
9-
// has an ID and put that ID into the termLists array so we can
10-
// interrogate all of the included termlists later.
8+
// the termlist is in a block of class "termlist".
119
const termNames = [] ;
12-
const termLists = [] ;
1310
const termsReferencedByTerms = [] ;
1411

1512
function restrictReferences(utils, content) {
@@ -33,7 +30,6 @@ function restrictReferences(utils, content) {
3330

3431
const $container = $(".termlist", base) ;
3532
const containerID = $container.makeID("", "terms") ;
36-
termLists.push(containerID) ;
3733
return (base.innerHTML);
3834
}
3935

@@ -99,14 +95,25 @@ require(["core/pubsubhub"], (respecEvents) => {
9995
// delete any terms that were not referenced.
10096
for (const term in termNames) {
10197
const $p = $("#"+term);
102-
if ($p.length > 0) {
103-
const tList = $p.getDfnTitles();
104-
$p.parent().next().remove(); // remove dd
105-
$p.remove(); // remove dt
106-
for (const item of tList) {
107-
if (respecConfig.definitionMap[item]) {
108-
delete respecConfig.definitionMap[item];
109-
}
98+
// Remove term definitions inside a dt, where data-cite does not start with shortname
99+
if ($p === undefined) { continue; }
100+
if (!$p.parent().is("dt")) { continue; }
101+
if (($p.data("cite") || "").toLowerCase().startsWith(respecConfig.shortName)) { continue; }
102+
103+
const $dt = $p.parent();
104+
const $dd = $dt.next();
105+
106+
// If the associated dd contains a dfn which is _not_ in termNames, warn
107+
if ($dd.children("dfn").length > 0) {
108+
console.log(term + " definition contains definitions " + $dd.children("dfn").attr("id"))
109+
}
110+
console.log("drop term " + term);
111+
const tList = $p.getDfnTitles();
112+
$dd.remove(); // remove dd
113+
$dt.remove(); // remove dt
114+
for (const item of tList) {
115+
if (respecConfig.definitionMap[item]) {
116+
delete respecConfig.definitionMap[item];
110117
}
111118
}
112119
}

index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ <h2>Terminology</h2>
352352
and defines terms specific to JSON-LD.</p>
353353

354354
<div data-include="common/terms.html"
355-
data-oninclude="exportReferences">
356-
<!-- Mark these terms for export to be shared by related specs-->
355+
data-oninclude="restrictReferences">
357356
</div>
358357

359358
<section>
@@ -362,8 +361,7 @@ <h4>Algorithm Terms</h4>
362361
<p>The Following terms are used within specific algorithms.</p>
363362

364363
<div data-include="common/algorithm-terms.html"
365-
data-oninclude="exportReferences">
366-
<!-- Mark these terms for export to be shared by related specs-->
364+
data-oninclude="restrictReferences">
367365
</div>
368366
</section>
369367

0 commit comments

Comments
 (0)