diff --git a/scripts/validation/config/rules-tutorials.yml b/scripts/validation/config/rules-tutorials.yml index 224c4496..ab365c8d 100644 --- a/scripts/validation/config/rules-tutorials.yml +++ b/scripts/validation/config/rules-tutorials.yml @@ -34,7 +34,12 @@ format: markdown errorMessage: Missing 'Required Hardware and Software' section. -- regex: "\\s[\\*_][^*_](?:.*?)[\\*_]" +- regex: "(?<=\\s)\\*[^* ].*\\*[^*]" + shouldMatch: false + format: markdown + errorMessage: The use of italic emphasis is discouraged. + +- regex: "(?<=\\s)_[^_].*_[^_]" shouldMatch: false format: markdown errorMessage: The use of italic emphasis is discouraged. diff --git a/scripts/validation/domain/tutorial.js b/scripts/validation/domain/tutorial.js index 954e8a17..db90deaa 100644 --- a/scripts/validation/domain/tutorial.js +++ b/scripts/validation/domain/tutorial.js @@ -78,10 +78,6 @@ var Tutorial = class Tutorial { return files.map(file => file.split("?")[0]); } - get metadataPath(){ - return this.basePath + "/metadata.json"; - } - get metadata(){ try { let rawData = fs.readFileSync(this.path).toString(); diff --git a/scripts/validation/validate.js b/scripts/validation/validate.js index cf59b77a..3fb3ef94 100644 --- a/scripts/validation/validate.js +++ b/scripts/validation/validate.js @@ -32,30 +32,30 @@ validator.addValidation(async (tutorials) => { tutorials.forEach(tutorial => { let jsonData = tutorial.metadata; if(!jsonData) { - const errorMessage = "No metadata file found"; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath)); + const errorMessage = "No metadata found"; + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); return; } try { if(!jsonData.coverImage){ const errorMessage = "No cover image found"; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath)); + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); } else if (jsonData.coverImage.indexOf(".svg") == -1) { const errorMessage = "Cover image is not in SVG format."; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath)); + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); } let jsonSchema = JSON.parse(fs.readFileSync(config.metadataSchema)); let validationResult = validate(jsonData, jsonSchema); if(validationResult.errors.length != 0){ const errorMessage = `An error occurred while validating the metadata ${validationResult}`; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath)); + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); } } catch (error) { const errorMessage = "An error occurred while parsing the metadata"; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath)); + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); } }); return errorsOccurred; @@ -96,8 +96,8 @@ validator.addValidation(async (tutorials) => { let image = htmlDoc.querySelector("image") // Detect if there are embedded images that are actually rendered if(image.attributes.width || image.attributes.height){ - const errorMessage = path + " containes embedded binary images"; - errorsOccurred.push(new ValidationError(errorMessage, tutorial.path)); + const errorMessage = path + " contains embedded binary images."; + errorsOccurred.push(new ValidationError(errorMessage, tutorial.path, "warning")); } } });