'
-
- addDefinitionTable(docsSchemaDocument, 'definition-editable-', objectBeingRendered.category, objectBeingRendered.project, objectBeingRendered.type)
-
- let editableParagraphIndex = 0
- let autoGeneratedParagraphIndex = 0
-
- if (objectBeingRendered.category === 'Topic') {
- generateMultiPageIndex()
- }
-
- addContent()
-
- HTML = HTML + '
' // Clickeable Container Ends
- HTML = HTML + '' // Common Style Container Ends
-
- /*
- Here we inject the HTML we built into the DOM at the Docs Space Div.
- */
- let docsContentDiv = document.getElementById('docs-content-div')
- docsContentDiv.innerHTML = HTML + UI.projects.superalgos.spaces.docsSpace.footer.addFooter()
-
- console.log(docsContentDiv.innerHTML)
-
- hightlightEmbeddedCode()
- detectEnterOnSearchBox()
-
- /*
- After generating the html, we will add the images at all the points we know
- there are images to be added.
- */
- addImages()
-
- function addDefinitionTable(docsSchemaDocument, idPrefix, category, project, type) {
- if (docsSchemaDocument.definition !== undefined) {
-
- let definitionText = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(docsSchemaDocument.definition)
- definitionText = definitionText + UI.projects.superalgos.utilities.docs.addWarningIfTranslationIsOutdated(docsSchemaDocument.definition)
-
- /* We will test if we can draw an image here or not*/
- let testElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, type)
-
- if ((category === 'Topic' || category === 'Concept') && testElement === undefined) {
- HTML = HTML + '
'
- }
- }
-
- function addContent() {
- HTML = HTML + '
'
- if (docsSchemaDocument.paragraphs !== undefined) {
- for (let i = 0; i < docsSchemaDocument.paragraphs.length; i++) {
- let key = 'editable-paragraph-' + editableParagraphIndex
- let paragraph = docsSchemaDocument.paragraphs[i]
-
- if (paragraph.style === "Include") {
- renderParagraph(paragraph, key)
- editableParagraphIndex++
- let error = addIncludedParagraphs(paragraph.text)
- if (error !== undefined) {
- paragraph = {
- style: "Error",
- text: error
- }
- key = 'error-paragraph-' + autoGeneratedParagraphIndex
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
- } else {
- renderParagraph(paragraph, key)
- editableParagraphIndex++
- }
- }
- }
- if (objectBeingRendered.category === 'Node') {
- autoGeneratedHtml()
- }
- HTML = HTML + '
' // Content Ends
-
- function addIncludedParagraphs(includeText) {
- let splittedIncludeText = includeText.split('->')
- let project = splittedIncludeText[0]
- let category = splittedIncludeText[1]
- let type = splittedIncludeText[2]
- let block
- let definition = false
- if (splittedIncludeText[3] === 'Definition') {
- definition = true
- } else {
- block = splittedIncludeText[3]
- }
- let includedSchemaDocument
-
- if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
- return 'Include paragraph style Syntax Error. The Project ' + project + ' could not be found. Check the Docs Include Style Syntax to learn how to include paragraphs from a different page. This error message will dissapear as soon as you fix the problem.'
- }
- switch (category) {
- case 'Node': {
- includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
- break
- }
- case 'Concept': {
- includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
- break
- }
- case 'Topic': {
- includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
- break
- }
- default: return 'Category provided (' + category + ') not valid. Use Node, Concept or Topic instead.'
- }
- if (includedSchemaDocument === undefined) {
- return category + ' document ' + type + ' not found at project ' + project
- }
- if (includedSchemaDocument.paragraphs === undefined) {
- return 'Schema Document found, but without paragraphs.'
- }
-
- if (definition === true) {
- addDefinitionTable(includedSchemaDocument, 'definition-included-', category, project, type)
- } else {
- let blockFound = false
- for (let i = 0; i < includedSchemaDocument.paragraphs.length; i++) {
-
- let key = 'included-paragraph-' + autoGeneratedParagraphIndex
- let paragraph = includedSchemaDocument.paragraphs[i]
-
- if (blockFound === false) {
- if (paragraph.style === "Block" && paragraph.text === block) {
- blockFound = true
- }
- } else {
- if (paragraph.style === "Block") {
- return // Expected return without errors
- }
- if (paragraph.style === "Include") {
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- let error = addIncludedParagraphs(paragraph.text)
- if (error !== undefined) {
- paragraph = {
- style: "Error",
- text: error
- }
- key = 'error-paragraph-' + autoGeneratedParagraphIndex
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
- } else {
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
- }
- }
- if (blockFound === false) {
- return 'Block ' + block + ' not found.'
- }
- }
- }
- }
-
- function addImages() {
- addProjectImage()
- addDefinitionImage()
- addhHerarchyImages()
-
- if (objectBeingRendered.category === 'Node') {
- addMenuItemsImages()
- addChildrenNodesPropertiesImages()
- addAttachingAndReferencingRulesImages()
- addConfigurationImages()
- }
-
- function addDefinitionImage() {
-
- for (let i = 0; i < definitionImagesArray.length; i++) {
- let imageItem = definitionImagesArray[i]
- let appSchemaDocument = SCHEMAS_BY_PROJECT.get(imageItem.project).map.appSchema.get(imageItem.type)
- let imageElement
- if (appSchemaDocument !== undefined && appSchemaDocument.icon === undefined) {
- /*
- We are checking this because there is a possibility that a different icon is specified
- for this Node Type, in that case we would override the default that is that the icon name is
- equal to the Node Type.
- */
- let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
- imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
- } else {
- imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
- }
-
- imageElement.width = "150"
- imageElement.height = "150"
-
- let definitionImageDiv = document.getElementById(imageItem.div)
- definitionImageDiv.appendChild(imageElement)
- }
- }
-
- function addhHerarchyImages() {
- for (let i = 0; i < hierarchyImagesArray.length; i++) {
- let imageItem = hierarchyImagesArray[i]
- let collectionImage
-
- if (imageItem.name === undefined) {
- let appSchemaDocument = SCHEMAS_BY_PROJECT.get(imageItem.project).map.appSchema.get(imageItem.type)
- if (appSchemaDocument.icon === undefined) {
- let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
- collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
- } else {
- collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
- }
- } else {
- collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageItem.name)
- }
-
-
- let imageElement = collectionImage.cloneNode()
-
- if (imageItem.size !== undefined) {
- imageElement.width = imageItem.size
- imageElement.height = imageItem.size
- }
-
- let hierarchyImageDiv = document.getElementById(imageItem.div)
- if (hierarchyImageDiv) { // The lower part of the table is filled with spaces that were added to the array but not to the HTML, we can ignore them.
- hierarchyImageDiv.appendChild(imageElement)
-
- }
- }
- }
-
- function addProjectImage() {
- let imageName = objectBeingRendered.project.toLowerCase().replaceAll(' ', '-')
- let imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(objectBeingRendered.project, imageName)
- imageElement.width = "50"
- imageElement.height = "50"
-
- let projectImageDiv = document.getElementById('projectImageDiv')
- projectImageDiv.appendChild(imageElement)
- }
-
- function addMenuItemsImages() {
- if (appSchemaDocument === undefined || appSchemaDocument.menuItems === undefined) { return }
- for (let i = 0; i < appSchemaDocument.menuItems.length; i++) {
- let menuItem = appSchemaDocument.menuItems[i]
- let collectionImage = getIcon()
- let imageElement = collectionImage.cloneNode()
-
- imageElement.className = "docs-collapsible-image"
-
- let parentElement = document.getElementById('docs-menu-item-' + i + '')
- let dummyImage = parentElement.childNodes[0]
- parentElement.replaceChild(imageElement, dummyImage)
-
- function getIcon() {
- if (menuItem.relatedUiObject !== undefined) {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, menuItem.relatedUiObject)
- } else {
- if (menuItem.iconPathOn !== undefined) {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(objectBeingRendered.project, menuItem.iconPathOn)
- } else {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName('Superalgos', 'bitcoin')
- }
- }
- }
- }
- }
-
- function addChildrenNodesPropertiesImages() {
- if (appSchemaDocument === undefined || appSchemaDocument.childrenNodesProperties === undefined) { return }
- for (let i = 0; i < appSchemaDocument.childrenNodesProperties.length; i++) {
- let childrenNodesProperty = appSchemaDocument.childrenNodesProperties[i]
- let collectionImage = getIcon()
- let imageElement = collectionImage.cloneNode()
-
- imageElement.className = "docs-collapsible-image"
-
- let parentElement = document.getElementById('docs-children-nodes-property-' + i + '')
- let dummyImage = parentElement.childNodes[0]
- parentElement.replaceChild(imageElement, dummyImage)
-
- function getIcon() {
- if (childrenNodesProperty.project !== undefined) {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(childrenNodesProperty.project, childrenNodesProperty.childType)
- } else {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, childrenNodesProperty.childType)
- }
- }
- }
- }
-
- function addAttachingAndReferencingRulesImages() {
- if (appSchemaDocument === undefined) { return }
-
- if (appSchemaDocument.attachingRules !== undefined) {
- if (appSchemaDocument.attachingRules.compatibleTypes !== undefined) {
- let splittedTypes = appSchemaDocument.attachingRules.compatibleTypes.split('->')
- imageForTheseNodes(splittedTypes, 'attaching-rules-compatible-types')
- }
- if (appSchemaDocument.attachingRules.incompatibleTypes !== undefined) {
- let splittedTypes = appSchemaDocument.attachingRules.incompatibleTypes.split('->')
- imageForTheseNodes(splittedTypes, 'attaching-rules-incompatible-types')
- }
- }
- if (appSchemaDocument.referencingRules !== undefined) {
- if (appSchemaDocument.referencingRules.compatibleTypes !== undefined) {
- let splittedTypes = appSchemaDocument.referencingRules.compatibleTypes.split('->')
- imageForTheseNodes(splittedTypes, 'referencing-rules-compatible-types')
- }
- if (appSchemaDocument.referencingRules.incompatibleTypes !== undefined) {
- let splittedTypes = appSchemaDocument.referencingRules.incompatibleTypes.split('->')
- imageForTheseNodes(splittedTypes, 'referencing-rules-incompatible-types')
- }
- }
-
- function imageForTheseNodes(nodeList, additionToKey) {
- for (let i = 0; i < nodeList.length; i++) {
- let listItem = nodeList[i]
- if (listItem === "") { continue }
-
- let collectionImage = getIcon()
- if (collectionImage === undefined) { continue }
- let imageElement = collectionImage.cloneNode()
-
- imageElement.className = "docs-collapsible-image"
-
- let parentElement = document.getElementById('docs-' + additionToKey + '-' + i + '')
- let dummyImage = parentElement.childNodes[0]
- parentElement.replaceChild(imageElement, dummyImage)
-
- function getIcon() {
- let splittedListItem = listItem.split('|')
- if (splittedListItem.length === 1) {
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, listItem)
- } else {
- let project = splittedListItem[0]
- let nodeType = splittedListItem[1]
- return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, nodeType)
- }
- }
- }
- }
- }
-
- function addConfigurationImages() {
- if (appSchemaDocument === undefined) { return }
- let configImageElementArray = document.getElementsByClassName('docs-configuration-property-image')
- if (configImageElementArray === undefined) { return }
-
- /*
- We need to create our own array otherwise while replacing the childElement
- we will be shrinking the array.
- */
- let imageArray = []
- for (let i = 0; i < configImageElementArray.length; i++) {
- let dummyImage = configImageElementArray[i]
- imageArray.push(dummyImage)
- }
- for (let i = 0; i < imageArray.length; i++) {
- let dummyImage = imageArray[i]
- let parentElement = dummyImage.parentNode
- let collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName('Superalgos', 'configuration')
- let imageElement = collectionImage.cloneNode()
-
- imageElement.className = "docs-collapsible-image"
- parentElement.replaceChild(imageElement, dummyImage)
- }
- }
- }
-
- function autoGeneratedHtml() {
- generateConfiguration()
- generateMenuItems()
- generateChildrenNodesProperties()
- generateAttachingRules()
- generateReferencingRules()
- generateCode()
- generateFormula()
-
- function generateMenuItems() {
- /*
- Menu Items
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || appSchemaDocument.menuItems === undefined) { return }
-
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Menu"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The " + appSchemaDocument.type + " Node has the following Node Menu items:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- for (let i = 0; i < appSchemaDocument.menuItems.length; i++) {
- let menuItem = appSchemaDocument.menuItems[i]
-
- HTML = HTML + ''
- HTML = HTML + '
'
-
- paragraph = {
- style: "Text",
- text: 'The ' + menuItem.label + ' menu item has the following properties:'
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- for (const property in menuItem) {
- paragraph = {
- style: "List",
- text: property + ": " + menuItem[property]
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
-
- HTML = HTML + '
'
- }
- paragraph = {
- style: "Success",
- text: "When any of the menu items is grayed out, it means that " + appSchemaDocument.type + " already has the type of children that that menu item can add, and that only one children is possible in that case. "
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
-
- function generateChildrenNodesProperties() {
- /*
- Children Nodes Properties
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
-
- if (appSchemaDocument === undefined || appSchemaDocument.childrenNodesProperties === undefined) { return }
-
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Children"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The " + appSchemaDocument.type + " Node has the following childrenNodesProperties which hold the Node Children at runtime:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- for (let i = 0; i < appSchemaDocument.childrenNodesProperties.length; i++) {
- let childrenNodesProperty = appSchemaDocument.childrenNodesProperties[i]
-
- let name = UI.projects.superalgos.utilities.strings.fromCamelCaseToUpperWithSpaces(childrenNodesProperty.name)
-
- HTML = HTML + ''
- HTML = HTML + '
'
-
- paragraph = {
- style: "Text",
- text: 'The ' + name + ' children node property has in turn the following properties:'
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- for (const property in childrenNodesProperty) {
- paragraph = {
- style: "List",
- text: property + ": " + childrenNodesProperty[property]
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
-
- HTML = HTML + '
'
- }
- }
-
- function generateAttachingRules() {
- /*
- Attaching Rules
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || (appSchemaDocument.attachingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return }
-
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Attaching Rules"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The following are Node Attaching Rules that govern the attacment of " + appSchemaDocument.type + " with other nodes:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- if (appSchemaDocument.attachingRules !== undefined) {
- if (appSchemaDocument.attachingRules.compatibleTypes !== undefined) {
- paragraph = {
- style: "Subtitle",
- text: "Compatible Types:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- let splittedTypes = appSchemaDocument.attachingRules.compatibleTypes.split('->')
- listAllTheseNodes(splittedTypes, 'attaching-rules-compatible-types')
- }
- if (appSchemaDocument.attachingRules.incompatibleTypes !== undefined) {
- paragraph = {
- style: "Subtitle",
- text: "Incompatible Types:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- let splittedTypes = appSchemaDocument.attachingRules.incompatibleTypes.split('->')
- listAllTheseNodes(splittedTypes, 'attaching-rules-incompatible-types')
- }
- }
-
- function listAllTheseNodes(nodeList, additionToKey) {
- for (let i = 0; i < nodeList.length; i++) {
- let listItem = nodeList[i]
- if (listItem === "") { continue }
- HTML = HTML + ''
- }
- }
- }
-
- function generateReferencingRules() {
- /*
- Referencing Rules
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || (appSchemaDocument.referencingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return }
-
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Referencing Rules"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The following are Node Referencing Rules that govern to which nodes " + appSchemaDocument.type + " can stablish a reference:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- if (appSchemaDocument.referencingRules !== undefined) {
- if (appSchemaDocument.referencingRules.compatibleTypes !== undefined) {
- paragraph = {
- style: "Subtitle",
- text: "Compatible Types:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- let splittedTypes = appSchemaDocument.referencingRules.compatibleTypes.split('->')
- listAllTheseNodes(splittedTypes, 'referencing-rules-compatible-types')
- }
- if (appSchemaDocument.referencingRules.incompatibleTypes !== undefined) {
- paragraph = {
- style: "Subtitle",
- text: "Incompatible Types:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- let splittedTypes = appSchemaDocument.referencingRules.incompatibleTypes.split('->')
- listAllTheseNodes(splittedTypes, 'referencing-rules-incompatible-types')
- }
- }
-
- function listAllTheseNodes(nodeList, additionToKey) {
- for (let i = 0; i < nodeList.length; i++) {
- let listItem = nodeList[i]
- if (listItem === "") { continue }
- HTML = HTML + ''
- }
- }
- }
-
- function generateConfiguration() {
- /*
- Configuration
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.config !== true) { return }
- paragraph = {
- style: "Subtitle",
- text: "Initial Values"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.config === undefined) { return }
-
- paragraph = {
- style: "Text",
- text: "The Initial Values for " + appSchemaDocument.type + "'s Config are:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- let initialValues = JSON.parse(appSchemaDocument.initialValues.config)
- paragraph = {
- style: "Json",
- text: JSON.stringify(initialValues, undefined, 4)
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- paragraph = {
- style: "Subtitle",
- text: "Examples"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "This is a list of properties used at the " + appSchemaDocument.type + " configuration. Expanding a property shows you sample values for that property taken from the current Workspace."
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- /*
- Here we will scan the whole workspace, first looking for nodes of the same type,
- and after that, analysing their configuration in order to extract all the properties
- they are using and sample values for each one.
- */
- /* First Step: get an array of all the nodes in the workspace of this type */
- let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
- let allNodesFound = []
- for (let i = 0; i < rootNodes.length; i++) {
- let rootNode = rootNodes[i]
- if (rootNode !== null) {
- let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
- allNodesFound = allNodesFound.concat(nodeArray)
- }
- }
- /* Second Step: create a map with all the properties used in configurations of this node type */
- let propertyMap = new Map()
- for (let i = 0; i < allNodesFound.length; i++) {
- let node = allNodesFound[i]
- let config = JSON.parse(node.config)
- for (const property in config) {
- let value = JSON.stringify(config[property], undefined, 4)
- let valueArray = propertyMap.get(property)
- if (valueArray === undefined) {
- propertyMap.set(property, [value])
- } else {
- if (valueArray.includes(value) === false) {
- if (valueArray.length <= 10) {
- valueArray.push(value)
- }
- }
- }
- }
- }
- /* Third Step: we will display the list of properties and the sample values */
- propertyMap.forEach(displayProperty)
- function displayProperty(valueArray, mapKey, map) {
-
- let name = UI.projects.superalgos.utilities.strings.fromCamelCaseToUpperWithSpaces(mapKey)
-
- HTML = HTML + ''
- HTML = HTML + '
'
-
- for (let i = 0; i < valueArray.length; i++) {
- let value = valueArray[i]
-
- paragraph = {
- style: "Json",
- text: value
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- }
-
- HTML = HTML + '
'
- }
- }
-
- function generateCode() {
- /*
- Code
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.code !== true) { return }
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Code"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "In this section we will explore " + appSchemaDocument.type + " Node Code."
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return }
-
- paragraph = {
- style: "Subtitle",
- text: "Initial Value"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The initial value for " + appSchemaDocument.type + "'s Code is:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- paragraph = {
- style: "Javascript",
- text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4)
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- paragraph = {
- style: "Subtitle",
- text: "Examples"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace."
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- /*
- Here we will scan the whole workspace, first looking for nodes of the same type,
- and after that, analysing their code in order to extract examples to show.
- */
- /* First Step: get an array of all the nodes in the workspace of this type */
- let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
- let allNodesFound = []
- for (let i = 0; i < rootNodes.length; i++) {
- let rootNode = rootNodes[i]
- if (rootNode !== null) {
- let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
- allNodesFound = allNodesFound.concat(nodeArray)
- }
- }
- /*
- Second Step: create a map with all the code examples used at this node type,
- without repeating them.
- */
- let codeMap = new Map()
- for (let i = 0; i < allNodesFound.length; i++) {
- let node = allNodesFound[i]
- codeMap.set(node.code, node.code)
- }
- /* Third Step: we will display the list of properties and the sample values */
- let exampleCounter = 1
- codeMap.forEach(displayProperty)
- function displayProperty(code, mapKey, map) {
- if (exampleCounter > 10) { return }
- HTML = HTML + ''
- HTML = HTML + '
'
- }
- }
-
- function generateFormula() {
- /*
- Formula
- */
- let paragraph
- let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
- if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.formula !== true) { return }
- paragraph = {
- style: "Title",
- text: "" + appSchemaDocument.type + " Formula"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "In this section we will explore " + appSchemaDocument.type + " Node Code."
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return }
-
- paragraph = {
- style: "Subtitle",
- text: "Initial Value"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "The initial value for " + appSchemaDocument.type + " is:"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- paragraph = {
- style: "Javascript",
- text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4)
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
-
- paragraph = {
- style: "Subtitle",
- text: "Examples"
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- paragraph = {
- style: "Text",
- text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace."
- }
- renderParagraph(paragraph, key)
- autoGeneratedParagraphIndex++
- /*
- Here we will scan the whole workspace, first looking for nodes of the same type,
- and after that, analysing their code in order to extract examples to show.
- */
- /* First Step: get an array of all the nodes in the workspace of this type */
- let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
- let allNodesFound = []
- for (let i = 0; i < rootNodes.length; i++) {
- let rootNode = rootNodes[i]
- if (rootNode !== null) {
- let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
- allNodesFound = allNodesFound.concat(nodeArray)
- }
- }
- /*
- Second Step: create a map with all the code examples used at this node type,
- without repeating them.
- */
- let codeMap = new Map()
- for (let i = 0; i < allNodesFound.length; i++) {
- let node = allNodesFound[i]
- codeMap.set(node.code, node.code)
- }
- /* Third Step: we will display the list of properties and the sample values */
- let exampleCounter = 1
- codeMap.forEach(displayProperty)
- function displayProperty(code, mapKey, map) {
- if (exampleCounter > 10) { return }
- HTML = HTML + ''
- HTML = HTML + '
'
+
+ addDefinitionTable(docsSchemaDocument, 'definition-editable-', objectBeingRendered.category, objectBeingRendered.project, objectBeingRendered.type)
+
+ let editableParagraphIndex = 0
+ let autoGeneratedParagraphIndex = 0
+
+ if (objectBeingRendered.category === 'Topic') {
+ generateMultiPageIndex()
+ }
+
+ addContent()
+
+ HTML = HTML + '
' // Clickeable Container Ends
+ HTML = HTML + '' // Common Style Container Ends
+
+ /*
+ Here we inject the HTML we built into the DOM at the Docs Space Div.
+ */
+ let docsContentDiv = document.getElementById('docs-content-div')
+ docsContentDiv.innerHTML = HTML + UI.projects.superalgos.spaces.docsSpace.footer.addFooter()
+
+ hightlightEmbeddedCode()
+ UI.projects.superalgos.spaces.docsSpace.mainSearchPage.detectEnterOnSearchBox()
+
+ /*
+ After generating the html, we will add the images at all the points we know
+ there are images to be added.
+ */
+ addImages()
+
+ function addDefinitionTable(docsSchemaDocument, idPrefix, category, project, type) {
+ if (docsSchemaDocument.definition !== undefined) {
+
+ let definitionText = UI.projects.superalgos.utilities.docs.getTextBasedOnLanguage(docsSchemaDocument.definition)
+ definitionText = definitionText + UI.projects.superalgos.utilities.docs.addWarningIfTranslationIsOutdated(docsSchemaDocument.definition)
+
+ /* We will test if we can draw an image here or not*/
+ let testElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, type)
+
+ if ((category === 'Topic' || category === 'Concept') && testElement === undefined) {
+ HTML = HTML + '
'
+ }
+ }
+
+ function addContent() {
+ HTML = HTML + '
'
+ if (docsSchemaDocument.paragraphs !== undefined) {
+ for (let i = 0; i < docsSchemaDocument.paragraphs.length; i++) {
+ let key = 'editable-paragraph-' + editableParagraphIndex
+ let paragraph = docsSchemaDocument.paragraphs[i]
+
+ if (paragraph.style === "Include") {
+ renderParagraph(paragraph, key)
+ editableParagraphIndex++
+ let error = addIncludedParagraphs(paragraph.text)
+ if (error !== undefined) {
+ paragraph = {
+ style: "Error",
+ text: error
+ }
+ key = 'error-paragraph-' + autoGeneratedParagraphIndex
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+ } else {
+ renderParagraph(paragraph, key)
+ editableParagraphIndex++
+ }
+ }
+ }
+ if (objectBeingRendered.category === 'Node') {
+ autoGeneratedHtml()
+ }
+ HTML = HTML + '
' // Content Ends
+
+ function addIncludedParagraphs(includeText) {
+ let splittedIncludeText = includeText.split('->')
+ let project = splittedIncludeText[0]
+ let category = splittedIncludeText[1]
+ let type = splittedIncludeText[2]
+ let block
+ let definition = false
+ if (splittedIncludeText[3] === 'Definition') {
+ definition = true
+ } else {
+ block = splittedIncludeText[3]
+ }
+ let includedSchemaDocument
+
+ if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
+ return 'Include paragraph style Syntax Error. The Project ' + project + ' could not be found. Check the Docs Include Style Syntax to learn how to include paragraphs from a different page. This error message will dissapear as soon as you fix the problem.'
+ }
+ switch (category) {
+ case 'Node': {
+ includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
+ break
+ }
+ case 'Concept': {
+ includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
+ break
+ }
+ case 'Topic': {
+ includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
+ break
+ }
+ default: return 'Category provided (' + category + ') not valid. Use Node, Concept or Topic instead.'
+ }
+ if (includedSchemaDocument === undefined) {
+ return category + ' document ' + type + ' not found at project ' + project
+ }
+ if (includedSchemaDocument.paragraphs === undefined) {
+ return 'Schema Document found, but without paragraphs.'
+ }
+
+ if (definition === true) {
+ addDefinitionTable(includedSchemaDocument, 'definition-included-', category, project, type)
+ } else {
+ let blockFound = false
+ for (let i = 0; i < includedSchemaDocument.paragraphs.length; i++) {
+
+ let key = 'included-paragraph-' + autoGeneratedParagraphIndex
+ let paragraph = includedSchemaDocument.paragraphs[i]
+
+ if (blockFound === false) {
+ if (paragraph.style === "Block" && paragraph.text === block) {
+ blockFound = true
+ }
+ } else {
+ if (paragraph.style === "Block") {
+ return // Expected return without errors
+ }
+ if (paragraph.style === "Include") {
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ let error = addIncludedParagraphs(paragraph.text)
+ if (error !== undefined) {
+ paragraph = {
+ style: "Error",
+ text: error
+ }
+ key = 'error-paragraph-' + autoGeneratedParagraphIndex
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+ } else {
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+ }
+ }
+ if (blockFound === false) {
+ return 'Block ' + block + ' not found.'
+ }
+ }
+ }
+ }
+
+ function addImages() {
+ addProjectImage()
+ addDefinitionImage()
+ addhHerarchyImages()
+
+ if (objectBeingRendered.category === 'Node') {
+ addMenuItemsImages()
+ addChildrenNodesPropertiesImages()
+ addAttachingAndReferencingRulesImages()
+ addConfigurationImages()
+ }
+
+ function addDefinitionImage() {
+
+ for (let i = 0; i < definitionImagesArray.length; i++) {
+ let imageItem = definitionImagesArray[i]
+ let appSchemaDocument = SCHEMAS_BY_PROJECT.get(imageItem.project).map.appSchema.get(imageItem.type)
+ let imageElement
+ if (appSchemaDocument !== undefined && appSchemaDocument.icon === undefined) {
+ /*
+ We are checking this because there is a possibility that a different icon is specified
+ for this Node Type, in that case we would override the default that is that the icon name is
+ equal to the Node Type.
+ */
+ let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
+ imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
+ } else {
+ imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
+ }
+
+ imageElement.width = "150"
+ imageElement.height = "150"
+
+ let definitionImageDiv = document.getElementById(imageItem.div)
+ definitionImageDiv.appendChild(imageElement)
+ }
+ }
+
+ function addhHerarchyImages() {
+ for (let i = 0; i < hierarchyImagesArray.length; i++) {
+ let imageItem = hierarchyImagesArray[i]
+ let collectionImage
+
+ if (imageItem.name === undefined) {
+ let appSchemaDocument = SCHEMAS_BY_PROJECT.get(imageItem.project).map.appSchema.get(imageItem.type)
+ if (appSchemaDocument.icon === undefined) {
+ let imageName = appSchemaDocument.type.toLowerCase().replaceAll(' ', '-')
+ collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageName)
+ } else {
+ collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(imageItem.project, imageItem.type)
+ }
+ } else {
+ collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(imageItem.project, imageItem.name)
+ }
+
+
+ let imageElement = collectionImage.cloneNode()
+
+ if (imageItem.size !== undefined) {
+ imageElement.width = imageItem.size
+ imageElement.height = imageItem.size
+ }
+
+ let hierarchyImageDiv = document.getElementById(imageItem.div)
+ if (hierarchyImageDiv) { // The lower part of the table is filled with spaces that were added to the array but not to the HTML, we can ignore them.
+ hierarchyImageDiv.appendChild(imageElement)
+
+ }
+ }
+ }
+
+ function addProjectImage() {
+ let imageName = objectBeingRendered.project.toLowerCase().replaceAll(' ', '-')
+ let imageElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(objectBeingRendered.project, imageName)
+ imageElement.width = "50"
+ imageElement.height = "50"
+
+ let projectImageDiv = document.getElementById('projectImageDiv')
+ projectImageDiv.appendChild(imageElement)
+ }
+
+ function addMenuItemsImages() {
+ if (appSchemaDocument === undefined || appSchemaDocument.menuItems === undefined) { return }
+ for (let i = 0; i < appSchemaDocument.menuItems.length; i++) {
+ let menuItem = appSchemaDocument.menuItems[i]
+ let collectionImage = getIcon()
+ let imageElement = collectionImage.cloneNode()
+
+ imageElement.className = "docs-collapsible-image"
+
+ let parentElement = document.getElementById('docs-menu-item-' + i + '')
+ let dummyImage = parentElement.childNodes[0]
+ parentElement.replaceChild(imageElement, dummyImage)
+
+ function getIcon() {
+ if (menuItem.relatedUiObject !== undefined) {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, menuItem.relatedUiObject)
+ } else {
+ if (menuItem.iconPathOn !== undefined) {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName(objectBeingRendered.project, menuItem.iconPathOn)
+ } else {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName('Superalgos', 'bitcoin')
+ }
+ }
+ }
+ }
+ }
+
+ function addChildrenNodesPropertiesImages() {
+ if (appSchemaDocument === undefined || appSchemaDocument.childrenNodesProperties === undefined) { return }
+ for (let i = 0; i < appSchemaDocument.childrenNodesProperties.length; i++) {
+ let childrenNodesProperty = appSchemaDocument.childrenNodesProperties[i]
+ let collectionImage = getIcon()
+ let imageElement = collectionImage.cloneNode()
+
+ imageElement.className = "docs-collapsible-image"
+
+ let parentElement = document.getElementById('docs-children-nodes-property-' + i + '')
+ let dummyImage = parentElement.childNodes[0]
+ parentElement.replaceChild(imageElement, dummyImage)
+
+ function getIcon() {
+ if (childrenNodesProperty.project !== undefined) {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(childrenNodesProperty.project, childrenNodesProperty.childType)
+ } else {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, childrenNodesProperty.childType)
+ }
+ }
+ }
+ }
+
+ function addAttachingAndReferencingRulesImages() {
+ if (appSchemaDocument === undefined) { return }
+
+ if (appSchemaDocument.attachingRules !== undefined) {
+ if (appSchemaDocument.attachingRules.compatibleTypes !== undefined) {
+ let splittedTypes = appSchemaDocument.attachingRules.compatibleTypes.split('->')
+ imageForTheseNodes(splittedTypes, 'attaching-rules-compatible-types')
+ }
+ if (appSchemaDocument.attachingRules.incompatibleTypes !== undefined) {
+ let splittedTypes = appSchemaDocument.attachingRules.incompatibleTypes.split('->')
+ imageForTheseNodes(splittedTypes, 'attaching-rules-incompatible-types')
+ }
+ }
+ if (appSchemaDocument.referencingRules !== undefined) {
+ if (appSchemaDocument.referencingRules.compatibleTypes !== undefined) {
+ let splittedTypes = appSchemaDocument.referencingRules.compatibleTypes.split('->')
+ imageForTheseNodes(splittedTypes, 'referencing-rules-compatible-types')
+ }
+ if (appSchemaDocument.referencingRules.incompatibleTypes !== undefined) {
+ let splittedTypes = appSchemaDocument.referencingRules.incompatibleTypes.split('->')
+ imageForTheseNodes(splittedTypes, 'referencing-rules-incompatible-types')
+ }
+ }
+
+ function imageForTheseNodes(nodeList, additionToKey) {
+ for (let i = 0; i < nodeList.length; i++) {
+ let listItem = nodeList[i]
+ if (listItem === "") { continue }
+
+ let collectionImage = getIcon()
+ if (collectionImage === undefined) { continue }
+ let imageElement = collectionImage.cloneNode()
+
+ imageElement.className = "docs-collapsible-image"
+
+ let parentElement = document.getElementById('docs-' + additionToKey + '-' + i + '')
+ let dummyImage = parentElement.childNodes[0]
+ parentElement.replaceChild(imageElement, dummyImage)
+
+ function getIcon() {
+ let splittedListItem = listItem.split('|')
+ if (splittedListItem.length === 1) {
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(objectBeingRendered.project, listItem)
+ } else {
+ let project = splittedListItem[0]
+ let nodeType = splittedListItem[1]
+ return UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, nodeType)
+ }
+ }
+ }
+ }
+ }
+
+ function addConfigurationImages() {
+ if (appSchemaDocument === undefined) { return }
+ let configImageElementArray = document.getElementsByClassName('docs-configuration-property-image')
+ if (configImageElementArray === undefined) { return }
+
+ /*
+ We need to create our own array otherwise while replacing the childElement
+ we will be shrinking the array.
+ */
+ let imageArray = []
+ for (let i = 0; i < configImageElementArray.length; i++) {
+ let dummyImage = configImageElementArray[i]
+ imageArray.push(dummyImage)
+ }
+ for (let i = 0; i < imageArray.length; i++) {
+ let dummyImage = imageArray[i]
+ let parentElement = dummyImage.parentNode
+ let collectionImage = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndName('Superalgos', 'configuration')
+ let imageElement = collectionImage.cloneNode()
+
+ imageElement.className = "docs-collapsible-image"
+ parentElement.replaceChild(imageElement, dummyImage)
+ }
+ }
+ }
+
+ function autoGeneratedHtml() {
+ generateConfiguration()
+ generateMenuItems()
+ generateChildrenNodesProperties()
+ generateAttachingRules()
+ generateReferencingRules()
+ generateCode()
+ generateFormula()
+
+ function generateMenuItems() {
+ /*
+ Menu Items
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || appSchemaDocument.menuItems === undefined) { return }
+
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Menu"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The " + appSchemaDocument.type + " Node has the following Node Menu items:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ for (let i = 0; i < appSchemaDocument.menuItems.length; i++) {
+ let menuItem = appSchemaDocument.menuItems[i]
+
+ HTML = HTML + ''
+ HTML = HTML + '
'
+
+ paragraph = {
+ style: "Text",
+ text: 'The ' + menuItem.label + ' menu item has the following properties:'
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ for (const property in menuItem) {
+ paragraph = {
+ style: "List",
+ text: property + ": " + menuItem[property]
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+
+ HTML = HTML + '
'
+ }
+ paragraph = {
+ style: "Success",
+ text: "When any of the menu items is grayed out, it means that " + appSchemaDocument.type + " already has the type of children that that menu item can add, and that only one children is possible in that case. "
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+
+ function generateChildrenNodesProperties() {
+ /*
+ Children Nodes Properties
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+
+ if (appSchemaDocument === undefined || appSchemaDocument.childrenNodesProperties === undefined) { return }
+
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Children"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The " + appSchemaDocument.type + " Node has the following childrenNodesProperties which hold the Node Children at runtime:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ for (let i = 0; i < appSchemaDocument.childrenNodesProperties.length; i++) {
+ let childrenNodesProperty = appSchemaDocument.childrenNodesProperties[i]
+
+ let name = UI.projects.superalgos.utilities.strings.fromCamelCaseToUpperWithSpaces(childrenNodesProperty.name)
+
+ HTML = HTML + ''
+ HTML = HTML + '
'
+
+ paragraph = {
+ style: "Text",
+ text: 'The ' + name + ' children node property has in turn the following properties:'
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ for (const property in childrenNodesProperty) {
+ paragraph = {
+ style: "List",
+ text: property + ": " + childrenNodesProperty[property]
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+
+ HTML = HTML + '
'
+ }
+ }
+
+ function generateAttachingRules() {
+ /*
+ Attaching Rules
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || (appSchemaDocument.attachingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return }
+
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Attaching Rules"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The following are Node Attaching Rules that govern the attacment of " + appSchemaDocument.type + " with other nodes:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ if (appSchemaDocument.attachingRules !== undefined) {
+ if (appSchemaDocument.attachingRules.compatibleTypes !== undefined) {
+ paragraph = {
+ style: "Subtitle",
+ text: "Compatible Types:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ let splittedTypes = appSchemaDocument.attachingRules.compatibleTypes.split('->')
+ listAllTheseNodes(splittedTypes, 'attaching-rules-compatible-types')
+ }
+ if (appSchemaDocument.attachingRules.incompatibleTypes !== undefined) {
+ paragraph = {
+ style: "Subtitle",
+ text: "Incompatible Types:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ let splittedTypes = appSchemaDocument.attachingRules.incompatibleTypes.split('->')
+ listAllTheseNodes(splittedTypes, 'attaching-rules-incompatible-types')
+ }
+ }
+
+ function listAllTheseNodes(nodeList, additionToKey) {
+ for (let i = 0; i < nodeList.length; i++) {
+ let listItem = nodeList[i]
+ if (listItem === "") { continue }
+ HTML = HTML + ''
+ }
+ }
+ }
+
+ function generateReferencingRules() {
+ /*
+ Referencing Rules
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || (appSchemaDocument.referencingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return }
+
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Referencing Rules"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The following are Node Referencing Rules that govern to which nodes " + appSchemaDocument.type + " can stablish a reference:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ if (appSchemaDocument.referencingRules !== undefined) {
+ if (appSchemaDocument.referencingRules.compatibleTypes !== undefined) {
+ paragraph = {
+ style: "Subtitle",
+ text: "Compatible Types:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ let splittedTypes = appSchemaDocument.referencingRules.compatibleTypes.split('->')
+ listAllTheseNodes(splittedTypes, 'referencing-rules-compatible-types')
+ }
+ if (appSchemaDocument.referencingRules.incompatibleTypes !== undefined) {
+ paragraph = {
+ style: "Subtitle",
+ text: "Incompatible Types:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ let splittedTypes = appSchemaDocument.referencingRules.incompatibleTypes.split('->')
+ listAllTheseNodes(splittedTypes, 'referencing-rules-incompatible-types')
+ }
+ }
+
+ function listAllTheseNodes(nodeList, additionToKey) {
+ for (let i = 0; i < nodeList.length; i++) {
+ let listItem = nodeList[i]
+ if (listItem === "") { continue }
+ HTML = HTML + ''
+ }
+ }
+ }
+
+ function generateConfiguration() {
+ /*
+ Configuration
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.config !== true) { return }
+ paragraph = {
+ style: "Subtitle",
+ text: "Initial Values"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.config === undefined) { return }
+
+ paragraph = {
+ style: "Text",
+ text: "The Initial Values for " + appSchemaDocument.type + "'s Config are:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ let initialValues = JSON.parse(appSchemaDocument.initialValues.config)
+ paragraph = {
+ style: "Json",
+ text: JSON.stringify(initialValues, undefined, 4)
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ paragraph = {
+ style: "Subtitle",
+ text: "Examples"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "This is a list of properties used at the " + appSchemaDocument.type + " configuration. Expanding a property shows you sample values for that property taken from the current Workspace."
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ /*
+ Here we will scan the whole workspace, first looking for nodes of the same type,
+ and after that, analysing their configuration in order to extract all the properties
+ they are using and sample values for each one.
+ */
+ /* First Step: get an array of all the nodes in the workspace of this type */
+ let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
+ let allNodesFound = []
+ for (let i = 0; i < rootNodes.length; i++) {
+ let rootNode = rootNodes[i]
+ if (rootNode !== null) {
+ let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
+ allNodesFound = allNodesFound.concat(nodeArray)
+ }
+ }
+ /* Second Step: create a map with all the properties used in configurations of this node type */
+ let propertyMap = new Map()
+ for (let i = 0; i < allNodesFound.length; i++) {
+ let node = allNodesFound[i]
+ let config = JSON.parse(node.config)
+ for (const property in config) {
+ let value = JSON.stringify(config[property], undefined, 4)
+ let valueArray = propertyMap.get(property)
+ if (valueArray === undefined) {
+ propertyMap.set(property, [value])
+ } else {
+ if (valueArray.includes(value) === false) {
+ if (valueArray.length <= 10) {
+ valueArray.push(value)
+ }
+ }
+ }
+ }
+ }
+ /* Third Step: we will display the list of properties and the sample values */
+ propertyMap.forEach(displayProperty)
+ function displayProperty(valueArray, mapKey, map) {
+
+ let name = UI.projects.superalgos.utilities.strings.fromCamelCaseToUpperWithSpaces(mapKey)
+
+ HTML = HTML + ''
+ HTML = HTML + '
'
+
+ for (let i = 0; i < valueArray.length; i++) {
+ let value = valueArray[i]
+
+ paragraph = {
+ style: "Json",
+ text: value
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ }
+
+ HTML = HTML + '
'
+ }
+ }
+
+ function generateCode() {
+ /*
+ Code
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.code !== true) { return }
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Code"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "In this section we will explore " + appSchemaDocument.type + " Node Code."
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return }
+
+ paragraph = {
+ style: "Subtitle",
+ text: "Initial Value"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The initial value for " + appSchemaDocument.type + "'s Code is:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ paragraph = {
+ style: "Javascript",
+ text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4)
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ paragraph = {
+ style: "Subtitle",
+ text: "Examples"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace."
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ /*
+ Here we will scan the whole workspace, first looking for nodes of the same type,
+ and after that, analysing their code in order to extract examples to show.
+ */
+ /* First Step: get an array of all the nodes in the workspace of this type */
+ let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
+ let allNodesFound = []
+ for (let i = 0; i < rootNodes.length; i++) {
+ let rootNode = rootNodes[i]
+ if (rootNode !== null) {
+ let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
+ allNodesFound = allNodesFound.concat(nodeArray)
+ }
+ }
+ /*
+ Second Step: create a map with all the code examples used at this node type,
+ without repeating them.
+ */
+ let codeMap = new Map()
+ for (let i = 0; i < allNodesFound.length; i++) {
+ let node = allNodesFound[i]
+ codeMap.set(node.code, node.code)
+ }
+ /* Third Step: we will display the list of properties and the sample values */
+ let exampleCounter = 1
+ codeMap.forEach(displayProperty)
+ function displayProperty(code, mapKey, map) {
+ if (exampleCounter > 10) { return }
+ HTML = HTML + ''
+ HTML = HTML + '
'
+ }
+ }
+
+ function generateFormula() {
+ /*
+ Formula
+ */
+ let paragraph
+ let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex
+ if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.formula !== true) { return }
+ paragraph = {
+ style: "Title",
+ text: "" + appSchemaDocument.type + " Formula"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "In this section we will explore " + appSchemaDocument.type + " Node Code."
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return }
+
+ paragraph = {
+ style: "Subtitle",
+ text: "Initial Value"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "The initial value for " + appSchemaDocument.type + " is:"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ paragraph = {
+ style: "Javascript",
+ text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4)
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+
+ paragraph = {
+ style: "Subtitle",
+ text: "Examples"
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ paragraph = {
+ style: "Text",
+ text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace."
+ }
+ renderParagraph(paragraph, key)
+ autoGeneratedParagraphIndex++
+ /*
+ Here we will scan the whole workspace, first looking for nodes of the same type,
+ and after that, analysing their code in order to extract examples to show.
+ */
+ /* First Step: get an array of all the nodes in the workspace of this type */
+ let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
+ let allNodesFound = []
+ for (let i = 0; i < rootNodes.length; i++) {
+ let rootNode = rootNodes[i]
+ if (rootNode !== null) {
+ let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode, appSchemaDocument.type)
+ allNodesFound = allNodesFound.concat(nodeArray)
+ }
+ }
+ /*
+ Second Step: create a map with all the code examples used at this node type,
+ without repeating them.
+ */
+ let codeMap = new Map()
+ for (let i = 0; i < allNodesFound.length; i++) {
+ let node = allNodesFound[i]
+ codeMap.set(node.code, node.code)
+ }
+ /* Third Step: we will display the list of properties and the sample values */
+ let exampleCounter = 1
+ codeMap.forEach(displayProperty)
+ function displayProperty(code, mapKey, map) {
+ if (exampleCounter > 10) { return }
+ HTML = HTML + ''
+ HTML = HTML + '