Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/validation/config/rules-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions scripts/validation/domain/tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions scripts/validation/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}
}
});
Expand Down