Skip to content

Commit

Permalink
Merge pull request #304 from pkalita-lbl/reference-guide-fixes
Browse files Browse the repository at this point in the history
Reference guide fixes
  • Loading branch information
ddooley authored Apr 27, 2022
2 parents ba8b936 + 601fa75 commit ecf8cba
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions script/data-harmonizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ let DataHarmonizer = {
*/
renderReference: function(mystyle = null) {

schema_template = this.schema['specifications'][this.template_name]
let schema_template = this.schema['specifications'][this.template_name]

let style = `
body {
Expand Down Expand Up @@ -419,12 +419,14 @@ let DataHarmonizer = {
table td {vertical-align: top; padding:5px;}
table td.label {font-weight:bold;}
ul { padding: 0; }
`;

if (mystyle != null)
style == mystyle;
style = mystyle;

row_html = '';
let row_html = '';
for (section of this.template) {

row_html +=
Expand All @@ -434,7 +436,7 @@ let DataHarmonizer = {
`
for (slot of section.children) {

slot_dict = this.getCommentDict(slot);
const slot_dict = this.getCommentDict(slot);

row_html +=
`<tr>
Expand Down Expand Up @@ -1330,16 +1332,20 @@ let DataHarmonizer = {
let guide = {
title: field.title,
description: field.description || '',
guidance: field.comments || [],
guidance: '',
examples: '',
metadata_status: field.metadata_status || ''
}

let guidance = [];
if (field.comments && field.comments.length) {
guidance = guidance.concat(field.comments);
}
if (field.pattern) {
guide.guidance.push('Pattern as regular expression: ' + field.pattern);
guidance.push('Pattern as regular expression: ' + field.pattern);
}
if (field.string_serialization) {
guide.guidance.push('Pattern hint: ' + field.string_serialization);
guidance.push('Pattern hint: ' + field.string_serialization);
}
const hasMinValue = field.minimum_value != null;
const hasMaxValue = field.maximum_value != null;
Expand All @@ -1352,10 +1358,10 @@ let DataHarmonizer = {
} else if (hasMaxValue) {
paragraph += `less than or equal to ${field.maximum_value}.`
}
guide.guidance.push(paragraph);
guidance.push(paragraph);
}

guide.guidance = guide.guidance
guide.guidance = guidance
.map(function (paragraph) {
return '<p>' + paragraph + '</p>';
})
Expand All @@ -1367,7 +1373,7 @@ let DataHarmonizer = {
for (const [key, item] of Object.entries(field.examples)) {
if (item.value.trim().length > 0) {
examples.push(item.value);
}
}
}
guide.examples = '<ul><li>' + examples.join('</li>\n<li>') + '</li></ul>'
}
Expand Down

0 comments on commit ecf8cba

Please sign in to comment.