New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: extract out common types #11391
Conversation
cc @drauggres You might be interested in these changes |
Tests:
Dependencies with modified semantic versioning:
|
7f96ae8
to
f906edd
Compare
Relates to #11386 @janvennemann Perhaps you'd be best for review? I attempted to try and basically "refactor" our docs to use some commonly defined types for many of the "simple object which has a few properties" arguments/callbacks. The goal was to clean the docs, try and re-use common types when defining them, and hopefully to improve TypeScript definitions and IDE content assist indirectly. |
6a6ef46
to
290d45b
Compare
type: zoomScaleOption | ||
- name: options | ||
summary: A JS object with an `animated` property which determines whether the scrollable region reposition should be animated | ||
type: AnimatedOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zoomScaleOption
was iOS-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true, but this method is iOS-only so the method and any arguments are therefore iOS-only.
summary: Determines whether the scrollable region reposition should be animated | ||
type: contentOffsetOption | ||
summary: A JS object with an `animated` property which determines whether the scrollable region reposition should be animated | ||
type: AnimatedOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentOffsetOption
was iOS-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true, but this method is iOS-only so the method and any arguments are therefore iOS-only.
@@ -1147,7 +1149,7 @@ properties: | |||
description: | | |||
This was separated from the <Titanium.UI.Window.androidback> event. You need to define this | |||
callback if you explicitly want to override the back button behavior. | |||
type: Callback<Object> | |||
type: Callback<void> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct way to define callback with no arguments? I can't find any other Callback<void>
(except one in validate.js
from titanium-docgen).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I believe it is in our doc format. Callback
is synonymous with Function
. As to the void
arg, well that is seen as ok in the validation. Otherwise, I'm not sure how to define that the function takes no arguments. I think the generators are ok with with void
arg
summary: Includes options how the menu popup should be hidden. | ||
type: MenuPopupHideParams | ||
summary: Includes options how the menu popup should be hidden. Introduced in SDK 5.2.0 | ||
type: AnimatedOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default was {animated: true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I struggled with how to handle the cases where the default animated
value is true
vs false
. Do we just mention it in the summary? Do I define a new sub-type of AnimatedOptions
that just overrides the property's default value to be true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do some follow-up: These special "types" I've been extracting are really a better match as TypeScript interfaces, not classes. Because there's no actual way to instantiate an AnimatedOptions
type - no such thing exists. It's more about the shape of a generic JS object we expect to be passed in to the methods. As such, the conversion to TypeScript would drop any "default" values on objects like this. It's more about documenting the property names, whether they're optional/required, and if they're "readonly". So trying to set the default value on the type may actually be moot - and I may need to just be thorough in mentioning the assumed defaults on all the methods that accept it. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thought of another possible way to document this - set the default value on the method argument to the raw JS object that it "assumes". Old docs already do this for things like Point (i.e. { x: 0, y: 0 }
) We've been pretty loosey-goosey with how we handle default
though. Not sure if we'd need more rules around it or just assume that the string value is the raw JS code/value that is assumed to be default. (How would we validate that, since I know we do have cases where we have sentences there?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least we should keep this information in summary
or description
(same for iOS-only properties).
@@ -39,14 +39,14 @@ methods: | |||
parameters: | |||
- name: options | |||
summary: Display properties to use when hiding the popover. | |||
type: PopoverParams | |||
type: AnimatedOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default was {animated: true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
|
||
- name: show | ||
summary: Displays the popover. | ||
parameters: | ||
- name: params | ||
summary: Display properties to use when displaying the popover. | ||
type: PopoverParams | ||
type: ShowPopoverParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default was {animated: true}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only two minor notes, the rest looks good.
PS: Man this looks like some tedious work, awesome job!
optional: true | ||
|
||
- name: UIApplicationOpenURLOptionsAnnotationKey | ||
type: Array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here must be a type of items stored in the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... I couldn't find what the heck goes in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: with type: Array
current version of the "typescript" generator will produce incorrect output.
JIRA
https://jira.appcelerator.org/browse/TIMOB-27688
Description:
Dictionary
/Object
typesSize
type:width
andheight
Dimension
type from View's yml file, have it extendSize
and addx
andy
propertiesTi.Blob.#imagesAsCropped()
now refers toDimension
rather than a custom type that had the same properties.Ti.Media CameraMediaItemType
now refers toDimension
forcropRect
andSize
forpreviewRect
rather the defining custom types with same properties.Padding
type fromViewPadding
. Attempted to clean up any special types that had the same concept (basically any padding/inset properties/types) to refer to it.TabIconInsets
, had it extendPadding
and noted right/bottom are excluded.TextFieldPadding
, had it extendPadding
and noted top/bottom are Android-only.Ti.DB.ResultSet
#field()
and#fieldByName()
returns to be a single entry with type as an array of possible return types.