From 75f052ee082f42d4fa555270774dcd560e276778 Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:55:49 -0700 Subject: [PATCH 1/7] Update conformance for EGs --- smpte.js | 89 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/smpte.js b/smpte.js index 7e3344a..51c00d4 100644 --- a/smpte.js +++ b/smpte.js @@ -612,6 +612,11 @@ function insertConformance(docMetadata) { return; } + if (docMetadata.pubType == smpte.EG_PUBTYPE) { + if (sec !== null) + logger_.error("EG must not contain a Conformance section."); + } + if (sec === null) { sec = document.createElement("section"); sec.id = SMPTE_CONFORMANCE_ID; @@ -632,7 +637,7 @@ function insertConformance(docMetadata) { } else { - implConformance = sec.innerText.innerHTML; + implConformance = sec.innerText; } @@ -640,36 +645,72 @@ function insertConformance(docMetadata) { logger_.error("Conformance section not used in AGs."); } - sec.innerHTML = ` -

Conformance

-

Normative text is text that describes elements of the design that are indispensable or contains the - conformance language keywords: "shall", "should", or "may". Informative text is text that is potentially - helpful to the user, but not indispensable, and can be removed, changed, or added editorially without - affecting interoperability. Informative text does not contain any conformance keywords.

+ if (docMetadata.pubType !== smpte.EG_PUBTYPE) { + + sec.innerHTML = ` +

Conformance

+

Normative text is text that describes elements of the design that are indispensable or contains the + conformance language keywords: "shall", "should", or "may". Informative text is text that is potentially + helpful to the user, but not indispensable, and can be removed, changed, or added editorially without + affecting interoperability. Informative text does not contain any conformance keywords.

+ +

All text in this document is, by default, normative, except: the Introduction, any clause explicitly + labeled as "Informative" or individual paragraphs that start with "Note:"

+ +

The keywords "shall" and "shall not" indicate requirements strictly to be followed in order to conform to the + document and from which no deviation is permitted.

+ +

The keywords, "should" and "should not" indicate that, among several possibilities, one is recommended + as particularly suitable, without mentioning or excluding others; or that a certain course of action + is preferred but not necessarily required; or that (in the negative form) a certain possibility + or course of action is deprecated but not prohibited.

+ +

The keywords "may" and "need not" indicate courses of action permissible within the limits of the document.

+ +

The keyword "reserved" indicates a provision that is not defined at this time, shall not be used, + and may be defined in the future. The keyword "forbidden" indicates "reserved" and in addition + indicates that the provision will never be defined in the future.

-

All text in this document is, by default, normative, except: the Introduction, any clause explicitly - labeled as "Informative" or individual paragraphs that start with "Note:"

+ ${implConformance} -

The keywords "shall" and "shall not" indicate requirements strictly to be followed in order to conform to the -document and from which no deviation is permitted.

+

Unless otherwise specified, the order of precedence of the types of normative information in + this document shall be as follows: Normative prose shall be the authoritative definition; + tables shall be next; then formal languages; then figures; and then any other language forms.

+ `; -

The keywords, "should" and "should not" indicate that, among several possibilities, one is recommended - as particularly suitable, without mentioning or excluding others; or that a certain course of action - is preferred but not necessarily required; or that (in the negative form) a certain possibility - or course of action is deprecated but not prohibited.

+ } else { + + sec.innerHTML = ` +

Conformance

+

This Engineering Guideline is purely informative and meant to provide tutorial information to the + industry. It does not impose Conformance Requirements and avoids the use of Conformance Notation.

-

The keywords "may" and "need not" indicate courses of action permissible within the limits of the document.

+

Engineering Guidelines frequently provide tutorial information about a Standard or Recommended Practice + and when this is the case, the user should rely on the Standards and Recommended Practices referenced for + interoperability information.

+ `; -

The keyword "reserved" indicates a provision that is not defined at this time, shall not be used, - and may be defined in the future. The keyword "forbidden" indicates "reserved" and in addition - indicates that the provision will never be defined in the future.

+ } -${implConformance} + if (docMetadata.pubType === smpte.EG_PUBTYPE) { + + const sections = document.querySelectorAll('section'); + sections.forEach((element) => { + let id = element.id; + if ((id !== "sec-front-matter") && (id !== "sec-foreword") && (id !== "sec-conformance")) { + if (element.innerText.includes("shall")) { + logger_.error(`EG must not contain Conformance Notation - "shall" found`, element); + } + if (element.innerText.includes("should")) { + logger_.error(`EG must not contain Conformance Notation - "should" found`, element); + } + if (element.innerText.includes("may")) { + logger_.error(`EG must not contain Conformance Notation - "may" found`, element); + } + } + }); + } -

Unless otherwise specified, the order of precedence of the types of normative information in - this document shall be as follows: Normative prose shall be the authoritative definition; - tables shall be next; then formal languages; then figures; and then any other language forms.

- `; } const SMPTE_FOREWORD_ID = "sec-foreword"; From 5fd7bc9bab12d77c19abee2b672b31b1a663223a Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:27:54 -0700 Subject: [PATCH 2/7] add note to documentation about no conformance --- doc/main.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/main.html b/doc/main.html index 303aa90..6c8da07 100644 --- a/doc/main.html +++ b/doc/main.html @@ -491,6 +491,9 @@

Conformance section

</section> + +

This section and additional text is not allowed for AG, OM, and EG docs.

+
From c17ea952c02ab852df768568fad1223874fec25b Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:06:40 -0700 Subject: [PATCH 3/7] account for all cases on search --- smpte.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smpte.js b/smpte.js index 51c00d4..3566904 100644 --- a/smpte.js +++ b/smpte.js @@ -698,13 +698,13 @@ function insertConformance(docMetadata) { sections.forEach((element) => { let id = element.id; if ((id !== "sec-front-matter") && (id !== "sec-foreword") && (id !== "sec-conformance")) { - if (element.innerText.includes("shall")) { + if (element.innerText.toLowerCase().includes("shall")) { logger_.error(`EG must not contain Conformance Notation - "shall" found`, element); } - if (element.innerText.includes("should")) { + if (element.innerText.toLowerCase().includes("should")) { logger_.error(`EG must not contain Conformance Notation - "should" found`, element); } - if (element.innerText.includes("may")) { + if (element.innerText.toLowerCase().includes("may")) { logger_.error(`EG must not contain Conformance Notation - "may" found`, element); } } From 212bd78f67077d21a0bbed3745d62b46f3ada8ab Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:38:10 -0700 Subject: [PATCH 4/7] changes as requested --- smpte.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/smpte.js b/smpte.js index 3566904..53f1910 100644 --- a/smpte.js +++ b/smpte.js @@ -612,8 +612,7 @@ function insertConformance(docMetadata) { return; } - if (docMetadata.pubType == smpte.EG_PUBTYPE) { - if (sec !== null) + if ((docMetadata.pubType == smpte.EG_PUBTYPE) && (sec !== null)) { logger_.error("EG must not contain a Conformance section."); } @@ -637,7 +636,7 @@ function insertConformance(docMetadata) { } else { - implConformance = sec.innerText; + implConformance = sec.innerHTML; } @@ -696,18 +695,22 @@ function insertConformance(docMetadata) { const sections = document.querySelectorAll('section'); sections.forEach((element) => { - let id = element.id; - if ((id !== "sec-front-matter") && (id !== "sec-foreword") && (id !== "sec-conformance")) { - if (element.innerText.toLowerCase().includes("shall")) { - logger_.error(`EG must not contain Conformance Notation - "shall" found`, element); - } - if (element.innerText.toLowerCase().includes("should")) { - logger_.error(`EG must not contain Conformance Notation - "should" found`, element); - } - if (element.innerText.toLowerCase().includes("may")) { - logger_.error(`EG must not contain Conformance Notation - "may" found`, element); - } + + const id = element.id; + + if (id === "sec-front-matter" || id === "sec-foreword" || id === "sec-conformance") + return; + + if (element.innerText.toLowerCase().includes("shall")) { + logger_.error(`EG must not contain Conformance Notation - "shall" found`, element); } + if (element.innerText.toLowerCase().includes("should")) { + logger_.error(`EG must not contain Conformance Notation - "should" found`, element); + } + if (element.innerText.toLowerCase().includes("may")) { + logger_.error(`EG must not contain Conformance Notation - "may" found`, element); + } + }); } From 5059528b8313f25b4ff0897700d434e032e10dc2 Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:54:00 -0700 Subject: [PATCH 5/7] update doc note --- doc/main.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/main.html b/doc/main.html index 6c8da07..d6b2251 100644 --- a/doc/main.html +++ b/doc/main.html @@ -492,7 +492,7 @@

Conformance section

-

This section and additional text is not allowed for AG, OM, and EG docs.

+

This section is prohibited when the document is an administrative guideline, operations manual or engineering guideline.

From fc85e0020123c55a73bb7983c505c3bd0164ff77 Mon Sep 17 00:00:00 2001 From: Steve LLamb <38917682+SteveLLamb@users.noreply.github.com> Date: Tue, 5 Nov 2024 09:47:02 -0800 Subject: [PATCH 6/7] updates in loop --- smpte.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/smpte.js b/smpte.js index 53f1910..ec62007 100644 --- a/smpte.js +++ b/smpte.js @@ -693,25 +693,24 @@ function insertConformance(docMetadata) { if (docMetadata.pubType === smpte.EG_PUBTYPE) { - const sections = document.querySelectorAll('section'); - sections.forEach((element) => { - - const id = element.id; - + for (let section of document.querySelectorAll("body > section")) { + + let id = section.id; + if (id === "sec-front-matter" || id === "sec-foreword" || id === "sec-conformance") - return; + continue; - if (element.innerText.toLowerCase().includes("shall")) { - logger_.error(`EG must not contain Conformance Notation - "shall" found`, element); + if (section.innerText.toLowerCase().includes("shall")) { + logger_.error(`EG must not contain Conformance Notation - "shall" found`, section); } - if (element.innerText.toLowerCase().includes("should")) { - logger_.error(`EG must not contain Conformance Notation - "should" found`, element); + if (section.innerText.toLowerCase().includes("should")) { + logger_.error(`EG must not contain Conformance Notation - "should" found`, section); } - if (element.innerText.toLowerCase().includes("may")) { - logger_.error(`EG must not contain Conformance Notation - "may" found`, element); + if (section.innerText.toLowerCase().includes("may")) { + logger_.error(`EG must not contain Conformance Notation - "may" found`, section); } - }); + }; } } From 1629690051e87be9a569082aca8e5fabe397cbc5 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Sat, 21 Dec 2024 16:05:08 -0800 Subject: [PATCH 7/7] Improve conformance notation matching Add test --- doc/main.html | 2 +- smpte.js | 55 +++++++++---------- .../html/validation/eg-conformance-valid.html | 27 +++++++++ 3 files changed, 54 insertions(+), 30 deletions(-) create mode 100644 test/resources/html/validation/eg-conformance-valid.html diff --git a/doc/main.html b/doc/main.html index d6b2251..7b86bc8 100644 --- a/doc/main.html +++ b/doc/main.html @@ -492,7 +492,7 @@

Conformance section

-

This section is prohibited when the document is an administrative guideline, operations manual or engineering guideline.

+

This section is prohibited unless the document is a Standard or Recommended Practice.

diff --git a/smpte.js b/smpte.js index ec62007..5eeb876 100644 --- a/smpte.js +++ b/smpte.js @@ -606,14 +606,11 @@ function insertConformance(docMetadata) { let sec = document.getElementById(SMPTE_CONFORMANCE_ID); - if (docMetadata.pubType == smpte.OM_PUBTYPE) { + if (!(docMetadata.pubType == smpte.RP_PUBTYPE || docMetadata.pubType == smpte.ST_PUBTYPE)) { if (sec !== null) - logger_.error("OM must not contain a Conformance section."); - return; - } - - if ((docMetadata.pubType == smpte.EG_PUBTYPE) && (sec !== null)) { - logger_.error("EG must not contain a Conformance section."); + logger_.error(`An ${docMetadata.pubType} document must not contain a conformance section`); + if (docMetadata.pubType != smpte.EG_PUBTYPE) + return; } if (sec === null) { @@ -691,28 +688,6 @@ function insertConformance(docMetadata) { } - if (docMetadata.pubType === smpte.EG_PUBTYPE) { - - for (let section of document.querySelectorAll("body > section")) { - - let id = section.id; - - if (id === "sec-front-matter" || id === "sec-foreword" || id === "sec-conformance") - continue; - - if (section.innerText.toLowerCase().includes("shall")) { - logger_.error(`EG must not contain Conformance Notation - "shall" found`, section); - } - if (section.innerText.toLowerCase().includes("should")) { - logger_.error(`EG must not contain Conformance Notation - "should" found`, section); - } - if (section.innerText.toLowerCase().includes("may")) { - logger_.error(`EG must not contain Conformance Notation - "may" found`, section); - } - - }; - } - } const SMPTE_FOREWORD_ID = "sec-foreword"; @@ -1280,6 +1255,27 @@ function resolveLinks(docMetadata) { } } +const CONFORMANCE_RE = /\s*(shall)|(should)|(may)\s/i; + +function checkConformanceNotation(docMetadata) { + if (docMetadata.pubType !== smpte.EG_PUBTYPE) + return; + + for (let section of document.querySelectorAll("section:not(:has(section))")) { + + const id = section.id; + + if (id === SMPTE_FRONT_MATTER_ID || id === SMPTE_FOREWORD_ID || id === SMPTE_CONFORMANCE_ID) + continue; + + const r = CONFORMANCE_RE.exec(section.innerText); + + if (r !== null) + logger_.error(`An EG must not contain the conformance notation ${r[1]}`, section); + + }; +} + function asyncInsertSnippets() { return Promise.all(Array.from( document.querySelectorAll("pre[data-include]"), @@ -1326,6 +1322,7 @@ async function render() { let docMetadata = loadDocMetadata(); insertIconLink(); + checkConformanceNotation(docMetadata); insertFrontMatter(docMetadata); insertForeword(docMetadata); insertIntroduction(docMetadata); diff --git a/test/resources/html/validation/eg-conformance-valid.html b/test/resources/html/validation/eg-conformance-valid.html new file mode 100644 index 0000000..9af0ba8 --- /dev/null +++ b/test/resources/html/validation/eg-conformance-valid.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + Title of the document + + +
+

This is the scope of the document.

+
+
+

A

+

The cat is blue.

+
+ + \ No newline at end of file