Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tidev/docs-devkit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: develop
Choose a base ref
...
head repository: TiStrong/docs-devkit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feature/typescript
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Dec 13, 2019

  1. Copy the full SHA
    24627b8 View commit details

Commits on Dec 18, 2019

  1. Copy the full SHA
    618a379 View commit details
  2. Copy the full SHA
    452fc9e View commit details
  3. fix(docgen): typescript: improve generator

    - generate Global properties
    - generate namespace and interface for modules
    drauggres committed Dec 18, 2019
    Copy the full SHA
    bdc6096 View commit details
  4. Copy the full SHA
    572c478 View commit details
  5. Copy the full SHA
    3eecc87 View commit details
  6. Copy the full SHA
    12a5011 View commit details
  7. Copy the full SHA
    6f231c6 View commit details

Commits on Dec 25, 2019

  1. Copy the full SHA
    f70d3b3 View commit details
  2. Copy the full SHA
    12cb24e View commit details

Commits on Dec 26, 2019

  1. fix(docgen): typescript: update to pass DefinitelyTyped linter

    - remove trailing spaces from jsdoc
    - use "any[]" as parameter for Ti.Database.DB.execute
    - use "Array<Dictionany<T>>" type instead of "Dictionary<T>[]"
    - 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
    drauggres committed Dec 26, 2019
    Copy the full SHA
    79012d8 View commit details
  2. Copy the full SHA
    9bc6012 View commit details
  3. fix(docgen): typescript: generate only namespace for Titanium

    generated class for Titanium will have only static members
    drauggres committed Dec 26, 2019
    Copy the full SHA
    f9c655b View commit details
  4. Copy the full SHA
    b73bcbb View commit details
  5. Copy the full SHA
    4281e68 View commit details
  6. fix(docgen): typescript: update header

    It is valid to pass a function (e.g. "onload") to Ti.Network.createHTTPClient()
    in Dictionary<Ti.Network.HTTPClient>.
    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.
    drauggres committed Dec 26, 2019
    Copy the full SHA
    c9571cc View commit details

Commits on Dec 27, 2019

  1. Copy the full SHA
    8443b56 View commit details

Commits on Jan 9, 2020

  1. Copy the full SHA
    0015133 View commit details
  2. Copy the full SHA
    fa8ee78 View commit details

Commits on Jan 16, 2020

  1. Copy the full SHA
    0432369 View commit details
  2. Copy the full SHA
    ee1caa6 View commit details
  3. Copy the full SHA
    1fe107a View commit details

Commits on Jan 17, 2020

  1. Copy the full SHA
    cc26435 View commit details
  2. Copy the full SHA
    ae6483d View commit details
  3. Copy the full SHA
    4bfcd65 View commit details

Commits on Feb 6, 2020

  1. Copy the full SHA
    0b7916c View commit details
  2. Copy the full SHA
    b2e0251 View commit details
  3. Copy the full SHA
    94111d0 View commit details
  4. Copy the full SHA
    0fabf50 View commit details
  5. Copy the full SHA
    8f6ebe2 View commit details
  6. Copy the full SHA
    13cd0c7 View commit details
  7. Copy the full SHA
    7926770 View commit details
  8. Copy the full SHA
    adf7305 View commit details

Commits on Feb 10, 2020

  1. Copy the full SHA
    8e97909 View commit details
  2. Copy the full SHA
    4ad7a41 View commit details
  3. Copy the full SHA
    1ab5719 View commit details

Commits on Feb 20, 2020

  1. Copy the full SHA
    1de1cf5 View commit details

Commits on Feb 21, 2020

  1. Copy the full SHA
    303c693 View commit details
  2. Merge remote-tracking branch 'upstream/develop' into feature/typescript

    # Conflicts:
    #	packages/titanium-docgen/generators/typescript_generator.js
    drauggres committed Feb 21, 2020
    Copy the full SHA
    36a0cb6 View commit details
  3. Copy the full SHA
    9566b98 View commit details

Commits on Mar 4, 2020

  1. Copy the full SHA
    7c45a79 View commit details
  2. Copy the full SHA
    fd9a188 View commit details
Showing with 81 additions and 28 deletions.
  1. +24 −18 packages/titanium-docgen/generators/typescript_generator.js
  2. +57 −10 packages/titanium-docgen/index.js
42 changes: 24 additions & 18 deletions packages/titanium-docgen/generators/typescript_generator.js
Original file line number Diff line number Diff line change
@@ -56,6 +56,10 @@ function isConstantsOnlyProxy(typeInfo) {
return false;
}

if (typeInfo.name === 'R') {
return false;
}

const ownMethods = typeInfo.methods.filter(methodDoc => {
if (methodDoc.__hide) {
return false;
@@ -263,7 +267,8 @@ class DocsParser {
'proxy',
'view'
];
return validSubtypes.includes(typeInfo.__subtype) && !forcedInterfaces.includes(typeInfo.name);
return validSubtypes.includes(typeInfo.__subtype) && !forcedInterfaces.includes(typeInfo.name)
&& !(typeInfo.createable === false && isConstantsOnlyProxy(typeInfo));
}

/**
@@ -349,7 +354,7 @@ class GlobalTemplateWriter {
this.output += '// Definitions by: Axway Appcelerator <https://github.com/appcelerator>\n';
this.output += '// Jan Vennemann <https://github.com/janvennemann>\n';
this.output += '// Sergey Volkov <https://github.com/drauggres>\n';
this.output += '// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n';
this.output += '// Definitions: https://github.com/TiStrong/types\n';
this.output += '// TypeScript Version: 3.0\n';
this.output += '\n';
this.output += 'type _Omit<T, K extends keyof any | undefined> = Pick<T, Exclude<keyof T, K>>;\n';
@@ -472,7 +477,7 @@ class GlobalTemplateWriter {
return;
}
const parent = interfaceNode.extends ? 'extends ' + interfaceNode.extends + ' ' : '';
const isTopLevelClass = this instanceof ClassNode && nestingLevel === 0 ? 'declare ' : '';
const isTopLevelClass = interfaceNode 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));
@@ -858,16 +863,6 @@ class MemberNode {
return false;
}

// 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;
}

// 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;
}
@@ -882,14 +877,14 @@ class MemberNode {

this.methods = [];

methods.sort(sortByName).forEach(methodDoc => {
const filterFunc = this.filterMethods.bind(this);

methods.filter(filterFunc).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;
}

if (this.proxyEventMap && isEventMethod) {
const parameters = [ {
name: 'name',
@@ -946,6 +941,11 @@ class MemberNode {
});
}

filterMethods(methodDoc) {
const isEventMethod = eventsMethods.includes(methodDoc.name);
return !(!isEventMethod && methodDoc.__inherits && methodDoc.__inherits !== this.fullyQualifiedName && !this.membersAreStatic);
}

parseEvents(events) {
if (!events || !events.length) {
return;
@@ -1078,10 +1078,16 @@ class NamespaceNode extends MemberNode {
filterProperties(propertyDoc) {
// If we have interface/class for this namespace, then we need here only upper cased constants
let onlyUpperCased = true;
let excluded = propertyDoc.__hide;
if (this.relatedNode) {
onlyUpperCased = propertyDoc.name.toUpperCase() === propertyDoc.name;
}
return onlyUpperCased && super.filterProperties(propertyDoc);
return onlyUpperCased && !excluded && super.filterProperties(propertyDoc);
}

filterMethods(methodDoc) {
let excluded = methodDoc.__hide;
return !excluded && super.filterMethods(methodDoc);
}

addNamespace(namespaceNode) {
67 changes: 57 additions & 10 deletions packages/titanium-docgen/index.js
Original file line number Diff line number Diff line change
@@ -306,14 +306,51 @@ function hideAPIMembers(apis, type) {
return apis;
}

/**
* Return deprecation object if required
* @param {boolean} getOrSet True for getter, False for setter
* @param {Object} api Property object
* @param {string} className Name of the class
* @param {string} deprecate Mark accessors as "deprecated" since (>= 8.0.0)
* @param {string} remove Mark accessors as "removed" since (>= 10.0.0)
* @return {*}
*/
function getDeprecation(getOrSet, api, className, deprecate, remove) {
if (api.deprecated && api.deprecated.removed) {
return api.deprecated;
}
if (deprecate) {
const deprecated = {};
if (api.deprecated) {
Object.keys(api.deprecated).forEach(key => {
// `api.deprecated` contains only primitives, no need for a deep clone
deprecated[key] = api.deprecated[key];
});
}
if (remove && !deprecated.removed) {
deprecated.removed = remove;
}
deprecated.since = deprecate;
if (!deprecated.notes) {
deprecated.notes = getOrSet ? 'Access <' + className + '.' + api.name + '> instead.'
: 'Set the value using <' + className + '.' + api.name + '> instead.';
}
return deprecated;
} else {
return api.deprecated;
}
}

/**
* Generates accessors from the given list of properties
* @param {Array<Object>} apis Array of property objects
* @param {String} className Name of the class
* @param {String} methods Array of defined methods on the API
* @param {Array<Object>} methods Array of defined methods on the API
* @param {string} deprecate Mark accessors as "deprecated" since (>= 8.0.0)
* @param {string} remove Mark accessors as "removed" since (>= 10.0.0)
* @returns {Array<Object>} Array of methods
*/
function generateAccessors(apis, className, methods) {
function generateAccessors(apis, className, methods, deprecate, remove) {
const rv = [];
apis.forEach(function (api) {

@@ -328,7 +365,7 @@ function generateAccessors(apis, className, methods) {
rv.push({
name: getterName,
summary: 'Gets the value of the <' + className + '.' + api.name + '> property.',
deprecated: api.deprecated || { since: '8.0.0', notes: 'Access <' + className + '.' + api.name + '> instead.' },
deprecated: getDeprecation(true, api, className, deprecate, remove),
platforms: api.platforms,
since: api.since,
returns: { type: api.type, __subtype: 'return' },
@@ -344,7 +381,7 @@ function generateAccessors(apis, className, methods) {
rv.push({
name: setterName,
summary: 'Sets the value of the <' + className + '.' + api.name + '> property.',
deprecated: api.deprecated || { since: '8.0.0', notes: 'Set the value using <' + className + '.' + api.name + '> instead.' },
deprecated: getDeprecation(false, api, className, deprecate, remove),
platforms: api.platforms,
since: api.since,
parameters: [ {
@@ -400,9 +437,11 @@ function getSubtype (api) {
/**
* Process API class
* @param {Object} api API object to build (and use as base)
* @param {string} deprecate Mark accessors as "deprecated" since (>= 8.0.0)
* @param {string} remove Mark accessors as "removed" since (>= 10.0.0)
* @return {Object} api
*/
function processAPIs (api) {
function processAPIs (api, deprecate, remove) {
var defaultVersions = nodeappc.util.mix({}, common.DEFAULT_VERSIONS),
inheritedAPIs = {},
matches = [];
@@ -479,7 +518,7 @@ function processAPIs (api) {
api = hideAPIMembers(api, 'properties');
api.properties = processAPIMembers(api.properties, 'properties', api.since, api.__addon);
const methods = api.methods.map(method => method.name);
if (api.__subtype !== 'pseudo' && (accessors = generateAccessors(api.properties, api.name, methods))) {
if (api.__subtype !== 'pseudo' && (accessors = generateAccessors(api.properties, api.name, methods, deprecate, remove))) {
if (assert(api, 'methods')) {
matches = [];
accessors.forEach(function (accessor) {
@@ -920,27 +959,36 @@ addOnDocs.forEach(function (basePath) {
}
});

const { version } = require(pathMod.resolve(basePaths[0], '..', 'package.json'));
let deprecateAccessors = '';
let removeAccessors = '';
if (nodeappc.version.gte(version, '8.0.0')) {
deprecateAccessors = '8.0.0';
}
if (nodeappc.version.gte(version, '10.0.0')) {
removeAccessors = '10.0.0';
}

// Process YAML files
common.log(common.LOG_INFO, 'Processing YAML data...');
processFirst.forEach(function (cls) {
if (!assert(doc, cls)) {
return;
}
processedData[cls] = processAPIs(doc[cls]);
processedData[cls] = processAPIs(doc[cls], deprecateAccessors, removeAccessors);
});
skipList = skipList.concat(processFirst);
for (const key in doc) {
if (~skipList.indexOf(key)) {
continue;
}
processedData[key] = processAPIs(doc[key]);
processedData[key] = processAPIs(doc[key], deprecateAccessors, removeAccessors);
}

formats.forEach(function (format) {
// For changes format, make sure we have a start version and it's less than the end version if defined
if (format === 'changes') {
if (!processedData.__startVersion) {
const { version } = require(pathMod.resolve(basePaths[0], '..', 'package.json'));
processedData.__startVersion = version;
}
if (processedData.__endVersion) {
@@ -957,7 +1005,6 @@ formats.forEach(function (format) {
if (format === 'modulehtml') {
processedData.__modules = modules;
} else if (format === 'typescript') {
const { version } = require(pathMod.resolve(basePaths[0], '..', 'package.json'));
processedData.__version = version;
}
if (searchPlatform) {