@@ -21,38 +21,12 @@ module.exports = [
2121} ,
2222{
2323 names : [ "PATTERN-TEMPLATE-RULE-002" ] ,
24- description : "Standard Headlines" ,
25- tags : [ "headings" , "headers" , "pattern-template" ] ,
26- function : ( params , onError ) => {
27- var allowedHeadlines = "Title|Patlet|Problem|Story|Context|Forces|Solutions|Resulting Context|Known Instances|Status|Author(s)|Acknowledgements" ;
28- var re = new RegExp ( `^## (${ allowedHeadlines . replace ( / (? = [ \( \) ] ) / g, '\\' ) } )\\s*$` , "m" ) ;
29- // console.log(re);
30-
31- params . tokens . filter ( function filterToken ( token ) {
32- return token . type === "heading_open" ;
33- } ) . forEach ( function forToken ( token ) {
34- if ( token . tag === "h2" ) {
35- if ( re . test ( token . line ) ) {
36- return ;
37- }
38- // if (/^## ()$/m.test(token.line)) {
39- // return;
40- // }
41-
42- return onError ( {
43- lineNumber : token . lineNumber ,
44- detail : "Allowed types are: " + allowedHeadlines . replace ( / \| / g, ', ' ) ,
45- context : token . line
46- } ) ;
47- }
48- } ) ;
49- }
50- } ,
51- {
52- names : [ "PATTERN-TEMPLATE-RULE-003" ] ,
5324 description : "Mandatory template sections" ,
25+ information : new URL ( "https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/meta/pattern-template.md" ) ,
5426 tags : [ "headings" , "headers" , "pattern-template" ] ,
5527 function : ( params , onError ) => {
28+ // A list of all mandatory headlines.
29+ // headline name (from template): regexp of all permitted headline spellings
5630 var mandatoryHeadlines = {
5731 "Title" : "Title" ,
5832 "Patlet" : "Patlet" ,
@@ -68,8 +42,8 @@ module.exports = [
6842
6943 var collectedHeadlines = ""
7044
71- // collect all h2 headlines
72- // (only the headline text itself , removing markdown sytnax and whitespace)
45+ // Collect all h2 (##) headlines.
46+ // Only the headline text, removing markdown and whitespaces.
7347 params . tokens . filter ( function filterToken ( token ) {
7448 return token . type === "heading_open" ;
7549 } ) . forEach ( function forToken ( token ) {
@@ -83,7 +57,7 @@ module.exports = [
8357 }
8458 } ) ;
8559
86- // confirm if all `mandatoryHeadlines` exist exactly once in the `collectedHeadlines`
60+ // confirm if all `mandatoryHeadlines` exist and exist exactly once in the `collectedHeadlines`
8761 var errorsFound = [ ] ;
8862
8963 let headline ;
0 commit comments