Andy Stark 5a3ce3d299 [ADF-3230] Changes to stop doc tools from updating files unnecessarily (#3519)
* [ADF-3230] Added basic change detector to doc tools

* [ADF-3230] Updates to type linker to fix before/after inconsistencies

* [ADF-3230] Fixed comparison error caused by adjacent text blocks

* [ADF-3230] Added basic change detector to doc tools

* [ADF-3230] Updates to type linker to fix before/after inconsistencies

* [ADF-3230] Fixed comparison error caused by adjacent text blocks

* [ADF-3230] Modified props tool to remove spaces from union types

* [ADF-3230] Made ToC tool before/after state consistent
2018-06-22 13:24:38 +01:00

141 lines
2.8 KiB
JavaScript

module.exports = {
makeRoot: function (children) {
return {
"type": "root",
"children": children
};
},
makeText: function (textVal) {
return {
"type": "text",
"value": textVal
};
},
makeEmphasis: function (content) {
return {
"type": "emphasis",
"children": content
};
},
makeStrong: function (content) {
return {
"type": "strong",
"children": content
};
},
makeHeading: function (caption, depth) {
return {
"type": "heading",
"depth": depth,
"children": [caption]
};
},
makeLink: function (caption, url, title = null) {
return {
"type": "link",
"title": title,
"url": url,
"children": [ caption ]
};
},
makeListItem: function (itemValue) {
return {
"type": "listItem",
"loose": false,
"children": [ itemValue ]
};
},
makeListUnordered: function (itemsArray) {
return {
"type": "list",
"ordered": false,
"children": itemsArray,
"loose": false
};
},
makeParagraph: function (itemsArray) {
return {
"type": "paragraph",
"children": itemsArray
}
},
makeTable: function (colAlignArray, rowArray) {
return {
"type": "table",
"align": colAlignArray,
"children": rowArray
};
},
makeTableRow: function (cellArray) {
return {
"type": "tableRow",
"children": cellArray
};
},
makeTableCell: function (content) {
return {
"type": "tableCell",
"children": content
};
},
makeInlineCode: function (codeText) {
return {
"type": "inlineCode",
"value": codeText
}
},
makeHTML: function (htmlText) {
return {
"type": "html",
"value": htmlText
};
},
makeBreak: function () {
return {
"type": "break"
}
},
makeImage: function (url, alt) {
return {
"type": "image",
"url": url,
"alt": alt
}
},
isHeading: function (node) {
return node.type === "heading";
},
isListUnordered: function (node) {
return (node.type === "list") && !node.ordered;
},
isParagraph: function (node) {
return node.type === "paragraph";
},
isText: function (node) {
return node.type === "text";
},
isLink: function (node) {
return node.type === "inlineCode";
}
}