@Christoph-Hart said in Looking into the hise_documentation on GitHub- any reason why a majority of the markdown files are empty for the Scripting API?:
Aw poor @VirtualVirgin that was half an hour that you'll never get back
"Aw poor @VirtualVirgin that was half an hour that you'll never get back"
No worries! Was learning how to generate markdown files from text.
I made text files of all of the classes in the API, then ran a python script to transform it to markdown. Just a learning experience. I then went on the generate JSON for the API with the following schema:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Scripting API Method",
"type": "object",
"properties": {
"class": {
"type": "string",
"description": "The class this method belongs to."
},
"method": {
"type": "string",
"description": "The method name."
},
"description": {
"type": "string",
"description": "A description of what the method does."
},
"syntax": {
"type": "string",
"description": "The usage syntax string for the method."
},
"parameters": {
"type": "array",
"description": "List of method parameters.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The parameter name."
},
"type": {
"type": "string",
"description": "The parameter type."
},
"optional": {
"type": "boolean",
"description": "Whether the parameter is optional."
},
"description": {
"type": "string",
"description": "A description of the parameter."
}
},
"required": ["name", "type", "optional", "description"],
"additionalProperties": false
}
},
"returns": {
"type": "string",
"description": "The return type of the method."
},
"examples": {
"type": "array",
"description": "Code examples demonstrating usage.",
"items": {
"type": "string"
}
}
},
"required": [
"class",
"method",
"description",
"syntax",
"parameters",
"returns"
],
"additionalProperties": false
}
Which makes this for example:
[
{
"class": "Array",
"method": "clear",
"description": "Clears the array.",
"syntax": "Array.clear()",
"parameters": [],
"returns": "",
"examples": [
"const var arr = []; // Declare an array\n\n// preallocate 10 elements, do this if you\n// know how many elements you are about to insert\narr.reserve(10); \n\nfor(i = 0; i < 10; i++)\n{\n\t// Add an element to the end of the array\n\tarr.push(Math.randInt(0, 1000));\n}\n\nConsole.print(trace(arr)); // [ 523, 5, 76, 345, 765, 45, 977, 223, 44, 54]\n\narr.clear();\n\nConsole.print(trace(arr)); // []"
]
},
{
"class": "Array",
"method": "clone",
"description": "Creates a deep copy of the array.",
"syntax": "Array.clone()",
"parameters": [],
"returns": "A deep copy of the array.",
"examples": [
"const arr1 = [0, 1];\n\nvar arr2 = arr1;\n\n// Changing any element in arr2 will also change it in arr1\narr2[0] = 22;\nConsole.print(trace(arr1)); // [22, 1]\n\n// Reset the element 0 back to 0\narr1[0] = 0;\n\n// Cloning the array creates a new dataset in memory, separate from the original array\narr2 = arr1.clone();\nConsole.print(trace(arr1));\narr2[0] = 22;\nConsole.print(trace(arr2));"
]
},
I'm sure this is all elementary for you and David, but I'm just learning how to do some these data formats and transformations with parsers etc.