From 3b1c537d29e8c6ac90eaf711e74e52dd225ec4fe Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Wed, 5 Feb 2020 05:13:20 -0500 Subject: [PATCH 1/7] feat(docgen): accept whitelist of constants references to skip (#26) --- packages/titanium-docgen/validate.js | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/titanium-docgen/validate.js b/packages/titanium-docgen/validate.js index 17cc8c61..2332940f 100644 --- a/packages/titanium-docgen/validate.js +++ b/packages/titanium-docgen/validate.js @@ -19,10 +19,10 @@ let standaloneFlag = false; // List of "whitelisted" types provided via cli flag // if we are unable to find these types we do not error // This gives more control versus the standalone Flag which just ignores any type errors -const whitelist = []; +const whitelistedTypes = []; // Constants that are valid, but are windows specific, so would fail validation -const WINDOWS_CONSTANTS = [ +const whitelistedConstants = [ 'Titanium.UI.Windows.ListViewScrollPosition.*' ]; @@ -244,7 +244,7 @@ function validateAPINames(names, type, className) { } // This is a whitelisted type, so ignore it - if (whitelist.includes(parent)) { + if (whitelistedTypes.includes(parent)) { return; } @@ -288,7 +288,7 @@ function validateClass(className) { if (standaloneFlag) { return new Problem(`Cannot validate class: ${className} (standalone flag is set)`, WARNING); } - if (whitelist.includes(className)) { + if (whitelistedTypes.includes(className)) { return null; } return new Problem(`Not a valid or known class/type: ${className}`); @@ -321,7 +321,7 @@ function validateConstants(constants) { */ function validateConstant(constant) { // skip windows constants that are OK, but would be marked invalid - if (WINDOWS_CONSTANTS.includes(constant)) { + if (whitelistedConstants.includes(constant)) { return null; } @@ -926,11 +926,12 @@ function validateKey(obj, syntax, currentKey, className, fullKeyPath) { * Output CLI usage */ function cliUsage () { - common.log('Usage: node validate.js [--standalone] [--quiet] [--whitelisted Type.Name,Type.Two] []'); + common.log('Usage: node validate.js [--standalone] [--quiet] [--whitelisted Type.Name,Type.Two] [--constant Titanium.Namespace.CONSTANT] []'); common.log('\nOptions:'); common.log('\t--quiet, -q\tSuppress non-error messages'); common.log('\t--standalone, -s\tdisable error checking for inherited APIs'); common.log('\t--whitelisted, -w\tdisable error checking for unresolved types. Can be specified multiple times. Accepts a comma separated list of types.'); + common.log('\t--constant, -c\tdisable error checking for unresolved constant references. Can be specified multiple times. Accepts a comma separated list of constants.'); } // Start of Main Flow @@ -960,7 +961,18 @@ if (argc > 2) { process.exit(1); } const types = process.argv[++x].split(','); - whitelist.push(...types); + whitelistedTypes.push(...types); + break; + case '--constant': + case '-c' : + // Read next arg as a whitelisted constant reference + if (x === argc - 1) { + common.log(common.LOG_WARN, 'Must supply name of whitelisted constant references'); + cliUsage(); + process.exit(1); + } + const constants = process.argv[++x].split(','); + whitelistedConstants.push(...constants); break; case '--quiet': case '-q': @@ -978,8 +990,12 @@ if (argc > 2) { } } -if (whitelist.length !== 0) { - common.log('Whitelist mode enabled. Errors will not be logged for failure to resolve these types: ' + whitelist); +if (whitelistedTypes.length !== 0) { + common.log('Whitelist mode enabled. Errors will not be logged for failure to resolve these types: ' + whitelistedTypes); +} + +if (whitelistedConstants.length !== 0) { + common.log('Whitelist constant mode enabled. Errors will not be logged for failure to resolve these constants: ' + whitelistedConstants); } if (!fs.existsSync(basePath) || !fs.statSync(basePath).isDirectory()) { From 42b27f776def9da710c3477c1edd4b584db524e5 Mon Sep 17 00:00:00 2001 From: build Date: Wed, 5 Feb 2020 10:17:47 +0000 Subject: [PATCH 2/7] chore(release): publish v4.2.0 --- CHANGELOG.md | 11 +++++++++++ lerna.json | 2 +- packages/docs/CHANGELOG.md | 8 ++++++++ packages/docs/package.json | 4 ++-- packages/titanium-docgen/CHANGELOG.md | 11 +++++++++++ packages/titanium-docgen/package.json | 2 +- .../vuepress/vuepress-plugin-apidocs/CHANGELOG.md | 8 ++++++++ .../vuepress/vuepress-plugin-apidocs/package.json | 4 ++-- 8 files changed, 44 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f795e10..297c4fca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.2.0](https://github.com/appcelerator/docs-devkit/compare/v4.1.0...v4.2.0) (2020-02-05) + + +### Features + +* **docgen:** accept whitelist of constants references to skip ([#26](https://github.com/appcelerator/docs-devkit/issues/26)) ([3b1c537](https://github.com/appcelerator/docs-devkit/commit/3b1c537)) + + + + + # [4.1.0](https://github.com/appcelerator/docs-devkit/compare/v4.0.1...v4.1.0) (2019-12-12) diff --git a/lerna.json b/lerna.json index 05a76ea6..11984ea1 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "3.13.0", - "version": "4.1.0", + "version": "4.2.0", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/docs/CHANGELOG.md b/packages/docs/CHANGELOG.md index 3dc1b57d..1425497c 100644 --- a/packages/docs/CHANGELOG.md +++ b/packages/docs/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.2.0](https://github.com/appcelerator/docs-devkit/compare/v4.1.0...v4.2.0) (2020-02-05) + +**Note:** Version bump only for package docs + + + + + # [4.1.0](https://github.com/appcelerator/docs-devkit/compare/v4.0.1...v4.1.0) (2019-12-12) **Note:** Version bump only for package docs diff --git a/packages/docs/package.json b/packages/docs/package.json index b98bd108..23541961 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "docs", - "version": "4.1.0", + "version": "4.2.0", "description": "Docs for the Titanium docs-devkit", "repository": "https://github.com/appcelerator/docs-devkit.git", "author": "Axway Appcelerator", @@ -16,7 +16,7 @@ "@vuepress/plugin-back-to-top": "1.0.2", "fs-extra": "^8.1.0", "vuepress": "^1.0.2", - "vuepress-plugin-apidocs": "^4.1.0", + "vuepress-plugin-apidocs": "^4.2.0", "vuepress-plugin-versioning": "^4.0.1", "vuepress-theme-titanium": "^4.0.1", "vuex": "^3.1.1", diff --git a/packages/titanium-docgen/CHANGELOG.md b/packages/titanium-docgen/CHANGELOG.md index 57793edc..deb44d16 100644 --- a/packages/titanium-docgen/CHANGELOG.md +++ b/packages/titanium-docgen/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.2.0](https://github.com/appcelerator/docs-devkit/compare/v4.1.0...v4.2.0) (2020-02-05) + + +### Features + +* **docgen:** accept whitelist of constants references to skip ([#26](https://github.com/appcelerator/docs-devkit/issues/26)) ([3b1c537](https://github.com/appcelerator/docs-devkit/commit/3b1c537)) + + + + + # [4.1.0](https://github.com/appcelerator/docs-devkit/compare/v4.0.1...v4.1.0) (2019-12-12) diff --git a/packages/titanium-docgen/package.json b/packages/titanium-docgen/package.json index 45bfd4a0..2739e8b7 100644 --- a/packages/titanium-docgen/package.json +++ b/packages/titanium-docgen/package.json @@ -1,6 +1,6 @@ { "name": "titanium-docgen", - "version": "4.1.0", + "version": "4.2.0", "description": "Generates Titanium API documentation in different formats", "main": "index.js", "scripts": { diff --git a/packages/vuepress/vuepress-plugin-apidocs/CHANGELOG.md b/packages/vuepress/vuepress-plugin-apidocs/CHANGELOG.md index 43dff218..6005de3a 100644 --- a/packages/vuepress/vuepress-plugin-apidocs/CHANGELOG.md +++ b/packages/vuepress/vuepress-plugin-apidocs/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.2.0](https://github.com/appcelerator/docs-devkit/compare/v4.1.0...v4.2.0) (2020-02-05) + +**Note:** Version bump only for package vuepress-plugin-apidocs + + + + + # [4.1.0](https://github.com/appcelerator/docs-devkit/compare/v4.0.1...v4.1.0) (2019-12-12) **Note:** Version bump only for package vuepress-plugin-apidocs diff --git a/packages/vuepress/vuepress-plugin-apidocs/package.json b/packages/vuepress/vuepress-plugin-apidocs/package.json index b6f684c1..2644bc0c 100644 --- a/packages/vuepress/vuepress-plugin-apidocs/package.json +++ b/packages/vuepress/vuepress-plugin-apidocs/package.json @@ -1,6 +1,6 @@ { "name": "vuepress-plugin-apidocs", - "version": "4.1.0", + "version": "4.2.0", "description": "Plugin for VuePress to render API reference documentation", "main": "index.js", "scripts": { @@ -23,7 +23,7 @@ "@vuepress/shared-utils": "^1.0.2", "axios": "^0.19.0", "fs-extra": "^8.1.0", - "titanium-docgen": "^4.1.0", + "titanium-docgen": "^4.2.0", "vue-content-loader": "^0.2.2" }, "peerDependencies": { From 2f085f070a33a0aee1eec04f9c88b95254d78941 Mon Sep 17 00:00:00 2001 From: Sergey Volkov Date: Fri, 14 Feb 2020 15:33:35 +0300 Subject: [PATCH 3/7] fix(docgen): build correct path (#27) --- packages/titanium-docgen/lib/common.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/titanium-docgen/lib/common.js b/packages/titanium-docgen/lib/common.js index 7355f3ee..aa1ff96e 100644 --- a/packages/titanium-docgen/lib/common.js +++ b/packages/titanium-docgen/lib/common.js @@ -10,6 +10,7 @@ const yaml = require('js-yaml'), fs = require('fs'), colors = require('colors'), // eslint-disable-line no-unused-vars nodeappc = require('node-appc'), + path = require('path'), MarkdownIt = require('markdown-it'), ignoreList = [ 'node_modules', '.travis.yml' ], LOG_INFO = 0, @@ -153,19 +154,19 @@ function errorMessage() { /** * Recursively find, load and parse YAML files - * @param {Object} path Root path to start search + * @param {Object} rootPath Root path to start search * @returns {Object} Dictionary containing the parsed data and any YAML errors */ -exports.parseYAML = function parseYAML(path) { +exports.parseYAML = function parseYAML(rootPath) { const rv = { data: {}, errors: [] }; - let currentFile = path; + let currentFile = rootPath; try { - const fsArray = fs.readdirSync(path); + const fsArray = fs.readdirSync(rootPath); fsArray.forEach(function (fsElement) { - const elem = path + '/' + fsElement, + const elem = path.join(rootPath, fsElement), stat = fs.statSync(elem); currentFile = elem; From 34f07c51e071b74ba4b4f41e2915a12d8acf245d Mon Sep 17 00:00:00 2001 From: Sergey Volkov Date: Tue, 18 Feb 2020 14:06:10 +0300 Subject: [PATCH 4/7] feat(docgen): improve typescript generator (#25) * fix(docgen): typescript: eslint problems in the generator * fix(docgen): typescript: sort APIs, methods and properties * fix(docgen): typescript: improve generator - generate Global properties - generate namespace and interface for modules * feat(docgen): typescript: generate interfaces for events * feat(docgen): typescript: inject "id" prop into "Ti.Proxy" * fix(docgen): typescript: "Windows" addon * fix(docgen): typescript: rest parameter for Ti.Database.DB.execute * fix(docgen): typescript: restore "defaultValue" * fix(docgen): typescript: skip removed events * fix(docgen): typescript: update to pass DefinitelyTyped linter - remove trailing spaces from jsdoc - use "any[]" as parameter for Ti.Database.DB.execute - use "Array>" type instead of "Dictionary[]" - add "tslint:disable-next-line:ban-types" for "Function" type - update TypeScript Version to 3.0: "excluded" methods are typed as properties with "methodName: never", this is not allowed before 3.0 * fix(docgen): typescript: reorder nodes. first class, then namespace: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-namespaces-with-classes * fix(docgen): typescript: generate only namespace for Titanium generated class for Titanium will have only static members * fix(docgen): typescript: remove "declare" from interfaces * fix(docgen): typescript: don't skip namespace generation for ConstantsOnlyProxy * fix(docgen): typescript: update header It is valid to pass a function (e.g. "onload") to Ti.Network.createHTTPClient() in Dictionary. So now we exclude from T only Functions that came from Ti.Proxy Since SDK 9.0 accessors will be removed, so they will not bother us here. * fix(docgen): typescript: handle "excludes" in isConstantOnlyProxy * fix(docgen): typescript: update header * fix(docgen): typescript: add new line after removed members * fix(docgen): typescript: skip bundled documentation for modules * feat(docgen): typescript: add @deprecated to jsdoc * fix(docgen): typescript: skip inherited properties * fix(docgen): typescript: skip inherited methods * fix(docgen): typescript: handle top level classes * fix(docgen): typescript: parent namespace search * fix(docgen): typescript: remove check for "Ti.Modules" * feat(docgen): typescript: handle global variables * feat(docgen): typescript: handle "repeatable" args --- .../generators/typescript_generator.js | 904 +++++++++++++----- 1 file changed, 644 insertions(+), 260 deletions(-) diff --git a/packages/titanium-docgen/generators/typescript_generator.js b/packages/titanium-docgen/generators/typescript_generator.js index a9fd9d70..563e1b82 100644 --- a/packages/titanium-docgen/generators/typescript_generator.js +++ b/packages/titanium-docgen/generators/typescript_generator.js @@ -1,4 +1,6 @@ 'use strict'; +const common = require('../lib/common.js'); +const path = require('path'); /* * Map of invalid types and their replacement @@ -9,6 +11,25 @@ const invalidTypeMap = { Dictionary: 'any', Object: 'any' }; + +const skipApis = [ + 'Dictionary', + 'Titanium.UI.2DMatrix', + 'Titanium.UI.3DMatrix' +]; + +// List of modules that need to be generated as an interface instead of a namespace. +const forcedInterfaces = [ + 'Titanium.App.iOS.UserDefaults', + 'Global.String' +]; + +const eventsMethods = [ + 'addEventListener', + 'removeEventListener', + 'fireEvent' +]; + let parser = null; exports.exportData = function exportGlobalTemplate(apis) { @@ -35,8 +56,18 @@ function isConstantsOnlyProxy(typeInfo) { return false; } - const ownMethods = typeInfo.methods.filter(methodDoc => methodDoc.__inherits === typeInfo.name); - const ownWritableProperties = typeInfo.properties.filter(propertyDoc => propertyDoc.__inherits === typeInfo.name && propertyDoc.permission !== 'read-only'); + const ownMethods = typeInfo.methods.filter(methodDoc => { + if (methodDoc.__hide) { + return false; + } + return methodDoc.__inherits === typeInfo.name; + }); + const ownWritableProperties = typeInfo.properties.filter(propertyDoc => { + if (propertyDoc.__hide) { + return false; + } + return propertyDoc.__inherits === typeInfo.name && propertyDoc.permission !== 'read-only'; + }); const ownReadOnlyProperties = typeInfo.properties.filter(propertyDoc => propertyDoc.__inherits === typeInfo.name && propertyDoc.permission === 'read-only'); if (ownMethods.length === 0 && ownReadOnlyProperties.length > 0 && ownWritableProperties.length === 0) { return true; @@ -46,51 +77,39 @@ function isConstantsOnlyProxy(typeInfo) { } /** - * Checks if a type can safely be extended from an already existing interface. - * - * A type can be extended from another type when it contains all of its - * properties and methods. - * - * @param {Object} typeInfo Type info of the type that should be checked if it can extend another type - * @param {InterfaceNode} interfaceNode Node of the type that should be extended - * @return {Boolean} True if the type can extend the given interface, false if not + * @param {Object} a method, property or event + * @param {Object} b method, property or event + * @return {number} */ -function canExtend(typeInfo, interfaceNode) { - if (!interfaceNode) { - return false; +function sortByName(a, b) { + if (a.name > b.name) { + return 1; } - - if (typeInfo.name === interfaceNode.fullyQualifiedName) { - return false; + if (a.name < b.name) { + return -1; } - - function hasAllMembers(typeMembers, interfaceMembers) { - return interfaceMembers.every(interfaceMemberNode => { - if (interfaceMemberNode.optional) { - return true; - } - - return typeMembers.some(typeMember => interfaceMemberNode.name === typeMember.name); - }); + if (a.type) { + return -1; } - - return hasAllMembers(typeInfo.properties, interfaceNode.properties) && hasAllMembers(typeInfo.methods, interfaceNode.methods); + if (b.type) { + return 1; + } + return 0; } /** - * Removes all memebers of the first type info object that are also present in - * the given interface node. - * - * @param {Object} typeInfo Type info object whos members should be removed - * @param {InterfaceNode} interfaceNode Reference interface node + * @param {MemberNode} a API node + * @param {MemberNode} b API node + * @return {number} */ -function removeMembers(typeInfo, interfaceNode) { - function filterMembers(typeMembers, interfaceMembers) { - return typeMembers.filter(memberInfo => !interfaceMembers.some(interfaceMember => interfaceMember.name === memberInfo.name)); +function sortByFQN(a, b) { + if (a.fullyQualifiedName > b.fullyQualifiedName) { + return 1; } - - typeInfo.properties = filterMembers(typeInfo.properties, interfaceNode.properties); - typeInfo.methods = filterMembers(typeInfo.methods, interfaceNode.methods); + if (a.fullyQualifiedName < b.fullyQualifiedName) { + return -1; + } + return 1; } /** @@ -104,9 +123,6 @@ class DocsParser { * @param {Object} apis Hash map of Titanium type names and their definition. */ constructor(apis) { - this.titaniumNamespace = null; - this.proxyInterface = null; - this.viewInterface = null; this.apis = apis; this.tree = new EmulatedSyntaxTree(); } @@ -115,56 +131,81 @@ class DocsParser { * Parses all Titanium types and generates the emulated TypeScript syntax tree. */ parse() { - this.titaniumNamespace = new NamespaceNode(this.apis['Titanium']); - this.tree.addNode(this.titaniumNamespace); - delete this.apis['Titanium']; - this.proxyInterface = new InterfaceNode(this.apis['Titanium.Proxy']); - this.titaniumNamespace.addInterface(this.proxyInterface); - delete this.apis['Titanium.Proxy']; - const uiNamespace = new NamespaceNode(this.apis['Titanium.UI']); - this.tree.registerNamespace(uiNamespace.fullyQualifiedName, uiNamespace); - this.titaniumNamespace.addNamespace(uiNamespace); - delete this.apis['Titanium.UI']; - this.viewInterface = new InterfaceNode(this.apis['Titanium.UI.View']); - uiNamespace.addInterface(this.viewInterface); - - for (const fullyQualifiedTypeName in this.apis) { + const globalNamespace = new NamespaceNode(this.apis['Global']); + this.tree.addNode(globalNamespace); + this.tree.registerNamespace('Global', globalNamespace); + delete this.apis['Global']; + + const namesList = Object.keys(this.apis); + namesList.forEach(fullyQualifiedTypeName => { if (fullyQualifiedTypeName.startsWith('__')) { - continue; + return; } const typeInfo = this.apis[fullyQualifiedTypeName]; - const namespaceParts = typeInfo.name.split('.'); - namespaceParts.pop(); - - if (namespaceParts[0] !== 'Titanium' && namespaceParts.length > 0) { - continue; - } else if (typeInfo.name === 'Global') { - continue; - } else if (typeInfo.name === 'Dictionary') { - continue; + if (typeInfo) { + this.processApi(typeInfo); } + }); + } + + /** + * Creates {MemberNode} for type and places it in the tree. + * Will return {NamespaceNode} if it was created. + * + * @param {Object} typeInfo API doc. + * @return {NamespaceNode|undefined} + */ + processApi(typeInfo) { + if (typeInfo.__file.indexOf(path.join('apidoc', 'Modules')) !== -1) { + // skip bundled documentation for modules + return; + } + const namespaceParts = typeInfo.name.split('.'); + namespaceParts.pop(); + if (skipApis.includes(typeInfo.name)) { + return; + } - const parentNamespace = this.findOrCreateNamespace(namespaceParts); - if (this.isInterface(typeInfo)) { - const interfaceNode = new InterfaceNode(typeInfo); + const parentNamespace = this.findOrCreateNamespace(namespaceParts); + const isInterface = this.isInterface(typeInfo); + const isClass = this.isClass(typeInfo); + const isNamespace = this.isNamespace(typeInfo); + let processed = false; + let namespaceNode; + if (isNamespace) { + processed = true; + if (!this.tree.hasNamespace(typeInfo.name)) { + namespaceNode = new NamespaceNode(typeInfo); + this.tree.registerNamespace(namespaceNode.fullyQualifiedName, namespaceNode); if (parentNamespace) { - parentNamespace.addInterface(interfaceNode); + parentNamespace.addNamespace(namespaceNode); } else { - this.tree.addNode(interfaceNode); - } - } else if (this.isNamespace(typeInfo)) { - if (!this.tree.hasNamespace(typeInfo.name)) { - const namespace = new NamespaceNode(typeInfo); - this.tree.registerNamespace(namespace.fullyQualifiedName, namespace); - if (parentNamespace) { - parentNamespace.addNamespace(namespace); - } + this.tree.addNode(namespaceNode); } + } + } + if (isInterface || isClass) { + processed = true; + if (namespaceNode && namespaceNode.fullyQualifiedName === 'Titanium') { + return namespaceNode; + } + const interfaceNode = isClass ? new ClassNode(typeInfo) : new InterfaceNode(typeInfo); + if (namespaceNode) { + namespaceNode.relatedNode = interfaceNode; + interfaceNode.relatedNode = namespaceNode; + } + + if (parentNamespace) { + parentNamespace.addInterface(interfaceNode); } else { - console.warn(`Unhandled type ${typeInfo.name}`); + this.tree.addNode(interfaceNode); } } + if (!processed) { + console.warn(`Unhandled type ${typeInfo.name}`); + } + return namespaceNode; } /** @@ -182,23 +223,11 @@ class DocsParser { const parentNamespaceName = namespaceParts.join('.'); let parentNamespace = null; if (!this.tree.hasNamespace(parentNamespaceName)) { - let namespacePathFromRoot = []; - namespaceParts.forEach(namespaceName => { - namespacePathFromRoot.push(namespaceName); - const subordinateNamespaceName = namespacePathFromRoot.join('.'); - if (!this.tree.hasNamespace(subordinateNamespaceName)) { - const doc = this.apis[subordinateNamespaceName]; - if (!doc) { - throw new Error(`Couldn't find docs for ${subordinateNamespaceName}.`); - } - const subordinateNamespace = new NamespaceNode(this.apis[subordinateNamespaceName]); - this.tree.registerNamespace(subordinateNamespace.fullyQualifiedName, subordinateNamespace); - parentNamespace.addNamespace(subordinateNamespace); - parentNamespace = subordinateNamespace; - } else { - parentNamespace = this.tree.getNamespace(subordinateNamespaceName); - } - }); + if (!this.apis[parentNamespaceName]) { + throw new Error(`Couldn't find docs for "${parentNamespaceName}".`); + } + parentNamespace = this.processApi(this.apis[parentNamespaceName]); + delete this.apis[parentNamespaceName]; } else { parentNamespace = this.tree.getNamespace(parentNamespaceName); } @@ -222,17 +251,19 @@ class DocsParser { */ isInterface(typeInfo) { const validSubtypes = [ - 'proxy', 'pseudo', - 'view' - ]; - // List of modules that need to be generated as an interface instead of a namespace. - const namespaceBlacklist = [ - 'Titanium.App.iOS.UserDefaults', ]; - return (validSubtypes.indexOf(typeInfo.__subtype) !== -1 && !isConstantsOnlyProxy(typeInfo)) - || namespaceBlacklist.indexOf(typeInfo.name) !== -1; + return validSubtypes.includes(typeInfo.__subtype) || forcedInterfaces.includes(typeInfo.name); + } + + isClass(typeInfo) { + const validSubtypes = [ + 'module', + 'proxy', + 'view' + ]; + return validSubtypes.includes(typeInfo.__subtype) && !forcedInterfaces.includes(typeInfo.name); } /** @@ -245,7 +276,7 @@ class DocsParser { * @return {Boolean} True if the API type is considered a namespace in TypeScript, false if not. */ isNamespace(typeInfo) { - return typeInfo.__subtype === 'module' || isConstantsOnlyProxy(typeInfo); + return (typeInfo.__subtype === 'module' || isConstantsOnlyProxy(typeInfo)) && !forcedInterfaces.includes(typeInfo.name); } } @@ -259,9 +290,6 @@ class EmulatedSyntaxTree { } addNode(node) { - if (node instanceof NamespaceNode && !this.hasNamespace(node.fullyQualifiedName)) { - this.registerNamespace(node.fullyQualifiedName, node); - } this.nodes.push(node); } @@ -306,8 +334,8 @@ class GlobalTemplateWriter { */ generateTitaniumDefinition(tree) { this.writeHeader(); - this.writeTiShorthand(); this.writeNodes(tree.nodes); + this.writeTiShorthand(); } /** @@ -320,28 +348,52 @@ class GlobalTemplateWriter { this.output += '// Project: https://github.com/appcelerator/titanium_mobile\n'; this.output += '// Definitions by: Axway Appcelerator \n'; this.output += '// Jan Vennemann \n'; + this.output += '// Sergey Volkov \n'; this.output += '// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n'; - this.output += '// TypeScript Version: 2.6\n'; + this.output += '// TypeScript Version: 3.0\n'; + this.output += '\n'; + this.output += 'type _Omit = Pick>;\n'; + this.output += 'type FunctionPropertyNames = {\n'; + this.output += ' // tslint:disable-next-line:ban-types\n'; + this.output += ' [K in keyof T]: T[K] extends Function ? K : never\n'; + this.output += '}[keyof T];\n'; + this.output += 'type Dictionary = Partial<_Omit>>;'; + this.output += '\n'; + this.output += 'interface ProxyEventMap {}\n\n'; } /** * Writes the "Ti" shorthand alias for the global Titanium namespace. */ writeTiShorthand() { - this.output += 'declare const Ti: typeof Titanium;\n'; + this.output += '\nimport Ti = Titanium;\n'; } /** * Renders all nodes from the synatx tree and adds them to the output. * - * @param {MemberNode} nodes Syntax tree node to render and write + * @param {Array} nodes Syntax tree node to render and write */ writeNodes(nodes) { - for (const node of nodes) { - if (node instanceof NamespaceNode) { - this.writeNamespaceNode(node, 0); - } else if (node instanceof InterfaceNode) { + const copy = nodes.slice().sort(sortByFQN); + while (copy.length) { + const node = copy.shift(); + if (node instanceof InterfaceNode) { this.writeInterfaceNode(node, 0); + if (node.relatedNode) { + const idx = copy.indexOf(node.relatedNode); + const related = /** @type {NamespaceNode} */ (copy[idx]); + copy.splice(idx, 1); + this.writeNamespaceNode(related, 0); + } + } else if (node instanceof NamespaceNode) { + if (node.relatedNode) { + const idx = copy.indexOf(node.relatedNode); + const related = /** @type {InterfaceNode} */ (copy[idx]); + copy.splice(idx, 1); + this.writeInterfaceNode(related, 0); + } + this.writeNamespaceNode(node, 0); } } } @@ -353,22 +405,53 @@ class GlobalTemplateWriter { * @param {Number} nestingLevel Current nesting level for indentation */ writeNamespaceNode(namespaceNode, nestingLevel) { - this.output += '\n'; + namespaceNode.init(); + const hasProperties = namespaceNode.properties.length > 0; + const hasMethods = namespaceNode.methods.length > 0; + const hasInterfaces = namespaceNode.interfaces.length > 0; + const hasNamespaces = namespaceNode.namespaces.length > 0; + + if (!hasProperties && !hasMethods && !hasInterfaces && !hasNamespaces) { + return; + } + + if (namespaceNode.relatedNode) { + if (!hasInterfaces && !hasNamespaces && !hasProperties) { + // empty namespace, all methods and properties will be defined in related interface + return; + } + if (namespaceNode.relatedNode.removed) { + return; + } + } + + const isGlobal = namespaceNode.name === 'Global'; + const nextNestingLevel = isGlobal ? nestingLevel : nestingLevel + 1; + this.output += this.generateJsDoc(namespaceNode, nestingLevel); - this.output += `${this.indent(nestingLevel)}${nestingLevel === 0 ? 'declare ' : ''}namespace ${namespaceNode.name} {\n`; - if (namespaceNode.properties.length > 0) { - namespaceNode.properties.forEach(propertyNode => this.writeVariableNode(propertyNode, nestingLevel + 1)); + + if (namespaceNode.removed) { + this.output += `${this.indent(nestingLevel)}${nestingLevel === 0 ? 'declare ' : ''}const ${namespaceNode.name}: never;\n`; + return; } - if (namespaceNode.methods.length > 0) { - namespaceNode.methods.forEach(methodNode => this.writeFunctionNode(methodNode, nestingLevel + 1)); + if (!isGlobal) { + this.output += `${this.indent(nestingLevel)}${nestingLevel === 0 ? 'declare ' : ''}namespace ${namespaceNode.name} {\n`; } - if (namespaceNode.interfaces.length > 0) { - namespaceNode.interfaces.forEach(interfaceNode => this.writeInterfaceNode(interfaceNode, nestingLevel + 1)); + if (hasProperties) { + namespaceNode.properties.forEach(propertyNode => this.writeVariableNode(propertyNode, nextNestingLevel)); } - if (namespaceNode.namespaces.length > 0) { - namespaceNode.namespaces.forEach(childNamespace => this.writeNamespaceNode(childNamespace, nestingLevel + 1)); + if (hasMethods) { + namespaceNode.methods.forEach(methodNode => this.writeFunctionNode(methodNode, nextNestingLevel)); + } + if (hasNamespaces) { + namespaceNode.namespaces.sort(sortByFQN).forEach(childNamespace => this.writeNamespaceNode(childNamespace, nextNestingLevel)); + } + if (hasInterfaces) { + namespaceNode.interfaces.sort(sortByFQN).forEach(interfaceNode => this.writeInterfaceNode(interfaceNode, nextNestingLevel)); + } + if (!isGlobal) { + this.output += `${this.indent(nestingLevel)}}\n`; } - this.output += `${this.indent(nestingLevel)}}\n`; } /** @@ -378,8 +461,19 @@ class GlobalTemplateWriter { * @param {Number} nestingLevel Current nesting level for indentation */ writeInterfaceNode(interfaceNode, nestingLevel) { + interfaceNode.init(); + if (interfaceNode.events.length > 0) { + interfaceNode.events.forEach(eventNode => + this.writeInterfaceNode(eventNode, nestingLevel)); + } this.output += this.generateJsDoc(interfaceNode, nestingLevel); - this.output += `${this.indent(nestingLevel)}interface ${interfaceNode.name} ${interfaceNode.extends ? 'extends ' + interfaceNode.extends + ' ' : ''}{\n`; + if (interfaceNode.removed) { + this.output += `${this.indent(nestingLevel)}const ${interfaceNode.name}: never;\n`; + return; + } + const parent = interfaceNode.extends ? 'extends ' + interfaceNode.extends + ' ' : ''; + const isTopLevelClass = this instanceof ClassNode && nestingLevel === 0 ? 'declare ' : ''; + this.output += `${this.indent(nestingLevel)}${isTopLevelClass}${interfaceNode.keyWord} ${interfaceNode.name} ${parent}{\n`; if (interfaceNode.properties.length > 0) { interfaceNode.properties.forEach(propertyNode => this.writePropertyNode(propertyNode, nestingLevel + 1)); } @@ -397,7 +491,9 @@ class GlobalTemplateWriter { */ writeVariableNode(variableNode, nestingLevel) { this.output += this.generateJsDoc(variableNode, nestingLevel); - this.output += `${this.indent(nestingLevel)}${variableNode.isConstant ? 'const' : 'let'} ${variableNode.name}: ${this.normalizeType(variableNode.type)};\n\n`; + const inGlobal = nestingLevel === 0 ? 'declare ' : ''; + const isConstant = variableNode.isConstant ? 'const' : inGlobal ? 'var' : 'let'; + this.output += `${this.indent(nestingLevel)}${inGlobal}${isConstant} ${variableNode.name}: ${this.normalizeType(variableNode.type)};\n\n`; } /** @@ -408,7 +504,12 @@ class GlobalTemplateWriter { */ writePropertyNode(propertyNode, nestingLevel) { this.output += this.generateJsDoc(propertyNode, nestingLevel); - this.output += `${this.indent(nestingLevel)}${propertyNode.isConstant ? 'readonly ' : ''}${propertyNode.name}${propertyNode.optional ? '?' : ''}: ${this.normalizeType(propertyNode.type)};\n\n`; + const isStatic = propertyNode.isStatic ? 'static ' : ''; + const inGlobal = nestingLevel === 0 ? 'declare ' : ''; + const isReadOnly = propertyNode.isConstant ? 'readonly ' : ''; + const type = this.normalizeType(propertyNode.type); + const isOptional = (type !== 'never' && propertyNode.optional) ? '?' : ''; + this.output += `${this.indent(nestingLevel)}${inGlobal}${isStatic}${isReadOnly}${propertyNode.name}${isOptional}: ${type};\n\n`; } /** @@ -419,8 +520,14 @@ class GlobalTemplateWriter { */ writeFunctionNode(functionNode, nestingLevel) { this.output += this.generateJsDoc(functionNode, nestingLevel); + const inGlobal = nestingLevel === 0 ? 'declare ' : ''; + if (functionNode.removed) { + this.output += `${this.indent(nestingLevel)}${inGlobal}const ${functionNode.name}: never;\n\n`; + return; + } const parametersString = this.prepareParameters(functionNode.parameters); - this.output += `${this.indent(nestingLevel)}function ${functionNode.name}(${parametersString}): ${this.normalizeType(functionNode.returnType)};\n\n`; + const type = this.normalizeType(functionNode.returnType); + this.output += `${this.indent(nestingLevel)}${inGlobal}function ${functionNode.name}(${parametersString}): ${type};\n\n`; } /** @@ -431,8 +538,16 @@ class GlobalTemplateWriter { */ writeMethodNode(functionNode, nestingLevel) { this.output += this.generateJsDoc(functionNode, nestingLevel); + const isStatic = functionNode.isStatic ? 'static ' : ''; + if (functionNode.removed) { + this.output += `${this.indent(nestingLevel)}${isStatic}${functionNode.name}: never;\n\n`; + return; + } const parametersString = this.prepareParameters(functionNode.parameters); - this.output += `${this.indent(nestingLevel)}${functionNode.name}${functionNode.optional ? '?' : ''}(${parametersString}): ${this.normalizeType(functionNode.returnType)};\n\n`; + const isOptional = functionNode.optional ? '?' : ''; + const type = this.normalizeType(functionNode.returnType); + const generic = functionNode.generic; + this.output += `${this.indent(nestingLevel)}${isStatic}${functionNode.name}${generic}${isOptional}(${parametersString}): ${type};\n\n`; } /** @@ -440,13 +555,19 @@ class GlobalTemplateWriter { * * @param {Object} node The node to generte the comment for * @param {Number} nestingLevel Current nesting level for indentation - * @return {Stirng} JSDoc comment + * @return {String} JSDoc comment */ generateJsDoc(node, nestingLevel) { - let jsDoc = `${this.indent(nestingLevel)}/**\n`; - let summary = node.summary.replace(/\s?\n/g, `\n${this.indent(nestingLevel)} * `); - jsDoc += `${this.indent(nestingLevel)} * ${summary}\n`; - jsDoc += `${this.indent(nestingLevel)} */\n`; + if (!node.summary) { + return ''; + } + const summary = node.summary.replace(/\s?\n/g, `\n${this.indent(nestingLevel)} * `).trim(); + let jsDoc = ''; + if (summary) { + jsDoc += `${this.indent(nestingLevel)}/**\n`; + jsDoc += `${this.indent(nestingLevel)} * ${summary}\n`; + jsDoc += `${this.indent(nestingLevel)} */\n`; + } if (node instanceof InterfaceNode && node.name === 'IOStream') { jsDoc += this.indent(nestingLevel) + '// tslint:disable-next-line:interface-name\n'; } @@ -467,8 +588,8 @@ class GlobalTemplateWriter { /** * Normalizes a given type so it can be safely used in TypeScript. * - * @param {Object} docType Type definition - * @param {String} usageHint A string with a hint where this type is used (null or 'parameter') + * @param {Object | String | Array } docType Type definition + * @param {String=} usageHint A string with a hint where this type is used (null or 'parameter') * @return {String} A normalized representation of the type for usage in TypeScript */ normalizeType(docType, usageHint) { @@ -478,7 +599,7 @@ class GlobalTemplateWriter { if (Array.isArray(docType)) { const normalizedTypes = docType.map(typeName => this.normalizeType(typeName)); - return normalizedTypes.indexOf('any') !== -1 ? 'any' : normalizedTypes.join(' | '); + return normalizedTypes.includes('any') ? 'any' : normalizedTypes.join(' | '); } const lessThanIndex = docType.indexOf('<'); @@ -491,18 +612,26 @@ class GlobalTemplateWriter { return subTypes.map(typeName => { if (usageHint === 'parameter') { return `ReadonlyArray<${typeName}>`; + } else if (typeName.indexOf('<') !== -1) { + return `Array<${typeName}>`; } else { return `${typeName}[]`; } }).join(' | '); } else if (baseType === 'Callback') { - return `(${subTypes.map((type, index) => `param${index}: ${type}`).join(', ')}) => any`; + if (docType === 'Callback') { + return '() => void'; + } else { + return `(${subTypes.map((type, index) => `param${index}: ${type}`).join(', ')}) => void`; + } } else if (baseType === 'Dictionary') { - return 'any'; + return `Dictionary<${subType}>`; } } switch (docType) { + case 'bool': + return 'boolean'; // Windows addon only case 'Boolean': case 'Function': case 'Number': @@ -510,8 +639,12 @@ class GlobalTemplateWriter { return docType.toLowerCase(); case 'Object': return 'any'; + case 'Array': + return 'any[]'; case 'Callback': { - return '() => any'; + // simple 'Callback' is considered a poorly documented type, assume any number of `any` arguments + // callback without arguments and return value should be documented as `Callback` + return '(...args: any[]) => void'; } default: { let typeName = docType; @@ -539,6 +672,8 @@ class GlobalTemplateWriter { normalizeParameter(paramNode) { if (paramNode.name === 'default') { paramNode.name = 'defaultValue'; + } else if (paramNode.name === 'function') { + paramNode.name = 'func'; } } @@ -561,11 +696,17 @@ class GlobalTemplateWriter { */ prepareParameterString(paramNode) { this.normalizeParameter(paramNode); - let parameter = paramNode.rest ? '...' + paramNode.name : paramNode.name; - if (paramNode.optional) { + let parameter = paramNode.repeatable ? '...' + paramNode.name : paramNode.name; + + // TS1047: A rest parameter cannot be optional. + if (paramNode.optional && !paramNode.repeatable) { parameter += '?'; } - parameter += `: ${this.normalizeType(paramNode.type, paramNode.rest ? null : 'parameter')}`; + let type = this.normalizeType(paramNode.type, paramNode.repeatable ? null : 'parameter'); + if (paramNode.repeatable && type.indexOf('Array<') !== 0 && type.indexOf('[]') !== type.length - 2) { + type = type.indexOf(' | ') !== -1 ? `Array<${type}>` : `${type}[]`; + } + parameter += `: ${type}`; return parameter; } @@ -577,28 +718,45 @@ class GlobalTemplateWriter { * Used for variables in namespaces and properties in interfaces. */ class VariableNode { - constructor(variableDoc) { + constructor(variableDoc, isStatic) { this.name = variableDoc.name; - this.type = variableDoc.type; + this.isStatic = isStatic; + if (variableDoc.__hide || variableDoc.deprecated && variableDoc.deprecated.removed) { + this.type = 'never'; + } else { + this.type = variableDoc.type; + } this.summary = variableDoc.summary ? variableDoc.summary.trim() : ''; + if (variableDoc.deprecated) { + this.summary += '\n@deprecated'; + if (variableDoc.deprecated.notes) { + this.summary += ' ' + variableDoc.deprecated.notes; + } + } this.isConstant = variableDoc.permission === 'read-only'; this.optional = variableDoc.optional; - this.rest = variableDoc.rest || false; + this.repeatable = variableDoc.repeatable || false; } } /** * A node that represents a function. * - * Used for funtions in namespaces and methods in interfaces. + * Used for functions in namespaces and methods in interfaces. */ class FunctionNode { - constructor(functionDoc) { + constructor(functionDoc, isStatic) { this.definition = functionDoc; this.name = functionDoc.name; + this.isStatic = isStatic; + this.generic = ''; + + if (functionDoc.__hide || functionDoc.deprecated && functionDoc.deprecated.removed) { + this.removed = true; + } if (functionDoc.returns) { if (Array.isArray(functionDoc.returns)) { - this.returnType = functionDoc.returns.map(type => type.type); + this.returnType = functionDoc.returns.map(type => type.type); } else { this.returnType = functionDoc.returns.type; } @@ -608,6 +766,12 @@ class FunctionNode { this.parameters = []; this.parseParameters(functionDoc.parameters); this.summary = functionDoc.summary ? functionDoc.summary.trim() : ''; + if (functionDoc.deprecated) { + this.summary += '\n@deprecated'; + if (functionDoc.deprecated.notes) { + this.summary += ' ' + functionDoc.deprecated.notes; + } + } this.optional = functionDoc.optional || false; } @@ -616,12 +780,6 @@ class FunctionNode { return; } - // Allow rest parameters on Ti.Filesystem.getFile - if (this.definition.__inherits === 'Titanium.Filesystem' && this.definition.name === 'getFile') { - this.parameters = [ new VariableNode({ name: 'paths', type: 'Array', rest: true }) ]; - return; - } - let hasOptional = false; this.parameters = parameters.map(paramDoc => { if (!hasOptional && paramDoc.optional) { @@ -632,17 +790,13 @@ class FunctionNode { paramDoc.optional = true; } - // Due to our "special" inheritance, we cannot use a View as a type, use any instead. - // @todo Find a common "baseView" type? - if (paramDoc.type === 'Titanium.UI.View') { - paramDoc.type = 'any'; - } else if (paramDoc.type === 'Array') { - paramDoc.type = 'any[]'; - } - return new VariableNode(paramDoc); }); } + + setGeneric(value) { + this.generic = value; + } } /** @@ -650,43 +804,75 @@ class FunctionNode { * namesapce and interface nodes). */ class MemberNode { - constructor() { + constructor(api) { + this.api = api; + this.fullyQualifiedName = api.name; + this.name = api.name.substring(api.name.lastIndexOf('.') + 1); this.properties = []; this.methods = []; + this.events = []; + this.relatedNode = null; + this.innerNodesMap = new Map(); + this.membersAreStatic = false; + this.proxyEventMap = null; + } + + init() { + throw Error('Not implemented'); } parseProperties(properties) { - if (!properties) { + if (!properties || !properties.length) { return; } - properties = properties.filter(propertyDoc => { - // Filter out unused animate property which collides with the animate method - if (this.fullyQualifiedName === 'Titanium.Map.View' && propertyDoc.name === 'animate') { - return false; - } + const filterFunc = this.filterProperties.bind(this); + this.properties = []; + properties + .filter(filterFunc) + .sort(sortByName) + .forEach(propertyDoc => { + // Make all properties of global interfaces optional by default + if (this.fullyQualifiedName.indexOf('.') === -1 && propertyDoc.optional === undefined) { + propertyDoc.optional = true; + } - // Filter out the Android R accessor as it is represented by a namespace already - if (this.fullyQualifiedName === 'Titanium.Android' && propertyDoc.name === 'R') { - return false; - } + // Some iOS views do not have this property, so mark it as optional. + if (this.fullyQualifiedName === 'Titanium.Proxy' && propertyDoc.name === 'lifecycleContainer') { + propertyDoc.optional = true; + } - return !propertyDoc.__hide; - }); + const node = new VariableNode(propertyDoc, this.membersAreStatic); + if (this.innerNodesMap.has(propertyDoc.name)) { + common.log(common.LOG_WARN, `Duplicate identifier "${propertyDoc.name}" on API ${this.fullyQualifiedName}`); + return; + } + this.innerNodesMap.set(propertyDoc.name, node); + this.properties.push(node); + }); + } - this.properties = properties.map(propertyDoc => { - // Make all properties of global interfaces optional by default - if (this.fullyQualifiedName.indexOf('.') === -1 && propertyDoc.optional === undefined) { - propertyDoc.optional = true; - } + filterProperties(propertyDoc) { + // Filter out unused animate property which collides with the animate method + if (this.fullyQualifiedName === 'Titanium.Map.View' && propertyDoc.name === 'animate') { + return false; + } - // Some iOS views do not have this property, so mark it as optional. - if (this.fullyQualifiedName === 'Titanium.Proxy' && propertyDoc.name === 'lifecycleContainer') { - propertyDoc.optional = true; - } + // Filter out the Ti.Android.R accessor as it is represented by a namespace already + if (this.fullyQualifiedName === 'Titanium.Android' && propertyDoc.name === 'R') { + return false; + } - return new VariableNode(propertyDoc); - }); + // Filter out the Ti.App.Android.R accessor as it is represented by a namespace already + if (this.fullyQualifiedName === 'Titanium.App.Android' && propertyDoc.name === 'R') { + return false; + } + + if (propertyDoc.__inherits && propertyDoc.__inherits !== this.fullyQualifiedName && !this.membersAreStatic) { + return false; + } + + return true; } parseMethods(methods) { @@ -694,43 +880,100 @@ class MemberNode { return; } - let filteredMethods = []; - methods.forEach(methodDoc => { - if (methodDoc.__hide) { - return; - } + this.methods = []; - // Filter out removed fieldCount method (@todo check against version in "removed" property) - if (this.fullyQualifiedName === 'Titanium.Database.ResultSet' && methodDoc.name === 'fieldCount') { + methods.sort(sortByName).forEach(methodDoc => { + if (this.fullyQualifiedName === 'Titanium.Proxy' && /LifecycleContainer$/.test(methodDoc.name)) { + methodDoc.optional = true; + } + const isEventMethod = eventsMethods.includes(methodDoc.name); + if (!isEventMethod && methodDoc.__inherits && methodDoc.__inherits !== this.fullyQualifiedName && !this.membersAreStatic) { return; } - - // Filter out create functions for constant only proxies - if (/^create/.test(methodDoc.name)) { - const returnType = methodDoc.returns; - const returnTypeName = Array.isArray(returnType) ? returnType[0].type : returnType.type; - const returnTypeDoc = parser.apis[returnTypeName]; - if (returnTypeDoc && isConstantsOnlyProxy(returnTypeDoc)) { - return; + if (this.proxyEventMap && isEventMethod) { + const parameters = [ { + name: 'name', + optional: false, + summary: 'Name of the event.', + type: 'K', + __subtype: 'parameter' + } ]; + if (methodDoc.name === 'fireEvent') { + parameters.push({ + name: 'event', + optional: true, + summary: 'A dictionary of keys and values to add to the object sent to the listeners.', + type: `${this.proxyEventMap.name}[K]`, + __subtype: 'parameter' + }); + } else { + parameters.push({ + name: 'callback', + optional: false, + summary: 'Callback function name.', + // Pass preformatted type for callback + type: `(this: ${this.fullyQualifiedName}, event: ${this.proxyEventMap.name}[K]) => void`, + thisValue: this.fullyQualifiedName, + __subtype: 'parameter' + }); } + const node = new FunctionNode({ + name: methodDoc.name, + summary: methodDoc.summary, + parameters: parameters + }, this.membersAreStatic); + node.setGeneric(``); + this.methods.push(node); + } + if (this.innerNodesMap.has(methodDoc.name)) { + if (!methodDoc.deprecated || !methodDoc.deprecated.removed) { + // only currently known method is "fieldCount" from "Titanium.Database.ResultSet" + common.log(common.LOG_WARN, `Duplicate identifier "${methodDoc.name}" on API ${this.fullyQualifiedName}`); + } + return; } // Generate overloads if required and add them instead of the original method const overloads = this.generateMethodOverloadsIfRequired(methodDoc); - if (overloads.length > 0) { - filteredMethods = filteredMethods.concat(overloads); - } else { - filteredMethods.push(methodDoc); + if (!overloads.length) { + overloads.push(methodDoc); } + overloads.forEach(doc => { + const node = new FunctionNode(doc, this.membersAreStatic); + this.innerNodesMap.set(doc.name, node); + this.methods.push(node); + }); }); + } - this.methods = filteredMethods.map(methodDoc => { - if (this.fullyQualifiedName === 'Titanium.Proxy' && /LifecycleContainer$/.test(methodDoc.name)) { - methodDoc.optional = true; + parseEvents(events) { + if (!events || !events.length) { + return; + } + const baseEvent = InterfaceNode.createBaseEvent(this); + const properties = []; + this.events.push(baseEvent); + events.forEach(eventDoc => { + if (eventDoc.deprecated && eventDoc.deprecated.removed) { + return; } - - return new FunctionNode(methodDoc); + const eventNode = InterfaceNode.createEvent(eventDoc, this); + this.events.push(eventNode); + const name = eventDoc.name.indexOf(':') === -1 ? eventDoc.name : `"${eventDoc.name}"`; + properties.push({ + name: name, + optional: false, + summary: '', + type: eventNode.name + }); }); + this.proxyEventMap = new InterfaceNode({ + name: `${this.name}EventMap`, + extends: 'ProxyEventMap', + properties: properties, + summary: '' + }); + this.events.push(this.proxyEventMap); } /** @@ -738,10 +981,10 @@ class MemberNode { * definitions that are not compatible with union types. * * Currently only handles one case where a parameter can be passed as both a - * single value and as an array, e.g. Ti.UI.View, Array + * single (repeatable) value and as an array, e.g. ...Ti.UI.View[], Array * - * @param {Object} methodDoc Method defintions as parsed from YAML files - * @return {Array} List of overload method defintions + * @param {Object} methodDoc Method definitions as parsed from YAML files + * @return {Array} List of overload method definitions */ generateMethodOverloadsIfRequired(methodDoc) { const parameters = methodDoc.parameters; @@ -749,33 +992,44 @@ class MemberNode { return []; } + // TODO: proper types for Titanium.Database.DB.executeAsync, problem is: + // "TS1014: A rest parameter must be last in a parameter list." + const originalMethodDocJsonString = JSON.stringify(methodDoc); - const dictionaryTypePattern = /Dictionary<.*>/; + const arrayTypePattern = /Array<.*>/; let methodOverloads = []; - for (let i = 0; i < parameters.length; i++) { - const parameter = parameters[i]; - if (!Array.isArray(parameter.type)) { - continue; - } - - let parameterOverloads = []; - for (let type of parameter.type) { - if (dictionaryTypePattern.test(type)) { - const anyOverloadDoc = JSON.parse(originalMethodDocJsonString); - anyOverloadDoc.parameters[i].type = 'any'; - parameterOverloads = [ anyOverloadDoc ]; - break; - } + let hasRepeatableAndArray = false; + const last = parameters.length - 1; + const parameter = parameters[last]; + if (!Array.isArray(parameter.type) || !parameter.repeatable) { + return [methodDoc]; + } + let parameterOverloads = []; + for (const type of parameter.type) { + if (arrayTypePattern.test(type)) { + hasRepeatableAndArray = true; + const arrayOverloadDoc = JSON.parse(originalMethodDocJsonString); + arrayOverloadDoc.parameters[last].repeatable = false; + arrayOverloadDoc.parameters[last].type = type; + parameterOverloads.push(arrayOverloadDoc); + } else { const newOverloadDoc = JSON.parse(originalMethodDocJsonString); - newOverloadDoc.parameters[i].type = type; + newOverloadDoc.parameters[last].type = type; + newOverloadDoc.parameters[last].optional = false; parameterOverloads.push(newOverloadDoc); } + } + if (hasRepeatableAndArray) { methodOverloads = methodOverloads.concat(parameterOverloads); } - return methodOverloads; + if (hasRepeatableAndArray) { + return methodOverloads; + } else { + return [JSON.parse(originalMethodDocJsonString)]; + } } } @@ -783,19 +1037,52 @@ class MemberNode { * A namespace in typescript represents a module in our Titanium global */ class NamespaceNode extends MemberNode { - constructor(moduleDoc) { - super(); - - this.fullyQualifiedName = moduleDoc.name; - this.name = moduleDoc.name.substring(moduleDoc.name.lastIndexOf('.') + 1); - this.summary = moduleDoc.summary.trim(); - - this.parseProperties(moduleDoc.properties); - this.parseMethods(moduleDoc.methods); - + constructor(moduleDoc, relatedNode) { + super(moduleDoc, relatedNode); this.interfaces = []; this.namespaces = []; } + init() { + const moduleDoc = this.api; + this.summary = moduleDoc.summary ? moduleDoc.summary.trim() : ''; + + if (moduleDoc.deprecated && moduleDoc.deprecated.removed) { + this.removed = true; + this.summary += '\n@deprecated'; + if (moduleDoc.deprecated.notes) { + this.summary += ' ' + moduleDoc.deprecated.notes; + } + } + if (this.relatedNode) { + if ((!this.interfaces.length && !this.namespaces.length && !isConstantsOnlyProxy(moduleDoc)) || this.removed) { + this.relatedNode.relatedNode = null; + return; + } + } + if (this.removed) { + return; + } + this.parseProperties(moduleDoc.properties); + if (!this.relatedNode) { + this.parseEvents(moduleDoc.events); + this.parseMethods(moduleDoc.methods); + } + if (this.interfaces.length) { + this.interfaces.forEach(node => this.findDuplicates(node.name)); + } + if (this.namespaces.length) { + this.namespaces.forEach(node => this.findDuplicates(node.name)); + } + } + + filterProperties(propertyDoc) { + // If we have interface/class for this namespace, then we need here only upper cased constants + let onlyUpperCased = true; + if (this.relatedNode) { + onlyUpperCased = propertyDoc.name.toUpperCase() === propertyDoc.name; + } + return onlyUpperCased && super.filterProperties(propertyDoc); + } addNamespace(namespaceNode) { this.namespaces.push(namespaceNode); @@ -804,6 +1091,28 @@ class NamespaceNode extends MemberNode { addInterface(interfaceNode) { this.interfaces.push(interfaceNode); } + + findDuplicates(name) { + if (this.innerNodesMap.has(name)) { + common.log(common.LOG_WARN, `Duplicate identified "${name} on ${this.fullyQualifiedName}`); + const node = this.innerNodesMap.get(name); + let found = false; + let idx = this.properties.indexOf(node); + if (idx !== -1) { + found = true; + this.properties.splice(idx, 1); + } + idx = this.methods.indexOf(node); + if (idx !== -1) { + found = true; + this.methods.splice(idx, 1); + } + if (!found) { + throw new Error(`Unable to found identifier ${name} in the method or properties of ${this.fullyQualifiedName}`); + } + this.innerNodesMap.delete(name); + } + } } /** @@ -811,25 +1120,100 @@ class NamespaceNode extends MemberNode { */ class InterfaceNode extends MemberNode { constructor(typeDoc) { - super(); - - this.fullyQualifiedName = typeDoc.name; - this.name = typeDoc.name.substring(typeDoc.name.lastIndexOf('.') + 1); - if (invalidTypeMap[this.name]) { - this.name = invalidTypeMap[this.name]; + super(typeDoc); + this.removed = typeDoc.deprecated && typeDoc.deprecated.removed; + this.membersAreStatic = false; + this.keyWord = 'interface'; + } + init() { + const typeDoc = this.api; + this.summary = typeDoc.summary ? typeDoc.summary.trim() : ''; + if (typeDoc.deprecated) { + this.summary += '\n@deprecated'; + if (typeDoc.deprecated.notes) { + this.summary += ' ' + typeDoc.deprecated.notes; + } } - this.summary = typeDoc.summary.trim(); - - if (canExtend(typeDoc, parser.proxyInterface)) { - removeMembers(typeDoc, parser.proxyInterface); - this.extends = 'Titanium.Proxy'; + if (typeDoc.extends && this.name !== 'Titanium') { + this.extends = typeDoc.extends; } - if (canExtend(typeDoc, parser.viewInterface)) { - removeMembers(typeDoc, parser.viewInterface); - this.extends = 'Titanium.UI.View'; + if (!this.removed) { + this.parseEvents(typeDoc.events); + this.parseProperties(typeDoc.properties); + this.parseMethods(typeDoc.methods); } + // FIXME: Ti.Proxy has no documented "id" property + // currently if we put it in docs - accessors methods will show up in + // every class extended from Ti.Proxy + if (this.fullyQualifiedName === 'Titanium.Proxy') { + const array = this.properties.filter(prop => prop.name === 'id'); + if (!array.length) { + // injecting "id" property into "Titanium.Proxy" + this.properties.push(new VariableNode({ + name: 'id', + optional: true, + summary: 'Proxy identifier', + type: 'string | number' + }, false)); + } + } + } + + filterProperties(propertyDoc) { + if (this.relatedNode && propertyDoc.name === propertyDoc.name.toUpperCase()) { + // all upper cased constants will be present in the related namespace + return false; + } + return super.filterProperties(propertyDoc); + } +} - this.parseProperties(typeDoc.properties); - this.parseMethods(typeDoc.methods); +/** + * @param {MemberNode} interfaceNode node + * @return {InterfaceNode} + */ +InterfaceNode.createBaseEvent = function (interfaceNode) { + const name = interfaceNode.fullyQualifiedName; + return new InterfaceNode({ + name: `${interfaceNode.name}BaseEvent`, + extends: 'Ti.Event', + summary: `Base event for class ${name}`, + properties: [ + { name: 'source', type: name, optional: false, summary: 'Source object that fired the event.' } + ] + }); +}; + +/** + * @param {Object} eventDoc event description + * @param {MemberNode} interfaceNode node + * @return {InterfaceNode} + */ +InterfaceNode.createEvent = function (eventDoc, interfaceNode) { + let properties = eventDoc.properties; + if (properties) { + properties = eventDoc.properties + .filter(prop => prop.name !== 'source') + .map(prop => { + prop.optional = false; + return prop; + }); + } + const name = eventDoc.name.replace(':', '_'); + return new InterfaceNode({ + name: `${interfaceNode.name}_${name}_Event`, + extends: `${interfaceNode.name}BaseEvent`, + summary: eventDoc.summary, + properties: properties + }); +}; + +class ClassNode extends InterfaceNode { + constructor(typeDoc) { + super(typeDoc); + this.keyWord = 'class'; + if (typeDoc.__subtype === 'module') { + this.membersAreStatic = true; + } } } From e4dde5d99c9b750fd575f859bff55caf1ecf3743 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Mon, 17 Feb 2020 16:09:47 +0000 Subject: [PATCH 5/7] fix(docgen): use correct include syntax for ejs3 --- .../titanium-docgen/templates/htmlejs/event.html | 6 +++--- .../templates/htmlejs/event_list.html | 6 +++--- .../titanium-docgen/templates/htmlejs/header.html | 10 +++++----- .../titanium-docgen/templates/htmlejs/method.html | 6 +++--- .../templates/htmlejs/method_list.html | 6 +++--- .../templates/htmlejs/method_param_list.html | 4 ++-- .../titanium-docgen/templates/htmlejs/property.html | 4 ++-- .../templates/htmlejs/property_list.html | 6 +++--- .../titanium-docgen/templates/htmlejs/proxy.html | 12 ++++++------ .../templates/htmlejs/proxy_list.html | 4 ++-- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/titanium-docgen/templates/htmlejs/event.html b/packages/titanium-docgen/templates/htmlejs/event.html index 4cc02d46..3c74af07 100644 --- a/packages/titanium-docgen/templates/htmlejs/event.html +++ b/packages/titanium-docgen/templates/htmlejs/event.html @@ -1,8 +1,8 @@
-<% include header.html %> -<% include property_list.html %> +<%- include('header.html', { data }) %> +<%- include('property_list.html', { data }) %> -<% include footer.html %> +<%- include('footer.html', { data }) %>
diff --git a/packages/titanium-docgen/templates/htmlejs/event_list.html b/packages/titanium-docgen/templates/htmlejs/event_list.html index e1bd8a06..f40ea428 100644 --- a/packages/titanium-docgen/templates/htmlejs/event_list.html +++ b/packages/titanium-docgen/templates/htmlejs/event_list.html @@ -3,7 +3,7 @@

Events

<% if (data.isModule) { %> <% data.events.forEach(function (member) { %> - <% include module_member.html %> + <%- include('module_member.html', { member }) %> <% }); %> <% } else { %> @@ -13,11 +13,11 @@

Events

Summary <% data.events.forEach(function (member) { %> - <% include member_list.html %> + <%- include('member_list.html', { member }) %> <% }); %> <% } %> <% } else { %> This type has no events. -<% } %> \ No newline at end of file +<% } %> diff --git a/packages/titanium-docgen/templates/htmlejs/header.html b/packages/titanium-docgen/templates/htmlejs/header.html index d6419019..cedee926 100644 --- a/packages/titanium-docgen/templates/htmlejs/header.html +++ b/packages/titanium-docgen/templates/htmlejs/header.html @@ -1,12 +1,12 @@ -<% include page_nav.html %> +<%- include('page_nav.html', { data }) %> <% if (~['event', 'method', 'property'].indexOf(data.typestr)) { data.name = data.parent.name + '.' + data.name; } %>

<%- data.name %>

-<% include parent_info.html %> +<%- include('parent_info.html', { data }) %> -<% include platforms.html %> +<%- include('platforms.html', { data }) %> <% if (data.deprecated) { %>
@@ -47,8 +47,8 @@

Type

Summary

<%- data.summary %>
-<% include description.html %> +<%- include('description.html', { data }) %> -<% include examples.html %> +<%- include('examples.html', { data }) %> diff --git a/packages/titanium-docgen/templates/htmlejs/method.html b/packages/titanium-docgen/templates/htmlejs/method.html index a80b40c3..1096dd6d 100644 --- a/packages/titanium-docgen/templates/htmlejs/method.html +++ b/packages/titanium-docgen/templates/htmlejs/method.html @@ -1,12 +1,12 @@
-<% include header.html %> +<%- include('header.html', { data }) %> -<% include method_param_list.html %> +<%- include('method_param_list.html', { data }) %>

Return Type

<%- data.returnType %>
-<% include footer.html %> +<%- include('footer.html', { data }) %>
diff --git a/packages/titanium-docgen/templates/htmlejs/method_list.html b/packages/titanium-docgen/templates/htmlejs/method_list.html index 8ba9f01b..95197d25 100644 --- a/packages/titanium-docgen/templates/htmlejs/method_list.html +++ b/packages/titanium-docgen/templates/htmlejs/method_list.html @@ -3,7 +3,7 @@

Methods

<% if (data.isModule) { %> <% data.methods.forEach(function (member) { %> - <% include module_member.html %> + <%- include('module_member.html', { member }) %> <% }); %> <% } else { %> @@ -12,11 +12,11 @@

Methods

<% data.methods.forEach(function (member) { %> - <% include member_list.html %> + <%- include('member_list.html', { member }) %> <% }); %>
Summary
<% } %> <% } else { %> This type has no methods. -<% } %> \ No newline at end of file +<% } %> diff --git a/packages/titanium-docgen/templates/htmlejs/method_param_list.html b/packages/titanium-docgen/templates/htmlejs/method_param_list.html index d3f25107..8ab43911 100644 --- a/packages/titanium-docgen/templates/htmlejs/method_param_list.html +++ b/packages/titanium-docgen/templates/htmlejs/method_param_list.html @@ -8,10 +8,10 @@

Arguments

Summary <% data.parameters.forEach(function (member) { %> - <% include member_list.html %> + <%- include('member_list.html', { member }) %> <% }); %> <% } else { %> This function takes no arguments. -<% } %> \ No newline at end of file +<% } %> diff --git a/packages/titanium-docgen/templates/htmlejs/property.html b/packages/titanium-docgen/templates/htmlejs/property.html index 5e2119f2..729e53e8 100644 --- a/packages/titanium-docgen/templates/htmlejs/property.html +++ b/packages/titanium-docgen/templates/htmlejs/property.html @@ -1,7 +1,7 @@
-<% include header.html %> +<%- include('header.html') %> -<% include footer.html %> +<%- include('footer.html') %>
diff --git a/packages/titanium-docgen/templates/htmlejs/property_list.html b/packages/titanium-docgen/templates/htmlejs/property_list.html index 37ec6a22..2e636455 100644 --- a/packages/titanium-docgen/templates/htmlejs/property_list.html +++ b/packages/titanium-docgen/templates/htmlejs/property_list.html @@ -3,7 +3,7 @@

Properties

<% if (data.isModule) { %> <% data.properties.forEach(function (member) { %> - <% include module_member.html %> + <%- include('module_member.html', { member }) %> <% }); %> <% } else { %> @@ -13,11 +13,11 @@

Properties

<% data.properties.forEach(function (member) { %> - <% include member_list.html %> + <%- include('member_list.html', { member }) %> <% }); %>
Summary
<% } %> <% } else { %> This type has no properties. -<% } %> \ No newline at end of file +<% } %> diff --git a/packages/titanium-docgen/templates/htmlejs/proxy.html b/packages/titanium-docgen/templates/htmlejs/proxy.html index 58e04013..043505b9 100644 --- a/packages/titanium-docgen/templates/htmlejs/proxy.html +++ b/packages/titanium-docgen/templates/htmlejs/proxy.html @@ -3,12 +3,12 @@ <% } else { %>
<% } %> -<% include header.html %> +<%- include('header.html', { data }) %> <% if (data.typestr == "module") { %> - <% include proxy_list.html %> + <% include('proxy_list.html', { data }) %> <% } %> -<% include property_list.html %> -<% include method_list.html %> -<% include event_list.html %> -<% include footer.html %> +<%- include('property_list.html', { data }); %> +<%- include('method_list.html', { data }) %> +<%- include('event_list.html', { data }) %> +<%- include('footer.html', { data }) %>
diff --git a/packages/titanium-docgen/templates/htmlejs/proxy_list.html b/packages/titanium-docgen/templates/htmlejs/proxy_list.html index dd13aea0..3e83e4d0 100644 --- a/packages/titanium-docgen/templates/htmlejs/proxy_list.html +++ b/packages/titanium-docgen/templates/htmlejs/proxy_list.html @@ -8,8 +8,8 @@

Objects

Summary <% data.proxies.forEach(function (member) { %> - <% include member_list.html %> + <%- include('member_list.html', { member }) %> <% }); %> -<% } %> \ No newline at end of file +<% } %> From 2ddf897d720b7a39483d2c5e65d0fc8b0933f8f8 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Tue, 18 Feb 2020 10:56:18 +0000 Subject: [PATCH 6/7] chore(docgen): remove unused templates Based off the switch statement at index.js#973 none of these are actually reachable using the -f flag, so rather than fix them lets kill them off --- .../templates/html/description.html | 5 - .../titanium-docgen/templates/html/event.html | 8 - .../templates/html/event_list.html | 6 - .../templates/html/event_property_list.html | 8 - .../templates/html/examples.html | 11 -- .../templates/html/footer.html | 0 .../templates/html/header.html | 59 ------- .../titanium-docgen/templates/html/index.html | 64 -------- .../templates/html/member_list.html | 83 ---------- .../templates/html/method.html | 18 --- .../templates/html/method_list.html | 6 - .../templates/html/method_param_list.html | 6 - .../templates/html/page_nav.html | 59 ------- .../templates/html/parent_info.html | 33 ---- .../templates/html/platforms.html | 22 --- .../templates/html/property.html | 7 - .../templates/html/property_list.html | 9 -- .../titanium-docgen/templates/html/proxy.html | 18 --- .../templates/html/proxy_list.html | 3 - .../templates/modulehtml/description.html | 6 - .../templates/modulehtml/event.html | 6 - .../templates/modulehtml/event_list.html | 6 - .../modulehtml/event_property_list.html | 9 -- .../templates/modulehtml/examples.html | 11 -- .../templates/modulehtml/footer.html | 0 .../templates/modulehtml/header.html | 56 ------- .../templates/modulehtml/index.html | 20 --- .../modulehtml/member_description.html | 6 - .../templates/modulehtml/member_list.html | 123 -------------- .../templates/modulehtml/method.html | 17 -- .../templates/modulehtml/method_list.html | 6 - .../modulehtml/method_param_list.html | 7 - .../templates/modulehtml/page_nav.html | 52 ------ .../templates/modulehtml/parent_info.html | 33 ---- .../templates/modulehtml/platforms.html | 22 --- .../templates/modulehtml/property_list.html | 9 -- .../templates/modulehtml/proxy.html | 19 --- .../templates/modulehtml/proxy_list.html | 3 - .../templates/modulehtml/styles.css | 150 ------------------ .../templates/vsdoc/method.vsdoc.html | 36 ----- .../templates/vsdoc/module.vsdoc.html | 70 -------- 41 files changed, 1092 deletions(-) delete mode 100644 packages/titanium-docgen/templates/html/description.html delete mode 100644 packages/titanium-docgen/templates/html/event.html delete mode 100644 packages/titanium-docgen/templates/html/event_list.html delete mode 100644 packages/titanium-docgen/templates/html/event_property_list.html delete mode 100644 packages/titanium-docgen/templates/html/examples.html delete mode 100644 packages/titanium-docgen/templates/html/footer.html delete mode 100644 packages/titanium-docgen/templates/html/header.html delete mode 100644 packages/titanium-docgen/templates/html/index.html delete mode 100644 packages/titanium-docgen/templates/html/member_list.html delete mode 100644 packages/titanium-docgen/templates/html/method.html delete mode 100644 packages/titanium-docgen/templates/html/method_list.html delete mode 100644 packages/titanium-docgen/templates/html/method_param_list.html delete mode 100644 packages/titanium-docgen/templates/html/page_nav.html delete mode 100644 packages/titanium-docgen/templates/html/parent_info.html delete mode 100644 packages/titanium-docgen/templates/html/platforms.html delete mode 100644 packages/titanium-docgen/templates/html/property.html delete mode 100644 packages/titanium-docgen/templates/html/property_list.html delete mode 100644 packages/titanium-docgen/templates/html/proxy.html delete mode 100644 packages/titanium-docgen/templates/html/proxy_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/description.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/event.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/event_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/event_property_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/examples.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/footer.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/header.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/index.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/member_description.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/member_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/method.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/method_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/method_param_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/page_nav.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/parent_info.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/platforms.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/property_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/proxy.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/proxy_list.html delete mode 100644 packages/titanium-docgen/templates/modulehtml/styles.css delete mode 100644 packages/titanium-docgen/templates/vsdoc/method.vsdoc.html delete mode 100644 packages/titanium-docgen/templates/vsdoc/module.vsdoc.html diff --git a/packages/titanium-docgen/templates/html/description.html b/packages/titanium-docgen/templates/html/description.html deleted file mode 100644 index 68d07f6a..00000000 --- a/packages/titanium-docgen/templates/html/description.html +++ /dev/null @@ -1,5 +0,0 @@ -% if data.description_html and len(data.description_html) > 0: -

Description

- -
${data.description_html}
-% endif diff --git a/packages/titanium-docgen/templates/html/event.html b/packages/titanium-docgen/templates/html/event.html deleted file mode 100644 index fc1d852b..00000000 --- a/packages/titanium-docgen/templates/html/event.html +++ /dev/null @@ -1,8 +0,0 @@ -
- -<%include file="header.html"/> -<%include file="event_property_list.html"/> - -<%include file="footer.html"/> - -
diff --git a/packages/titanium-docgen/templates/html/event_list.html b/packages/titanium-docgen/templates/html/event_list.html deleted file mode 100644 index b8889da1..00000000 --- a/packages/titanium-docgen/templates/html/event_list.html +++ /dev/null @@ -1,6 +0,0 @@ -

Events

-% if data.events is not None and len(data.events) > 0: - <%include file="member_list.html" args="platform_count=len(data.platforms), item_list=data.events"/> -% else: - This type has no events. -% endif diff --git a/packages/titanium-docgen/templates/html/event_property_list.html b/packages/titanium-docgen/templates/html/event_property_list.html deleted file mode 100644 index f081f9b5..00000000 --- a/packages/titanium-docgen/templates/html/event_property_list.html +++ /dev/null @@ -1,8 +0,0 @@ -

Properties

-
Properties of the object passed to the event callback:
- -% if data.properties is not None and len(data.properties) > 0: - <%include file="member_list.html" args="platform_count=0, is_property_list=True, item_list=data.properties"/> -% else: - This event's callback has no properties. -% endif diff --git a/packages/titanium-docgen/templates/html/examples.html b/packages/titanium-docgen/templates/html/examples.html deleted file mode 100644 index 2cb651e0..00000000 --- a/packages/titanium-docgen/templates/html/examples.html +++ /dev/null @@ -1,11 +0,0 @@ -% if len(data.examples_html) > 0: -

Code Examples

- -
- % for example in data.examples_html : -

${example["title"]}

-
${example["example"]}
- % endfor -
- -% endif diff --git a/packages/titanium-docgen/templates/html/footer.html b/packages/titanium-docgen/templates/html/footer.html deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/titanium-docgen/templates/html/header.html b/packages/titanium-docgen/templates/html/header.html deleted file mode 100644 index abce88b2..00000000 --- a/packages/titanium-docgen/templates/html/header.html +++ /dev/null @@ -1,59 +0,0 @@ -<%include file="page_nav.html"/> - -<% - name = data.name - if data.typestr in ("method", "property", "event"): - name = "%s.%s" % (data.parent.name, name) -%> - -

${name}

- -<%include file="parent_info.html"/> - -<%include file="platforms.html"/> - -% if data.deprecated: -
Deprecated - % if "since" in data.deprecated: - since ${data.deprecated["since"]}. - % endif - % if "removed" in data.deprecated: - Removed in ${data.deprecated["removed"]}. - % endif - % if "notes_html" in data.deprecated: - ${data.deprecated["notes_html"]} - % endif - -
-% endif - -% if data.availability: -
Availability: ${data.availability}
-% endif - -% if data.permission: -
Permission: ${data.permission}
-% else: - % if data.typestr == "property": -
Permission: read-write
- % endif -% endif - -

Summary

-
${data.summary_html}
- -% if data.typestr == "property": -

Type

-
${data.type_html}
- - % if data.default is not None: -

Default

-
${data.default_html}
- % endif -% endif - -<%include file="description.html"/> - -<%include file="examples.html"/> - - diff --git a/packages/titanium-docgen/templates/html/index.html b/packages/titanium-docgen/templates/html/index.html deleted file mode 100644 index 8e6a0b2b..00000000 --- a/packages/titanium-docgen/templates/html/index.html +++ /dev/null @@ -1,64 +0,0 @@ - -<% - # This index.html is mostly for developers who generate the apidocs and want a module index. - # Not used for production. - def sort_by_name(items): - return sorted(items, key=lambda item: item.name) - - global_apis = [] - modules = [] - - import re - for item in data.values(): - if item.name == "Global": - for m in item.methods: - global_apis.append(m) - for p in item.properties: - global_apis.append(p) - elif item.name.startswith("Global"): - global_apis.append(item) - elif item.typestr == "module": - modules.append(item) - - global_apis = sort_by_name(global_apis) - modules = sort_by_name(modules) -%> - - - - Titanium Mobile SDK ${config.version} - - - -
- -
-

Global APIs

-
    - % for api in global_apis: - <% global_name = re.sub(r"Global\.?", "", api.name) %> -
  • - ${global_name} -
  • - % endfor -
-

Modules

-
    - % for m in modules: -
  • - ${m.name} -
  • - % endfor -
-
-
- - - - - - diff --git a/packages/titanium-docgen/templates/html/member_list.html b/packages/titanium-docgen/templates/html/member_list.html deleted file mode 100644 index 130b1443..00000000 --- a/packages/titanium-docgen/templates/html/member_list.html +++ /dev/null @@ -1,83 +0,0 @@ -<%page args="item_list, platform_count, is_property_list=False"/> - - - - % if is_property_list: - - % endif - - -% for item in item_list: - % if item.name not in ("Titanium.Proxy", "Titanium.Module"): - <% row_class = " ".join(["in_" + p["name"].lower() for p in item.platforms]) %> - <% - if hasattr(item, "getter_for") or hasattr(item, "setter_for"): - row_class += " accessor" - if item.inherited_from_obj is not None: - row_class += " inherited" - %> - <% platform_names = ", ".join([p["pretty_name"] for p in item.platforms]) %> - <% append_cell_class = " deprecated" if item.deprecated else "" %> - <% - if hasattr(item, "repeatable") and item.repeatable: - item_name = "%s..." % item.name - else: - item_name = item.name - %> - <% - summary = item.summary_html - was_para_close = False - if summary.endswith("

"): - summary = summary[:-4] # we'll put it back later, promise - was_para_close = True - %> - - - % if item.typestr=="parameter" or (item.typestr=="property" and item.parent.typestr=="event"): - - % else: - - % endif - % if is_property_list: - - % endif - - - % endif -% endfor -
NameTypeSummary
${item_name}${item_name}${item.type_html} - % if item.deprecated is not None: - <% - if summary.startswith("

"): - summary = '%sDeprecated %s' % (summary[:3],summary[3:]) - %> - % endif - ${summary} - % if len(item.platforms) < platform_count: - (${platform_names} only.) - % endif - % if item.permission is not None: - ${item.permission} - % endif - % if item.availability is not None: - ${item.availability} - % endif - % if item.typestr=="parameter": - % if item.optional is not None: - Optional. - % endif - % if item.repeatable: - Repeatable. - % endif - % if item.default is not None: - <% - if item.default_html.startswith("

"): - item.default_html = item.default_html[3:-4] - %> - Default: ${item.default_html} - % endif - % endif - % if was_para_close: -

- % endif -
diff --git a/packages/titanium-docgen/templates/html/method.html b/packages/titanium-docgen/templates/html/method.html deleted file mode 100644 index 9a932faa..00000000 --- a/packages/titanium-docgen/templates/html/method.html +++ /dev/null @@ -1,18 +0,0 @@ -
- -<%include file="header.html"/> - -<%include file="method_param_list.html"/> - -

Return Type

-
- % if len(data.return_type_html) > 0: - ${data.return_type_html} - % else: - void - % endif -
- -<%include file="footer.html"/> - -
diff --git a/packages/titanium-docgen/templates/html/method_list.html b/packages/titanium-docgen/templates/html/method_list.html deleted file mode 100644 index c9977ec0..00000000 --- a/packages/titanium-docgen/templates/html/method_list.html +++ /dev/null @@ -1,6 +0,0 @@ -

Methods

-% if data.methods and len(data.methods)>0: - <%include file="member_list.html" args="platform_count=len(data.platforms), item_list=data.methods"/> -% else: - This type has no methods. -% endif diff --git a/packages/titanium-docgen/templates/html/method_param_list.html b/packages/titanium-docgen/templates/html/method_param_list.html deleted file mode 100644 index 450c54d8..00000000 --- a/packages/titanium-docgen/templates/html/method_param_list.html +++ /dev/null @@ -1,6 +0,0 @@ -

Arguments

-% if data.parameters is not None and len(data.parameters) > 0: - <%include file="member_list.html" args="platform_count=0, is_property_list=True, item_list=data.parameters"/> -% else: - This function takes no arguments. -% endif diff --git a/packages/titanium-docgen/templates/html/page_nav.html b/packages/titanium-docgen/templates/html/page_nav.html deleted file mode 100644 index 6133dad5..00000000 --- a/packages/titanium-docgen/templates/html/page_nav.html +++ /dev/null @@ -1,59 +0,0 @@ - diff --git a/packages/titanium-docgen/templates/html/parent_info.html b/packages/titanium-docgen/templates/html/parent_info.html deleted file mode 100644 index d22121ac..00000000 --- a/packages/titanium-docgen/templates/html/parent_info.html +++ /dev/null @@ -1,33 +0,0 @@ -
-% if data.typestr == "module" and data.parent is None: - Module -% else: - <% - typestr = "" - if data.typestr == "module": - typestr = "Submodule" - elif data.typestr == "proxy": - typestr = "Object" - elif data.typestr == "method": - typestr = "Function" - elif data.typestr == "property": - typestr = "Property" - elif data.typestr == "event": - typestr = "Event" - elif data.typestr == "parameter": - typestr = "Parameter" - %> - % if typestr == "Property" and data.parent.typestr == "event": - ${typestr} of ${data.parent.parent.name}.${data.parent.name} event callback. - % elif typestr == "Parameter": - ${typestr} of ${data.parent.parent.name}.${data.parent.name} method. - % elif len(typestr) > 0 and data.parent is not None: - ${typestr} of ${data.parent.name}. - % else: - ${typestr} - % endif - % if not (data.inherited_from_obj is None): - Inherited from ${data.inherited_from_obj.name}. - % endif -% endif -
diff --git a/packages/titanium-docgen/templates/html/platforms.html b/packages/titanium-docgen/templates/html/platforms.html deleted file mode 100644 index 362d058c..00000000 --- a/packages/titanium-docgen/templates/html/platforms.html +++ /dev/null @@ -1,22 +0,0 @@ -
- % for p in data.platforms: - - % endfor - -
- - - - - - - - % for p in data.platforms: - - - - - % endfor -
PlatformSince
${p["pretty_name"]}${p["since"]}
-
-
diff --git a/packages/titanium-docgen/templates/html/property.html b/packages/titanium-docgen/templates/html/property.html deleted file mode 100644 index 53025af9..00000000 --- a/packages/titanium-docgen/templates/html/property.html +++ /dev/null @@ -1,7 +0,0 @@ -
- -<%include file="header.html"/> - -<%include file="footer.html"/> - -
diff --git a/packages/titanium-docgen/templates/html/property_list.html b/packages/titanium-docgen/templates/html/property_list.html deleted file mode 100644 index 17dc6c53..00000000 --- a/packages/titanium-docgen/templates/html/property_list.html +++ /dev/null @@ -1,9 +0,0 @@ -

Properties

- -% if data.properties is not None and len(data.properties) > 0: - - <%include file="member_list.html" args="item_list=data.properties, platform_count=len(data.platforms), is_property_list=True"/> - -% else: - This type has no properties. -% endif diff --git a/packages/titanium-docgen/templates/html/proxy.html b/packages/titanium-docgen/templates/html/proxy.html deleted file mode 100644 index 9838c8ec..00000000 --- a/packages/titanium-docgen/templates/html/proxy.html +++ /dev/null @@ -1,18 +0,0 @@ -% if data.typestr == "module": -
-% else: -
-% endif - -<%include file="header.html"/> - -% if data.typestr == "module" and data.member_proxies and len(data.member_proxies)>0: - <%include file="proxy_list.html"/> -% endif - -<%include file="method_list.html"/> -<%include file="property_list.html"/> -<%include file="event_list.html"/> -<%include file="footer.html"/> - -
diff --git a/packages/titanium-docgen/templates/html/proxy_list.html b/packages/titanium-docgen/templates/html/proxy_list.html deleted file mode 100644 index 6a481a42..00000000 --- a/packages/titanium-docgen/templates/html/proxy_list.html +++ /dev/null @@ -1,3 +0,0 @@ -

Objects

- -<%include file="member_list.html" args="item_list=data.member_proxies, platform_count=len(data.platforms)"/> diff --git a/packages/titanium-docgen/templates/modulehtml/description.html b/packages/titanium-docgen/templates/modulehtml/description.html deleted file mode 100644 index c8ea274b..00000000 --- a/packages/titanium-docgen/templates/modulehtml/description.html +++ /dev/null @@ -1,6 +0,0 @@ -% if data.description_html and len(data.description_html) > 0: -

Description

- -
${data.summary_html}
-
${data.description_html}
-% endif diff --git a/packages/titanium-docgen/templates/modulehtml/event.html b/packages/titanium-docgen/templates/modulehtml/event.html deleted file mode 100644 index 78df6491..00000000 --- a/packages/titanium-docgen/templates/modulehtml/event.html +++ /dev/null @@ -1,6 +0,0 @@ -<%page args="item"/> -
- -<%include file="event_property_list.html" args="item=item"/> - -
diff --git a/packages/titanium-docgen/templates/modulehtml/event_list.html b/packages/titanium-docgen/templates/modulehtml/event_list.html deleted file mode 100644 index 515cc12a..00000000 --- a/packages/titanium-docgen/templates/modulehtml/event_list.html +++ /dev/null @@ -1,6 +0,0 @@ -

Events

-% if data.events is not None and len(data.events) > 0: - <%include file="member_list.html" args="platform_count=len(data.platforms), item_list=data.events, div_class='events'"/> -% else: - This type has no events. -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/event_property_list.html b/packages/titanium-docgen/templates/modulehtml/event_property_list.html deleted file mode 100644 index ef9b0ce8..00000000 --- a/packages/titanium-docgen/templates/modulehtml/event_property_list.html +++ /dev/null @@ -1,9 +0,0 @@ -<%page args="item"/> -

Properties

-
Properties of the object passed to the event callback:
- -% if item.properties is not None and len(item.properties) > 0: - <%include file="member_list.html" args="platform_count=0, is_property_list=True, item_list=item.properties, is_method_param_list=True, div_class='events'"/> -% else: - This event's callback has no properties. -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/examples.html b/packages/titanium-docgen/templates/modulehtml/examples.html deleted file mode 100644 index ba75595d..00000000 --- a/packages/titanium-docgen/templates/modulehtml/examples.html +++ /dev/null @@ -1,11 +0,0 @@ -% if len(data.examples_html) > 0: -

Code Examples

- -
- % for example in data.examples_html : -

${example["title"]}

-
${example["example"]}
- % endfor -
- -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/footer.html b/packages/titanium-docgen/templates/modulehtml/footer.html deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/titanium-docgen/templates/modulehtml/header.html b/packages/titanium-docgen/templates/modulehtml/header.html deleted file mode 100644 index ca586dc7..00000000 --- a/packages/titanium-docgen/templates/modulehtml/header.html +++ /dev/null @@ -1,56 +0,0 @@ -<%include file="page_nav.html"/> - -<% - name = data.name - if data.typestr in ("method", "property", "event"): - name = "%s.%s" % (data.parent.name, name) -%> - -

${name}

- -<%include file="parent_info.html"/> - -<%include file="platforms.html"/> - -% if data.deprecated: -
Deprecated - % if "since" in data.deprecated: - since ${data.deprecated["since"]}. - % endif - % if "removed" in data.deprecated: - Removed in ${data.deprecated["removed"]}. - % endif - % if "notes_html" in data.deprecated: - ${data.deprecated["notes_html"]} - % endif - -
-% endif - -% if data.availability: -
Availability: ${data.availability}
-% endif - -% if data.permission: -
Permission: ${data.permission}
-% else: - % if data.typestr == "property": -
Permission: read-write
- % endif -% endif - -% if data.typestr == "property": -

Type

-
${data.type_html}
- - % if data.default is not None: -

Default

-
${data.default_html}
- % endif -% endif - -<%include file="description.html"/> - -<%include file="examples.html"/> - - diff --git a/packages/titanium-docgen/templates/modulehtml/index.html b/packages/titanium-docgen/templates/modulehtml/index.html deleted file mode 100644 index 278509a3..00000000 --- a/packages/titanium-docgen/templates/modulehtml/index.html +++ /dev/null @@ -1,20 +0,0 @@ - -<% - module_filename = False - for item in data.values(): - if item.name.startswith("Modules") and item.typestr == "module": - module_filename = "%s.html" % item.filename_html - break -%> -% if module_filename: - - - - - - If you are not redirected automatically, follow the link - - -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/member_description.html b/packages/titanium-docgen/templates/modulehtml/member_description.html deleted file mode 100644 index 345a6bbf..00000000 --- a/packages/titanium-docgen/templates/modulehtml/member_description.html +++ /dev/null @@ -1,6 +0,0 @@ -<%page args="item"/> -% if item.description_html and len(item.description_html) > 0: -

Description

- -
${item.description_html}
-% endif diff --git a/packages/titanium-docgen/templates/modulehtml/member_list.html b/packages/titanium-docgen/templates/modulehtml/member_list.html deleted file mode 100644 index 67a47a6a..00000000 --- a/packages/titanium-docgen/templates/modulehtml/member_list.html +++ /dev/null @@ -1,123 +0,0 @@ -<%page args="item_list, platform_count, div_class, is_property_list=False, is_method_param_list=False, is_proxy_list=False"/> -% if is_proxy_list: - - - - - -% else: -
-% endif - - % if is_method_param_list: -
    - % endif - % for item in item_list: - % if is_method_param_list: -
  • - % endif - % if item.name not in ("Titanium.Proxy", "Titanium.Module"): - <% row_class = " ".join(["in_" + p["name"].lower() for p in item.platforms]) %> - <% - if hasattr(item, "getter_for") or hasattr(item, "setter_for"): - row_class += " accessor" - if item.inherited_from_obj is not None: - row_class += " inherited" - %> - <% platform_names = ", ".join([p["pretty_name"] for p in item.platforms]) %> - <% append_cell_class = " deprecated" if item.deprecated else "" %> - <% - if hasattr(item, "repeatable") and item.repeatable: - item_name = "%s..." % item.name - else: - item_name = item.name - %> - <% - summary = item.summary_html - was_para_close = False - if summary.endswith("

    "): - summary = summary[:-4] # we'll put it back later, promise - was_para_close = True - %> - % if is_method_param_list: -
    ${item_name} : ${item.type_html} - % elif is_property_list: -

    ${item_name} : ${item.type_html} - % elif is_proxy_list: -

- - - - % endif - % endfor - % if is_method_param_list: - - % endif - -% if is_proxy_list: -
NameSummary
${item_name} - % else: -

${item_name}

- % endif - - % if len(item.platforms) < platform_count: - (${platform_names} only) - % endif - % if item.permission is not None: - ${item.permission} - % endif - % if item.availability is not None: - ${item.availability} - % endif - % if item.typestr=="parameter": - % if item.optional is not None: - (optional) - % endif - % if item.repeatable: - (repeatable) - % endif - % endif - % if is_method_param_list: - - % elif is_property_list: - - % endif -
- % if item.deprecated is not None: - <% - if summary.startswith("

"): - summary = '%sDeprecated %s' % (summary[:3],summary[3:]) - %> - % endif - ${summary} - % if item.typestr=="parameter" and item.default is not None: - <% - if item.default_html.startswith("

"): - item.default_html = item.default_html[3:-4] - %> - Default: ${item.default_html} - % endif - % if was_para_close: -

- % endif - - % if not is_proxy_list: - <%include file="member_description.html" args="item=item"/> - % endif - - % if item.typestr=="method": - <%include file="method.html" args="item=item"/> - % elif item.typestr=="event": - <%include file="event.html" args="item=item"/> - % endif -
- % endif - % if is_method_param_list: - - % endif - % if is_proxy_list: -
-% else: -
-% endif - diff --git a/packages/titanium-docgen/templates/modulehtml/method.html b/packages/titanium-docgen/templates/modulehtml/method.html deleted file mode 100644 index 1e6561df..00000000 --- a/packages/titanium-docgen/templates/modulehtml/method.html +++ /dev/null @@ -1,17 +0,0 @@ -<%page args="item"/> -
-
    - <%include file="method_param_list.html" args="item=item"/> - -
  • -

    Returns

    -
    - % if len(item.return_type_html) > 0: - ${item.return_type_html} - % else: - void - % endif -
    -
  • -
      -
diff --git a/packages/titanium-docgen/templates/modulehtml/method_list.html b/packages/titanium-docgen/templates/modulehtml/method_list.html deleted file mode 100644 index e8e96ece..00000000 --- a/packages/titanium-docgen/templates/modulehtml/method_list.html +++ /dev/null @@ -1,6 +0,0 @@ -

Methods

-% if data.methods and len(data.methods)>0: - <%include file="member_list.html" args="platform_count=len(data.platforms), item_list=data.methods, div_class='methods'"/> -% else: - This type has no methods. -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/method_param_list.html b/packages/titanium-docgen/templates/modulehtml/method_param_list.html deleted file mode 100644 index c0037bfa..00000000 --- a/packages/titanium-docgen/templates/modulehtml/method_param_list.html +++ /dev/null @@ -1,7 +0,0 @@ -<%page args="item"/> -% if item.parameters is not None and len(item.parameters) > 0: -
  • -

    Parameters

    - <%include file="member_list.html" args="platform_count=0, is_property_list=True, item_list=item.parameters, div_class='arguments', is_method_param_list=True"/> -
  • -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/page_nav.html b/packages/titanium-docgen/templates/modulehtml/page_nav.html deleted file mode 100644 index a42f80f5..00000000 --- a/packages/titanium-docgen/templates/modulehtml/page_nav.html +++ /dev/null @@ -1,52 +0,0 @@ - diff --git a/packages/titanium-docgen/templates/modulehtml/parent_info.html b/packages/titanium-docgen/templates/modulehtml/parent_info.html deleted file mode 100644 index d22121ac..00000000 --- a/packages/titanium-docgen/templates/modulehtml/parent_info.html +++ /dev/null @@ -1,33 +0,0 @@ -
    -% if data.typestr == "module" and data.parent is None: - Module -% else: - <% - typestr = "" - if data.typestr == "module": - typestr = "Submodule" - elif data.typestr == "proxy": - typestr = "Object" - elif data.typestr == "method": - typestr = "Function" - elif data.typestr == "property": - typestr = "Property" - elif data.typestr == "event": - typestr = "Event" - elif data.typestr == "parameter": - typestr = "Parameter" - %> - % if typestr == "Property" and data.parent.typestr == "event": - ${typestr} of ${data.parent.parent.name}.${data.parent.name} event callback. - % elif typestr == "Parameter": - ${typestr} of ${data.parent.parent.name}.${data.parent.name} method. - % elif len(typestr) > 0 and data.parent is not None: - ${typestr} of ${data.parent.name}. - % else: - ${typestr} - % endif - % if not (data.inherited_from_obj is None): - Inherited from ${data.inherited_from_obj.name}. - % endif -% endif -
    diff --git a/packages/titanium-docgen/templates/modulehtml/platforms.html b/packages/titanium-docgen/templates/modulehtml/platforms.html deleted file mode 100644 index 362d058c..00000000 --- a/packages/titanium-docgen/templates/modulehtml/platforms.html +++ /dev/null @@ -1,22 +0,0 @@ -
    - % for p in data.platforms: - - % endfor - -
    - - - - - - - - % for p in data.platforms: - - - - - % endfor -
    PlatformSince
    ${p["pretty_name"]}${p["since"]}
    -
    -
    diff --git a/packages/titanium-docgen/templates/modulehtml/property_list.html b/packages/titanium-docgen/templates/modulehtml/property_list.html deleted file mode 100644 index 5003f825..00000000 --- a/packages/titanium-docgen/templates/modulehtml/property_list.html +++ /dev/null @@ -1,9 +0,0 @@ -

    Properties

    - -% if data.properties is not None and len(data.properties) > 0: - - <%include file="member_list.html" args="item_list=data.properties, platform_count=len(data.platforms), is_property_list=True, div_class='properties'"/> - -% else: - This type has no properties. -% endif diff --git a/packages/titanium-docgen/templates/modulehtml/proxy.html b/packages/titanium-docgen/templates/modulehtml/proxy.html deleted file mode 100644 index 80a4fcec..00000000 --- a/packages/titanium-docgen/templates/modulehtml/proxy.html +++ /dev/null @@ -1,19 +0,0 @@ -% if data.typestr == "module": -
    -% else: -
    -% endif - -<%include file="header.html"/> - -% if data.typestr == "module" and data.member_proxies and len(data.member_proxies)>0: - <%include file="proxy_list.html"/> -% endif - -<%include file="property_list.html"/> -<%include file="method_list.html"/> -<%include file="event_list.html"/> - -<%include file="footer.html"/> - -
    diff --git a/packages/titanium-docgen/templates/modulehtml/proxy_list.html b/packages/titanium-docgen/templates/modulehtml/proxy_list.html deleted file mode 100644 index 1af9eb8c..00000000 --- a/packages/titanium-docgen/templates/modulehtml/proxy_list.html +++ /dev/null @@ -1,3 +0,0 @@ -

    Objects

    - -<%include file="member_list.html" args="item_list=data.member_proxies, platform_count=len(data.platforms), div_class='objects', is_proxy_list=True"/> diff --git a/packages/titanium-docgen/templates/modulehtml/styles.css b/packages/titanium-docgen/templates/modulehtml/styles.css deleted file mode 100644 index 1ccb3871..00000000 --- a/packages/titanium-docgen/templates/modulehtml/styles.css +++ /dev/null @@ -1,150 +0,0 @@ -html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { - background: transparent; - border: 0; - font-size: 100%; - margin: 0; - outline: 0; - padding: 0; - vertical-align: baseline; -} -body { - line-height: 1; - margin: 20px; - font-family: Helvetica, Arial, sans-serif; - font-size: 13px; -} -ul { - list-style: inherit; -} -ol { - list-style: decimal; -} -ol, ul { - padding: 10px 0 0 20px; -} -.page-nav ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -:focus { - outline: 0; -} -ins { - text-decoration: none; -} -del { - text-decoration: line-through; -} -table { - border-collapse: collapse; - border-spacing: 0; -} -a { - color: inherit; -} -a:hover { - text-decoration: underline; -} -.clear { - clear: both; -} -h1 { - font-size: 20px; - padding: 10px; - margin: 20px 0 10px; - border-bottom: 1px solid #820e18; - background: #CF1626; - color: #FFF; -} -h2 { - font-size: 16px; - padding: 10px; - margin: 20px 0 10px; - border-bottom: 1px solid #111; - background: #666; - color: #FFF; -} -h3 { - font-size: 16px; - padding: 10px 0; - margin: 10px 0 0; -} -h4 { - padding: 10px 0 10px 0; -} -h5 { - padding: 10px 0 10px 0; -} -p { - padding: 5px 0 5px 0; - line-height: 16px; -} -pre { - background: #EEE; - border: 1px solid #CCC; - padding: 10px; - margin: 10px 0; -} -table { - margin: 10px 0 0 10px; -} -table th { - background: #EEE; - border-bottom: 1px solid #CCC; -} -table th, table td { - padding: 10px 15px; -} -.page-nav li { - color: #222; - float: left; - margin: 0 10px 10px 0; - line-height: 26px; -} -.page-nav li a { - text-decoration: none; - line-height: 14px; - padding: 5px 10px; - border: 1px solid #CCC; - display: block; - color: #444; -} -.namespace { - clear: both; -} -.namespace_type, -.summary, -.description, -.examples, -.methods, -.properties, -.objects, -.events { - padding: 0 0 0 10px; -} -.arguments { - padding: 0 0 10px 20px; -} -.return_type, -.member_description { - padding: 0 0 0 20px; -} -.apidoc_container .apidoc_method { - padding: 0 0 0 20px; -} -.deprecation_warning, -.platform_warning, -.permission_warning, -.availability_warning { - font-size: 12; - border-radius: 2px; - margin-left: 5px; - padding: 2px 3px; - color: #FFF; - background-color: #aaa; -} -.permission_warning { - text-transform: uppercase; -} \ No newline at end of file diff --git a/packages/titanium-docgen/templates/vsdoc/method.vsdoc.html b/packages/titanium-docgen/templates/vsdoc/method.vsdoc.html deleted file mode 100644 index 92680ea5..00000000 --- a/packages/titanium-docgen/templates/vsdoc/method.vsdoc.html +++ /dev/null @@ -1,36 +0,0 @@ -<%! import re -#it's just about time to break out module and 'object' templates -safeWord = { 'default' : 'defaultValue' } -def getSafeWord(str): - return safeWord.get(str,str) - -def getReturnType(str, defaultValue): - needle = 'Creates and returns an instance of ' - if needle in str: - return re.split(needle,str)[-1] - else: - return defaultValue - -def getTypeInstance(str, defaultValue): - needle = 'Creates and returns an instance of ' - if needle in str: - return 'new ' + re.split(needle,str)[-1] + '()' - else: - return defaultValue - -def propertyAssign(typestr): - return ':' if typestr=='module' else '=' - -def objectPrefix(typestr): - return '' if typestr=='module' else 'this.' - -%><%page args="m,d"/> -${objectPrefix(d.typestr)}${m['name'].replace('[object]','')} ${propertyAssign(d.typestr)} function(${', '.join(map(lambda w: getSafeWord(w['name']), m['parameters']))}) - { - ///${d.remove_html_tags(m['value'])} - %for p in m['parameters']: - ///${d.remove_html_tags(p['summary'])} - %endfor - /// - return ${d.vsdoc_return_type(d.remove_html_tags(getTypeInstance(m['value'], d.vsdoc_return_type(m['returntype']))))}; - } diff --git a/packages/titanium-docgen/templates/vsdoc/module.vsdoc.html b/packages/titanium-docgen/templates/vsdoc/module.vsdoc.html deleted file mode 100644 index 423e6e32..00000000 --- a/packages/titanium-docgen/templates/vsdoc/module.vsdoc.html +++ /dev/null @@ -1,70 +0,0 @@ -<%! import re -#it's just about time to break out module and 'object' templates -def propertyAssign(typestr): - return ':' if typestr=='module' else '=' -def propertyTerm(typestr): - return ',' if typestr == 'module' else ';' -def propertyWrap(typestr): - return "'" if typestr=='module' else '' -def objectPrefix(typestr): - return '' if typestr=='module' else 'this.' -%>\ -<%def name="moduleName()">\ -${''.join(map(lambda w: '[\''+w+'\']' if re.match('^\d',w) else '.'+w if data.namespace.split('.')[0]!=w else w, data.namespace.split('.')))}\ -\ -%if data.namespace == 'Titanium': -var Ti,Titanium; Ti = \ -%endif -${moduleName()} = \ -%if data.typestr == 'object': -function() { -%else: -{ -%endif -%for p in data.properties: - ${objectPrefix(data.typestr)}${propertyWrap(data.typestr)}${''.join(map(lambda w: w.capitalize() if w in p['name'].split('-')[1:] else w,p['name'].split('-')))}${propertyWrap(data.typestr)} ${propertyAssign(data.typestr)} \ - %if p['name'] == 'currentWindow': # hack to make the vsdoc not die. Ti.UI.Window is defined later on. -{} - %else: -${data.vsdoc_return_type(data.remove_html_tags(p['type']))}\ - %endif - %if (p['name'] != data.properties[-1]['name'] or (len(data.events) != 0 or len(data.methods)!=0)): -${propertyTerm(data.typestr)} - %elif data.typestr == 'object': -; - %else: - - %endif -%endfor -%if len(data.events)>0: - ${objectPrefix(data.typestr)}events ${propertyAssign(data.typestr)} {\ - %for e in data.events: -'${e['name']}':''\ - %if e['name'] != data.events[-1]['name']: -,\ - %endif - %endfor -}\ - %if len(data.methods)!=0: -${propertyTerm(data.typestr)} - %endif -%endif -%for m in data.methods: - <%include file="method.vsdoc.html" args="m=m,d=data"/>\ - %if m['name'] != data.methods[-1]['name']: -${propertyTerm(data.typestr)} -%elif data.typestr == 'object': -; - %else: - - %endif -%endfor -%if data.typestr == 'object': - -%endif -}; -%if data.typestr == 'module': -${moduleName()}.__namespace = true; -%elif data.typestr == 'object': -${moduleName()}.__class = true; -%endif From e00f17543f1293f456c798a871425a0ab1372627 Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Tue, 18 Feb 2020 10:56:42 +0000 Subject: [PATCH 7/7] fix(docgen/modulehtml): correct require path --- packages/titanium-docgen/generators/modulehtml_generator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/titanium-docgen/generators/modulehtml_generator.js b/packages/titanium-docgen/generators/modulehtml_generator.js index 66562505..25593644 100644 --- a/packages/titanium-docgen/generators/modulehtml_generator.js +++ b/packages/titanium-docgen/generators/modulehtml_generator.js @@ -3,7 +3,7 @@ */ 'use strict'; -const exporter = require('../lib/html_generator.js'); +const exporter = require('./html_generator.js'); /** * Returns a JSON object formatted for HTML EJS templates