ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

[QUEST] Reformatting Ember API docs for Typescript

Open ttbach opened this issue 3 years ago • 2 comments

Summary

Currently, there is an ongoing initiative to add Typescript support to Ember API documentation. More specifically, that means adding the ability for API docs to be generated from typescript instead of jsdocs. In order to do that, we will need to modify the API code, such that it will be well formed to pass through a documentation generator for TS projects (typedoc). That means for modules that import Mixins, we need to move the jsdocs comments close to the functions that are defined inside the interface. For more details, see the Example section below.

Issues

File Package Count Owner Status
index.ts @ember/array 3  @slijack-in https://github.com/emberjs/ember.js/pull/20189
index.ts @ember/controller 1  @jalexakos https://github.com/emberjs/ember.js/pull/20202
index.ts @ember/enumerable 1  @jalexakos DONE
mutable.ts @ember/enumerable 1  @52052100 DONE
evented.ts @ember/object 1  @pablonajera https://github.com/emberjs/ember.js/pull/20189#pullrequestreview-1104598985
mixin.ts @ember/object 4  @TechieQian DONE
observable @ember/object 1  @52052100 https://github.com/emberjs/ember.js/pull/20191
promise-proxy-mixin.ts @ember/object 1 @TechieQian https://github.com/emberjs/ember.js/pull/20192

Example

Let's take a look at objectsAt in array.ts. Currently, the jsdocs are above the function definition of objectsAt

const EmberArray = Mixin.create(Enumerable, {
  ...
  /**
    This returns the objects at the specified indexes, using `objectAt`.
    ```javascript
    let arr = ['a', 'b', 'c', 'd'];
    arr.objectsAt([0, 1, 2]);  // ['a', 'b', 'c']
    arr.objectsAt([2, 3, 4]);  // ['c', 'd', undefined]
    ```
    @method objectsAt
    @param {Array} indexes An array of indexes of items to return.
    @return {Array}
    @public
   */
  objectsAt(indexes: number[]) {
    return indexes.map((idx) => objectAt(this, idx));
  },
  ...
});

We want to move these comments to the objectsAt declared inside the interface like so:

interface EmberArray<T> extends Enumerable {
  ...
  /**
    This returns the objects at the specified indexes, using `objectAt`.
    ```javascript
    let arr = ['a', 'b', 'c', 'd'];
    arr.objectsAt([0, 1, 2]);  // ['a', 'b', 'c']
    arr.objectsAt([2, 3, 4]);  // ['c', 'd', undefined]
    ```
    @method objectsAt
    @param {Array} indexes An array of indexes of items to return.
    @return {Array}
    @public
   */
  objectsAt(indexes: number[]): Array<T | undefined>;
  ...
}

ttbach avatar Aug 29 '22 23:08 ttbach

File Package Count Owner
index.ts @ember/array 3  
index.ts @ember/controller 1  
index.ts @ember/enumerable 1  
mutable.ts @ember/enumerable 1  
core.ts @ember/object 3  
evented.ts @ember/object 1  
mixin.ts @ember/object 4  
observable @ember/object 1  
promise-proxy-mixin.ts @ember/object 1  

TechieQian avatar Sep 08 '22 01:09 TechieQian

Signing up for @ember/array

slijack-in avatar Sep 08 '22 02:09 slijack-in