Skip to content

Flow docs #543

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

Closed
montogeek opened this issue Sep 13, 2016 · 21 comments
Closed

Flow docs #543

montogeek opened this issue Sep 13, 2016 · 21 comments

Comments

@montogeek
Copy link
Contributor

Hi!

This is the HTML generate by the following code:
screen shot 2016-09-12 at 20 30 24

// @flow
type FlightParams = {
  airline: string;
};

type Flight = {
  display: string
}

const Fligths = {
  /**
   * Test
   */
  getFlights: (data: FlightParams): Promise<Flight[]> => {
    return client.get(GET_FLIGHTS_ENDPOINT, { query: data })
      .then((response): Array<Flight> => {
        return response.flights.map((flight): Flight => {
          return {
            display: flight.label
          }
        });
      })
  }
}

export default Fligths;

Shouldn't it create docs for the params and return values?
I am using documentation 4.0.0-beta9

Thanks!

@arv
Copy link
Contributor

arv commented Sep 13, 2016

Try using --document-exported.

There is still more work to do when it comes to outputting the types nicely.

@montogeek
Copy link
Contributor Author

Same output

@montogeek
Copy link
Contributor Author

Oh, is on beta10

@arv
Copy link
Contributor

arv commented Sep 13, 2016

Hmmm... I guess the changes are not in the latest beta release. Try using master instead.

@montogeek
Copy link
Contributor Author

I am a beta behind, updating...

@montogeek
Copy link
Contributor Author

Still, same output

@montogeek
Copy link
Contributor Author

When using master, all static methods were deleted from the output

@arv
Copy link
Contributor

arv commented Sep 13, 2016

I have to look at it. --document-exported is a new feature and it is possible/likely I forgot some cases.

@arv
Copy link
Contributor

arv commented Sep 13, 2016

I figured it out. I'm currently not handling var x = function () {} or var x = { ... } in the --document-exported case. I'll get a PR up but it will depend on some open PRs because they all touch the same area.

@montogeek
Copy link
Contributor Author

No worries!
Thanks!!

arv added a commit to arv/documentation that referenced this issue Sep 13, 2016
This improves detection of cases where we have:

```js
export const f = function () {};
export const o = { ... };
```

and similarly indirection using default/named.

```js
const f = function () {};
export {f};
```

Fixes documentationjs#543
@tmcw tmcw closed this as completed in #544 Sep 19, 2016
tmcw pushed a commit that referenced this issue Sep 19, 2016
This improves detection of cases where we have:

```js
export const f = function () {};
export const o = { ... };
```

and similarly indirection using default/named.

```js
const f = function () {};
export {f};
```

Fixes #543
@montogeek
Copy link
Contributor Author

montogeek commented Nov 10, 2016

@arv I am getting the same behaviour using beta12.

My project is composed by modules that exports an object with methods:
foo.js

// @flow
const Foo = {
 /**
  * Desc
  */
  method: (params: <T>): Promise<T> => {};
}
export default Foo;
import foo from './path/foo.js'

export default {
 foo
}

I get a empty HTML output, without params and return values using --document-exported.
I get a nice output with all methods grouped by its module without using --document-exported.

@tmcw tmcw reopened this Nov 10, 2016
@arv
Copy link
Contributor

arv commented Dec 2, 2016

I finally got to look at this...

The problem is the export default ___ only handles declarations and identifier expressions. https://github.com/documentationjs/documentation/blob/master/lib/extractors/exported.js#L69-L77

If you write:

export default 42;

as:

const temp = 42;
export default temp;

...we do generate documentation for it.

arv added a commit to arv/documentation that referenced this issue Dec 2, 2016
With `--document-exported` we used to only support

  export default Declaration

and

  export default IdentifierExpression

With this change we generate a comment for all default exports.

Fixes documentationjs#543
arv added a commit to arv/documentation that referenced this issue Dec 2, 2016
With `--document-exported` we used to only support

```js
export default Declaration
```

and

```js
export default IdentifierExpression
```

With this change we generate a comment for all default exports.

Fixes documentationjs#543
arv added a commit to arv/documentation that referenced this issue Dec 2, 2016
With `--document-exported` we used to only support

```js
export default Declaration
```

and

```js
export default IdentifierExpression
```

With this change we generate a comment for all default exports.

Fixes documentationjs#543
@arv arv closed this as completed in #623 Dec 3, 2016
arv added a commit that referenced this issue Dec 3, 2016
With `--document-exported` we used to only support

```js
export default Declaration
```

and

```js
export default IdentifierExpression
```

With this change we generate a comment for all default exports.

Fixes #543
@arv
Copy link
Contributor

arv commented Dec 3, 2016

@montogeek Can you try with master to see if this works sufficiently for you? Thanks.

@montogeek
Copy link
Contributor Author

@arv With master, I get the same results as the original code: #543 (comment)

@montogeek
Copy link
Contributor Author

Thanks for working on it!

I can keep writing JSDocs manually :)

@arv
Copy link
Contributor

arv commented Dec 19, 2016

@montogeek I'm not sure where we are with this? Can you provide an example input and an expected outut? #623 did add tests for what I thought was missing. Thanks.

@arv arv reopened this Dec 19, 2016
@carocad
Copy link

carocad commented Apr 13, 2017

@arv I think I am having the same problem as @montogeek. Here is a bit more context:

/**
 * This function adds one to its input.
 */
var foo = {
  /** bar member */
  bar: function addOne(input: number): number {
    return input + 1;
  }
}

the previous input with renders as:
screen shot 2017-04-13 at 10 37 10

On the other hand, if I write it like this:

/**
 * This function adds one to its input.
 */
var foo = {}

/** bar member */
foo.bar = function addOne(input: number): number {
  return input + 1;
}

then the output is:
screen shot 2017-04-13 at 10 38 49

Both cases are definitely equivalent but documentationjs seems to not support flow type annotations on static methods.

I hope this helps :)

@arv
Copy link
Contributor

arv commented Apr 23, 2017

@carocad I think this is fixed in 4.0.0-rc-0. I'm getting identical results for those two cases:

screen shot 2017-04-23 at 4 29 30 pm

@arv
Copy link
Contributor

arv commented Apr 23, 2017

Ignore the new, it is because I named the function expression AAAand BBB respectively.

@carocad
Copy link

carocad commented Apr 24, 2017

@arv I can confirm that with the version 4.0.0-rc.0 the types are outputted to the documentation as well :)

PS: You had a typo in the version 4.0.0-rc-0 it should be 4.0.0-rc.0 just in case somebody else wants to test it ;)

@arv
Copy link
Contributor

arv commented Apr 24, 2017

Closing. Feel free to open a new issue if you see something else.

@arv arv closed this as completed Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants