Skip to content

Commit 37f0c55

Browse files
authored
Merge pull request #260 from tidev/develop
2 parents 0ed8a90 + 69ae6d9 commit 37f0c55

File tree

15 files changed

+73
-51
lines changed

15 files changed

+73
-51
lines changed

.github/workflows/cla.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ jobs:
88
name: Verify contributor
99

1010
steps:
11-
- uses: tidev/tidev-cla-action@v1
11+
- uses: tidev/tidev-cla-action@v2
1212
with:
1313
repo-token: ${{ secrets.GITHUB_TOKEN }}

packages/titanium-docgen/generators/jsduck_generator.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,17 @@ function exportEditUrl(api) {
328328
const file = api.__file;
329329
const blackList = [ 'appcelerator.https', 'ti.geofence' ]; // Don't include Edit button for these modules
330330
let rv = '';
331-
let basePath = 'https://github.com/appcelerator/titanium_mobile/edit/master/';
331+
let basePath = 'https://github.com/tidev/titanium-sdk/edit/master/';
332332

333333
// Determine edit URL by file's folder location
334-
if (file.indexOf('titanium_mobile/apidoc') !== -1) {
334+
if (file.indexOf('titanium-sdk/apidoc') !== -1) {
335335
const startIndex = file.indexOf('apidoc/');
336336
const path = file.substr(startIndex);
337337
rv = basePath + path;
338-
} else if (file.indexOf('titanium_modules') !== -1 || file.indexOf('appc_modules') !== -1) {
338+
} else {
339339
// URL template with placeholders for module name and path.
340-
const urlTemplate = 'https://github.com/appcelerator-modules/%MODULE_NAME%/edit/master/%MODULE_PATH%';
341-
const re = /titanium_modules|appc_modules\/(.+)\/apidoc/;
340+
const urlTemplate = 'https://github.com/tidev/%MODULE_NAME%/edit/master/%MODULE_PATH%';
341+
const re = /tidev\/(.+)\/apidoc/;
342342
const match = file.match(re);
343343
let modulename;
344344
if (match) {
@@ -358,15 +358,6 @@ function exportEditUrl(api) {
358358
rv = urlTemplate.replace(/%\w+%/g, function (all) {
359359
return urlReplacements[all] || all;
360360
});
361-
} else if (file.indexOf('titanium_mobile_tizen/modules/tizen/apidoc') !== -1) {
362-
const index = file.indexOf('modules/tizen/apidoc/');
363-
basePath = 'https://github.com/appcelerator/titanium_mobile_tizen/edit/master/';
364-
if (index !== -1) {
365-
rv = basePath + file.substr(index);
366-
} else {
367-
common.log(common.LOG_WARN, 'Error creating edit URL for:', file, '. Couldn\'t find apidoc/ folder.');
368-
return rv;
369-
}
370361
}
371362

372363
return rv;

packages/titanium-docgen/generators/typescript_generator.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ const skipApis = [
2121
// List of modules that need to be generated as an interface instead of a namespace.
2222
const forcedInterfaces = [
2323
'Titanium.Android.R',
24-
'Titanium.App.iOS.UserDefaults'
24+
'Titanium.App.iOS.UserDefaults',
25+
'Titanium.Media.Item',
26+
'Titanium.Calendar.Attendee',
27+
'Titanium.Calendar.Reminder',
28+
'Titanium.Calendar.RecurrenceRule',
29+
'Titanium.Platform.DisplayCaps',
30+
'Titanium.XML.DocumentType'
2531
];
2632

2733
const eventsMethods = [
@@ -169,7 +175,9 @@ class DocsParser {
169175
// skip bundled documentation for modules and Node.js shims
170176
return;
171177
}
172-
const namespaceParts = typeInfo.name.split('.');
178+
// Handle generic types by extracting the base type name before the first '<'
179+
const typeName = typeInfo.name.split('<')[0];
180+
const namespaceParts = typeName.split('.');
173181
namespaceParts.pop();
174182
if (skipApis.includes(typeInfo.name)) {
175183
return;
@@ -357,7 +365,6 @@ class GlobalTemplateWriter {
357365
this.output += '// Project: https://github.com/appcelerator/titanium_mobile\n';
358366
this.output += '// Definitions by: Axway Appcelerator <https://github.com/appcelerator>\n';
359367
this.output += '// Jan Vennemann <https://github.com/janvennemann>\n';
360-
this.output += '// Sergey Volkov <https://github.com/drauggres>\n';
361368
this.output += '// Mathias Lorenzen <https://github.com/ffMathy>\n';
362369
this.output += '// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n';
363370
this.output += '// TypeScript Version: 3.0\n';
@@ -617,7 +624,17 @@ class GlobalTemplateWriter {
617624

618625
if (Array.isArray(docType)) {
619626
const normalizedTypes = docType.map(typeName => this.normalizeType(typeName));
620-
return normalizedTypes.includes('any') ? 'any' : normalizedTypes.join(' | ');
627+
if (normalizedTypes.includes('any')) {
628+
return 'any';
629+
}
630+
// Parenthesize function types in unions to avoid TypeScript syntax errors
631+
const parenthesizedTypes = normalizedTypes.map(type => {
632+
if (type.includes(') => ')) {
633+
return `(${type})`;
634+
}
635+
return type;
636+
});
637+
return parenthesizedTypes.join(' | ');
621638
}
622639

623640
const lessThanIndex = docType.indexOf('<');
@@ -644,6 +661,9 @@ class GlobalTemplateWriter {
644661
}
645662
} else if (baseType === 'Dictionary') {
646663
return `Dictionary<${subType}>`;
664+
} else if (baseType === 'Promise') {
665+
// Use standard Promise<T> generic syntax
666+
return `Promise<${subTypes.join(', ')}>`;
647667
}
648668
}
649669

packages/titanium-docgen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "titanium-docgen",
3-
"version": "4.10.3",
3+
"version": "4.10.4",
44
"description": "Generates Titanium API documentation in different formats",
55
"main": "index.js",
66
"scripts": {

packages/titanium-docgen/validate.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ function validateDataType(type, fullTypeContext) {
434434
// Should it have been written as a complex type?
435435
if (common.COMPLEX_TYPES.has(type)) {
436436
const argCount = common.COMPLEX_TYPES.get(type); // may be 0 if Function/Callback
437-
// Enforce as ERROR if Promise/Set/Map doesn't have exact generic type count
438-
const severity = [ 'Map', 'Set', 'Promise' ].includes(type) ? ERROR : WARNING;
437+
// Skip validation for Promise to allow Promise without generics (Promise<T> not supported by build system)
438+
if (type === 'Promise') {
439+
return errors;
440+
}
441+
// Enforce as ERROR if Set/Map doesn't have exact generic type count
442+
const severity = [ 'Map', 'Set' ].includes(type) ? ERROR : WARNING;
439443
errors.push(new Problem(`${type} ${severity === ERROR ? 'must' : 'should'} have ${argCount || 'any number of'} generic type(s) specified, but had 0: ${fullTypeContext || type}`, severity));
440444
} else if (type === 'Object') {
441445
// Warn about generic Object types (Dictionary is handled above as a complex type)

packages/vuepress/vuepress-plugin-apidocs/components/ConstantList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</h2>
66

77
<div v-for="(constant, index) in constants" :key="constant.name">
8-
<div class="member-header">
9-
<h4 :id="constant.name.toLowerCase()">
8+
<div class="member-header" :id="`${constant.name.toLowerCase()}`">
9+
<h4 :id="`constants_${constant.name.toLowerCase()}`">
1010
<a :href="`#${constant.name.toLowerCase()}`" class="header-anchor">#</a> {{constant.name}} <Badge v-if="constant.deprecated" text="DEPRECATED" type="warn"/>
1111
</h4>
1212
<AvailabilityInfo :platforms="constant.platforms"/>

packages/vuepress/vuepress-plugin-apidocs/components/EventList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</h2>
66

77
<div v-for="(event, index) in events" :key="event.name">
8-
<div class="member-header">
9-
<h3 :id="event.name.toLowerCase()">
8+
<div class="member-header" :id="`${event.name.toLowerCase()}`">
9+
<h3 :id="`events_${event.name.toLowerCase()}`">
1010
<a :href="`#${event.name.toLowerCase()}`" class="header-anchor">#</a> {{event.name}} <Badge v-if="event.deprecated" text="DEPRECATED" type="warn"/>
1111
</h3>
1212
<AvailabilityInfo :platforms="event.platforms"/>

packages/vuepress/vuepress-plugin-apidocs/components/MethodList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</h2>
66

77
<div v-for="(method, index) in methods" :key="method.name">
8-
<div class="member-header">
9-
<h3 :id="method.name.toLowerCase()">
8+
<div class="member-header" :id="`${method.name.toLowerCase()}`">
9+
<h3 :id="`methods_${method.name.toLowerCase()}`">
1010
<a :href="`#${method.name.toLowerCase()}`" class="header-anchor">#</a> {{method.name}} <Badge v-if="method.deprecated" text="DEPRECATED" type="warn"/>
1111
</h3>
1212
<AvailabilityInfo :platforms="method.platforms"/>

packages/vuepress/vuepress-plugin-apidocs/components/PropertyList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</h2>
66

77
<div v-for="(property, index) in properties" :key="property.name">
8-
<div class="member-header">
9-
<h3 :id="property.name.toLowerCase()">
8+
<div class="member-header" :id="`${property.name.toLowerCase()}`">
9+
<h3 :id="`properties_${property.name.toLowerCase()}`">
1010
<a :href="`#${property.name.toLowerCase()}`" class="header-anchor">#</a> {{property.name}} <Badge v-if="property.permission === 'read-only'" text="READONLY" type="light"/><Badge v-if="property.availability === 'creation'" text="CREATION ONLY" type="info"/><Badge v-if="property.deprecated" text="DEPRECATED" type="warn"/>
1111
</h3>
1212
<AvailabilityInfo :platforms="property.platforms"/>

packages/vuepress/vuepress-plugin-apidocs/lib/metadata/processor.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class MetadataProcessor {
5858

5959
filterInheritedMembers (metadata) {
6060
const filterInherited = member => {
61-
if (member.inherits && member.inherits !== metadata.name) {
62-
return false
63-
}
61+
// if (member.inherits && member.inherits !== metadata.name) {
62+
// return false
63+
// }
6464

6565
return true
6666
}
@@ -108,7 +108,7 @@ class MetadataProcessor {
108108
headers.push({
109109
level: 3,
110110
title: memberMetadata.name,
111-
slug: memberMetadata.name.toLowerCase()
111+
slug: memberType + "_" + memberMetadata.name.toLowerCase()
112112
})
113113
})
114114
if (headers.length) {
@@ -117,9 +117,7 @@ class MetadataProcessor {
117117
title: memberType.charAt(0).toUpperCase() + memberType.slice(1),
118118
slug: memberType
119119
})
120-
if (memberType !== 'constants') {
121-
this.additionalHeaders = this.additionalHeaders.concat(headers)
122-
}
120+
this.additionalHeaders = this.additionalHeaders.concat(headers)
123121
}
124122
}
125123

0 commit comments

Comments
 (0)