Skip to content

Commit 5c34c08

Browse files
Update conformance for EGs (#287)
* Update conformance for EGs * add note to documentation about no conformance * account for all cases on search * changes as requested * update doc note * updates in loop * Improve conformance notation matching Add test --------- Co-authored-by: Pierre-Anthony Lemieux <[email protected]>
1 parent 193dd3f commit 5c34c08

File tree

3 files changed

+97
-27
lines changed

3 files changed

+97
-27
lines changed

doc/main.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ <h4>Conformance section</h4>
497497
&lt;/section&gt;
498498
</pre>
499499
</div>
500+
501+
<p>This section is prohibited unless the document is a Standard or Recommended Practice.</p>
502+
500503
</section>
501504

502505
<section id="sec-norm-refs-section">

smpte.js

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,11 @@ function insertConformance(docMetadata) {
606606

607607
let sec = document.getElementById(SMPTE_CONFORMANCE_ID);
608608

609-
if (docMetadata.pubType == smpte.OM_PUBTYPE) {
609+
if (!(docMetadata.pubType == smpte.RP_PUBTYPE || docMetadata.pubType == smpte.ST_PUBTYPE)) {
610610
if (sec !== null)
611-
logger_.error("OM must not contain a Conformance section.");
612-
return;
611+
logger_.error(`An ${docMetadata.pubType} document must not contain a conformance section`);
612+
if (docMetadata.pubType != smpte.EG_PUBTYPE)
613+
return;
613614
}
614615

615616
if (sec === null) {
@@ -632,44 +633,61 @@ function insertConformance(docMetadata) {
632633

633634
} else {
634635

635-
implConformance = sec.innerText.innerHTML;
636+
implConformance = sec.innerHTML;
636637

637638
}
638639

639640
} else if (sec.innerText.trim().length !== 0) {
640641
logger_.error("Conformance section not used in AGs.");
641642
}
642643

643-
sec.innerHTML = `
644-
<h2>Conformance</h2>
645-
<p>Normative text is text that describes elements of the design that are indispensable or contains the
646-
conformance language keywords: "shall", "should", or "may". Informative text is text that is potentially
647-
helpful to the user, but not indispensable, and can be removed, changed, or added editorially without
648-
affecting interoperability. Informative text does not contain any conformance keywords. </p>
644+
if (docMetadata.pubType !== smpte.EG_PUBTYPE) {
645+
646+
sec.innerHTML = `
647+
<h2>Conformance</h2>
648+
<p>Normative text is text that describes elements of the design that are indispensable or contains the
649+
conformance language keywords: "shall", "should", or "may". Informative text is text that is potentially
650+
helpful to the user, but not indispensable, and can be removed, changed, or added editorially without
651+
affecting interoperability. Informative text does not contain any conformance keywords. </p>
652+
653+
<p>All text in this document is, by default, normative, except: the Introduction, any clause explicitly
654+
labeled as "Informative" or individual paragraphs that start with "Note:" </p>
655+
656+
<p>The keywords "shall" and "shall not" indicate requirements strictly to be followed in order to conform to the
657+
document and from which no deviation is permitted.</p>
658+
659+
<p>The keywords, "should" and "should not" indicate that, among several possibilities, one is recommended
660+
as particularly suitable, without mentioning or excluding others; or that a certain course of action
661+
is preferred but not necessarily required; or that (in the negative form) a certain possibility
662+
or course of action is deprecated but not prohibited.</p>
649663
650-
<p>All text in this document is, by default, normative, except: the Introduction, any clause explicitly
651-
labeled as "Informative" or individual paragraphs that start with "Note:" </p>
664+
<p>The keywords "may" and "need not" indicate courses of action permissible within the limits of the document. </p>
652665
653-
<p>The keywords "shall" and "shall not" indicate requirements strictly to be followed in order to conform to the
654-
document and from which no deviation is permitted.</p>
666+
<p>The keyword "reserved" indicates a provision that is not defined at this time, shall not be used,
667+
and may be defined in the future. The keyword "forbidden" indicates "reserved" and in addition
668+
indicates that the provision will never be defined in the future.</p>
655669
656-
<p>The keywords, "should" and "should not" indicate that, among several possibilities, one is recommended
657-
as particularly suitable, without mentioning or excluding others; or that a certain course of action
658-
is preferred but not necessarily required; or that (in the negative form) a certain possibility
659-
or course of action is deprecated but not prohibited.</p>
670+
${implConformance}
660671
661-
<p>The keywords "may" and "need not" indicate courses of action permissible within the limits of the document. </p>
672+
<p>Unless otherwise specified, the order of precedence of the types of normative information in
673+
this document shall be as follows: Normative prose shall be the authoritative definition;
674+
tables shall be next; then formal languages; then figures; and then any other language forms.</p>
675+
`;
662676

663-
<p>The keyword "reserved" indicates a provision that is not defined at this time, shall not be used,
664-
and may be defined in the future. The keyword "forbidden" indicates "reserved" and in addition
665-
indicates that the provision will never be defined in the future.</p>
677+
} else {
678+
679+
sec.innerHTML = `
680+
<h2>Conformance</h2>
681+
<p>This Engineering Guideline is purely informative and meant to provide tutorial information to the
682+
industry. It does not impose Conformance Requirements and avoids the use of Conformance Notation.</p>
666683
667-
${implConformance}
684+
<p>Engineering Guidelines frequently provide tutorial information about a Standard or Recommended Practice
685+
and when this is the case, the user should rely on the Standards and Recommended Practices referenced for
686+
interoperability information.</p>
687+
`;
688+
689+
}
668690

669-
<p>Unless otherwise specified, the order of precedence of the types of normative information in
670-
this document shall be as follows: Normative prose shall be the authoritative definition;
671-
tables shall be next; then formal languages; then figures; and then any other language forms.</p>
672-
`;
673691
}
674692

675693
const SMPTE_FOREWORD_ID = "sec-foreword";
@@ -1237,6 +1255,27 @@ function resolveLinks(docMetadata) {
12371255
}
12381256
}
12391257

1258+
const CONFORMANCE_RE = /\s*(shall)|(should)|(may)\s/i;
1259+
1260+
function checkConformanceNotation(docMetadata) {
1261+
if (docMetadata.pubType !== smpte.EG_PUBTYPE)
1262+
return;
1263+
1264+
for (let section of document.querySelectorAll("section:not(:has(section))")) {
1265+
1266+
const id = section.id;
1267+
1268+
if (id === SMPTE_FRONT_MATTER_ID || id === SMPTE_FOREWORD_ID || id === SMPTE_CONFORMANCE_ID)
1269+
continue;
1270+
1271+
const r = CONFORMANCE_RE.exec(section.innerText);
1272+
1273+
if (r !== null)
1274+
logger_.error(`An EG must not contain the conformance notation ${r[1]}`, section);
1275+
1276+
};
1277+
}
1278+
12401279
function asyncInsertSnippets() {
12411280
return Promise.all(Array.from(
12421281
document.querySelectorAll("pre[data-include]"),
@@ -1283,6 +1322,7 @@ async function render() {
12831322
let docMetadata = loadDocMetadata();
12841323

12851324
insertIconLink();
1325+
checkConformanceNotation(docMetadata);
12861326
insertFrontMatter(docMetadata);
12871327
insertForeword(docMetadata);
12881328
insertIntroduction(docMetadata);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html>
3+
<head itemscope="itemscope" itemtype="http://smpte.org/standards/documents">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="x-ua-compatible" content="ie=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<script type="module" src="../../../../smpte.js"></script>
8+
<meta itemprop="test" content="valid" />
9+
<meta itemprop="pubType" content="EG" />
10+
<meta itemprop="pubNumber" content="429" />
11+
<meta itemprop="pubPart" content="6" />
12+
<meta itemprop="pubSuiteTitle" content="Suite title" />
13+
<meta itemprop="pubTC" content="27C" />
14+
<meta itemprop="pubStage" content="WD" />
15+
<meta itemprop="pubState" content="draft" />
16+
<title>Title of the document</title>
17+
</head>
18+
<body>
19+
<section id="sec-scope">
20+
<p>This is the scope of the document.</p>
21+
</section>
22+
<section id="sec-a">
23+
<h2>A</h2>
24+
<p>The cat is blue.</p>
25+
</section>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)