Skip to content
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

Not properly generating JSDoc documentation. #5798

Closed
mattd3v opened this issue May 23, 2020 · 5 comments
Closed

Not properly generating JSDoc documentation. #5798

mattd3v opened this issue May 23, 2020 · 5 comments
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@mattd3v
Copy link
Contributor

mattd3v commented May 23, 2020

A few things seem off about the documentation generator.

This example code was run with Deno v1.0.2 on MacOS Catalina:

/**
 * Boolean helper functions.
 */

/** Returns a boolean representing if its argument was true. */
export function isTrue (bool: boolean): boolean {
  return bool || false;
}

/** Returns a boolean representing if its argument was false. */
export function isFalse (bool: boolean): boolean {
  return !isTrue(bool);
}
function isFalse(bool: boolean): boolean
  Returns a boolean representing if its argument was false.

function isTrue(bool: boolean): boolean
  Boolean helper functions.

The documentation text for the isTrue function actually contains the file header comment.

Also, when using export { isTrue, isFalse } the doc command yields no output, as if the exports weren't even there.

I have spent some time now familiarizing myself with the cli/doc source code, and can help out here. However, pointers from @bartlomieju and @lucacasonato would be much appreciated!

@lucacasonato
Copy link
Member

Would be super awesome if you could get that working, but it's probably going to be somewhat challenging because of variable hoisting. But a first pass with no hoisting support would already be great.

Ref #4516

@bartlomieju
Copy link
Member

The documentation text for the isTrue function actually contains the file header comment.

@mattd3v Definitely a bug - we need to add a test case for this situation.

Also, when using export { isTrue, isFalse } the doc command yields no output, as if the exports weren't even there.

Correct, this situation is still not handled.

Here's documentation for AST node for export { isTrue, isFalse }:
https://docs.rs/swc_ecma_ast/0.20.0/swc_ecma_ast/struct.NamedExport.html

Named exports should be parsed and then. based on collected specifiers, proper declarations from module body should be extracted.

@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels May 26, 2020
@mattd3v mattd3v mentioned this issue May 27, 2020
@mattd3v
Copy link
Contributor Author

mattd3v commented May 28, 2020

I'm getting much more comfortable with the cli/doc code, and will implement named exports.

However, @bartlomieju I noticed the CLI automatically calls format_jsdoc with the value true for the truncated parameter. The CLI doesn’t seem capable of calling doc without truncation yet, but I could add a flag. Has there been any discussion on what the default should be?

/**
 * Print a custom greeting
 * by providing a name.
 *
 * @param {string} name
 */
export function greet(name) {
  console.log(`Hello, ${name}`);
}

Running the doc command on the above yields:

$ deno doc greet.js
function greet(name)
  Print a custom greeting by providing a name.

@bartlomieju
Copy link
Member

@mattd3v I'm not sure, I think that was added by @lucacasonato to save some space in terminal (to replicate how go doc works), but there's already been a report that it's surprising behavior (#4755). I guess we could remove it altogether and always show full contents.

@mattd3v
Copy link
Contributor Author

mattd3v commented Jun 1, 2020

@bartlomieju can this be closed, or are there any other changes you know need to be made?

@mattd3v mattd3v closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet
Development

No branches or pull requests

3 participants