@tinymce/moxiedoc
Advanced tools
Comparing version 0.2.0-rc.20220310010105103.sha4bab33b to 0.2.0-rc.20220322005335934.sha73e058f
@@ -5,3 +5,3 @@ "use strict"; | ||
// TODO: we can pass this through later | ||
const baseURL = ''; | ||
const basePath = 'apis/'; | ||
const hasValue = (x) => { | ||
@@ -29,3 +29,3 @@ // empty helper for strings, objects, arrays | ||
const encodeCode = (str) => { | ||
const regex = /<code>(.*?)<\/code>/g; | ||
const regex = /<code>(.*?)<\/code>/; | ||
let matches; | ||
@@ -56,4 +56,8 @@ while ((matches = regex.exec(str))) { | ||
const getNameFromFullName = (name) => name.split('.').slice(-1).join(''); | ||
const generateTypeLink = (type) => type.includes('tinymce', 0) ? 'link:' + baseURL + type.toLowerCase() + '.html[' + getNameFromFullName(type) + ']' : type; | ||
const generateDefinedByLink = (definedBy) => 'link:' + baseURL + definedBy.toLowerCase() + '.html[' + getNameFromFullName(definedBy) + ']'; | ||
const getFilePathFromFullName = (name) => { | ||
const filename = name.toLowerCase() === 'tinymce' ? 'tinymce.root' : name.toLowerCase(); | ||
return basePath + filename + '.adoc'; | ||
}; | ||
const generateTypeXref = (type) => type.includes('tinymce', 0) ? 'xref:' + getFilePathFromFullName(type) + '[' + getNameFromFullName(type) + ']' : type; | ||
const generateDefinedByXref = (definedBy) => 'xref:' + getFilePathFromFullName(definedBy) + '[' + getNameFromFullName(definedBy) + ']'; | ||
const generateExamples = (examples) => { | ||
@@ -72,3 +76,3 @@ let tmp = '\n==== Examples\n'; | ||
params.forEach((param) => { | ||
tmp += '\n* `' + param.name + ' (' + param.types.map(generateTypeLink).join(' | ') + ')` - ' + cleanup(param.desc); | ||
tmp += '\n* `' + param.name + ' (' + param.types.map(generateTypeXref).join(' | ') + ')` - ' + cleanup(param.desc); | ||
}); | ||
@@ -80,3 +84,3 @@ return tmp + '\n'; | ||
ret.types.forEach((type) => { | ||
tmp += '\n* `' + generateTypeLink(type) + '` - ' + cleanup(ret.desc); | ||
tmp += '\n* `' + generateTypeXref(type) + '` - ' + cleanup(ret.desc); | ||
}); | ||
@@ -93,3 +97,3 @@ tmp += '\n'; | ||
tmp += '=== Settings\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,1,4,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -99,5 +103,5 @@ tmp += '|Name|Type|Summary|Defined by\n'; | ||
tmp += '|' + item.name; | ||
tmp += '|`' + generateTypeLink(item.dataTypes[0]) + '`'; | ||
tmp += '|`' + generateTypeXref(item.dataTypes[0]) + '`'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -110,3 +114,3 @@ tmp += '|===\n'; | ||
tmp += '=== Properties\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,1,4,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -116,5 +120,5 @@ tmp += '|Name|Type|Summary|Defined by\n'; | ||
tmp += '|' + item.name; | ||
tmp += '|`' + generateTypeLink(item.dataTypes[0]) + '`'; | ||
tmp += '|`' + generateTypeXref(item.dataTypes[0]) + '`'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -127,9 +131,9 @@ tmp += '|===\n'; | ||
tmp += '=== Constructors\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
tmp += '|Name|Summary|Defined by\n'; | ||
data.constructors.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + '()]'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + '()]'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -142,7 +146,7 @@ tmp += '|===\n'; | ||
tmp += '=== Methods\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
tmp += '|Name|Summary|Defined by\n'; | ||
data.methods.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + '()]|' + cleanup(item.desc) + '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + '()]|' + cleanup(item.desc) + '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -156,9 +160,9 @@ tmp += '|===\n'; | ||
tmp += '=== Events\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
tmp += '|Name|Summary|Defined by\n'; | ||
data.events.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + ']'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + ']'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -265,3 +269,3 @@ tmp += '|===\n'; | ||
data.borrows.forEach((item) => { | ||
tmp += '\n * link:' + baseURL + item.toLowerCase() + '.html[' + item + ']\n'; | ||
tmp += '\n * xref:' + basePath + item.toLowerCase() + '.adoc[' + item + ']\n'; | ||
}); | ||
@@ -268,0 +272,0 @@ } |
{ | ||
"name": "@tinymce/moxiedoc", | ||
"version": "0.2.0-rc.20220310010105103.sha4bab33b", | ||
"version": "0.2.0-rc.20220322005335934.sha73e058f", | ||
"description": "A tool for generating API documentation", | ||
@@ -5,0 +5,0 @@ "author": "Tiny Technologies, Inc", |
@@ -11,3 +11,3 @@ import { Return } from '../../lib/member'; | ||
// TODO: we can pass this through later | ||
const baseURL = ''; | ||
const basePath = 'apis/'; | ||
@@ -43,3 +43,3 @@ const hasValue = <T>(x: T): x is NonNullable<T> => { | ||
const encodeCode = (str: string) => { | ||
const regex = /<code>(.*?)<\/code>/g; | ||
const regex = /<code>(.*?)<\/code>/; | ||
let matches; | ||
@@ -76,8 +76,13 @@ while ((matches = regex.exec(str))) { | ||
const generateTypeLink = (type: string): string => | ||
type.includes('tinymce', 0) ? 'link:' + baseURL + type.toLowerCase() + '.html[' + getNameFromFullName(type) + ']' : type; | ||
const getFilePathFromFullName = (name: string): string => { | ||
const filename = name.toLowerCase() === 'tinymce' ? 'tinymce.root' : name.toLowerCase(); | ||
return basePath + filename + '.adoc'; | ||
}; | ||
const generateDefinedByLink = (definedBy: string) => | ||
'link:' + baseURL + definedBy.toLowerCase() + '.html[' + getNameFromFullName(definedBy) + ']'; | ||
const generateTypeXref = (type: string): string => | ||
type.includes('tinymce', 0) ? 'xref:' + getFilePathFromFullName(type) + '[' + getNameFromFullName(type) + ']' : type; | ||
const generateDefinedByXref = (definedBy: string): string => | ||
'xref:' + getFilePathFromFullName(definedBy) + '[' + getNameFromFullName(definedBy) + ']'; | ||
const generateExamples = (examples: Array<{ content: string }>): string => { | ||
@@ -97,3 +102,3 @@ let tmp = '\n==== Examples\n'; | ||
params.forEach((param) => { | ||
tmp += '\n* `' + param.name + ' (' + param.types.map(generateTypeLink).join(' | ') + ')` - ' + cleanup(param.desc); | ||
tmp += '\n* `' + param.name + ' (' + param.types.map(generateTypeXref).join(' | ') + ')` - ' + cleanup(param.desc); | ||
}); | ||
@@ -106,3 +111,3 @@ return tmp + '\n'; | ||
ret.types.forEach((type) => { | ||
tmp += '\n* `' + generateTypeLink(type) + '` - ' + cleanup(ret.desc); | ||
tmp += '\n* `' + generateTypeXref(type) + '` - ' + cleanup(ret.desc); | ||
}); | ||
@@ -122,3 +127,3 @@ tmp += '\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,1,4,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -129,5 +134,5 @@ tmp += '|Name|Type|Summary|Defined by\n'; | ||
tmp += '|' + item.name; | ||
tmp += '|`' + generateTypeLink(item.dataTypes[0]) + '`'; | ||
tmp += '|`' + generateTypeXref(item.dataTypes[0]) + '`'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -142,3 +147,3 @@ tmp += '|===\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,1,4,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -149,5 +154,5 @@ tmp += '|Name|Type|Summary|Defined by\n'; | ||
tmp += '|' + item.name; | ||
tmp += '|`' + generateTypeLink(item.dataTypes[0]) + '`'; | ||
tmp += '|`' + generateTypeXref(item.dataTypes[0]) + '`'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -162,3 +167,3 @@ tmp += '|===\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -168,5 +173,5 @@ tmp += '|Name|Summary|Defined by\n'; | ||
data.constructors.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + '()]'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + '()]'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -180,7 +185,7 @@ tmp += '|===\n'; | ||
tmp += '=== Methods\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
tmp += '|Name|Summary|Defined by\n'; | ||
data.methods.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + '()]|' + cleanup(item.desc) + '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + '()]|' + cleanup(item.desc) + '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -196,3 +201,3 @@ tmp += '|===\n'; | ||
tmp += '[options="header"]\n'; | ||
tmp += '[cols="2,5,1",options="header"]\n'; | ||
tmp += '|===\n'; | ||
@@ -202,5 +207,5 @@ tmp += '|Name|Summary|Defined by\n'; | ||
data.events.forEach((item) => { | ||
tmp += '|link:#' + item.name + '[' + item.name + ']'; | ||
tmp += '|xref:#' + item.name + '[' + item.name + ']'; | ||
tmp += '|' + cleanup(item.desc); | ||
tmp += '|`' + generateDefinedByLink(item.definedBy) + '`\n'; | ||
tmp += '|`' + generateDefinedByXref(item.definedBy) + '`\n'; | ||
}); | ||
@@ -330,3 +335,3 @@ tmp += '|===\n'; | ||
data.borrows.forEach((item) => { | ||
tmp += '\n * link:' + baseURL + item.toLowerCase() + '.html[' + item + ']\n'; | ||
tmp += '\n * xref:' + basePath + item.toLowerCase() + '.adoc[' + item + ']\n'; | ||
}); | ||
@@ -333,0 +338,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
344280
6657