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

Remove tsdocs from documented const initialisers #1224

Closed
1 task done
knoan opened this issue Mar 5, 2020 · 2 comments
Closed
1 task done

Remove tsdocs from documented const initialisers #1224

knoan opened this issue Mar 5, 2020 · 2 comments
Labels
bug Functionality does not match expectation

Comments

@knoan
Copy link

knoan commented Mar 5, 2020

Steps to reproduce the bug

Generate docs for the following snippet:

export const Work={

	/**
	 * Lorem ipsum
	 */
	a: "one" as string,

	/**
	 * Sit amet
	 */
	b: 2 as number

} as const;

tsconfig.json

{
	"typedocOptions": {
		"mode": "modules",
		"theme": "minimal",
		"out": "docs"
	}
}

Expected Behavior

tsdocs not included in documented const initialiser, i.e.

Work: { a: string; b: number } = { a: "one", b: 2 } as const

Actual Behavior

tsdocs included verbatim in documented const initialiser, i.e.

Screenshot 2020-03-05 at 14 51 02

Environment

  • Typedoc version: 0.16.11
  • Node.js version: v11.10.0
  • OS: macOS 10.15.3
@knoan knoan added the bug Functionality does not match expectation label Mar 5, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 15, 2020

This happens here:

export function convertExpression(expression: ts.Expression): string {
switch (expression.kind) {
case ts.SyntaxKind.StringLiteral:
return '"' + (<ts.LiteralExpression> expression).text + '"';
case ts.SyntaxKind.NumericLiteral:
return (<ts.LiteralExpression> expression).text;
case ts.SyntaxKind.TrueKeyword:
return 'true';
case ts.SyntaxKind.FalseKeyword:
return 'false';
case ts.SyntaxKind.NullKeyword:
return 'null';
default:
return expression.getText(expression.getSourceFile());
}
}

I think it should be possible to ask TS for a printer configured to remove comments and use that instead of getText. PR welcome if you'd like to give it a shot. I probably won't get to it for a while.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 29, 2020

0.20.1 renders this as:

image

In investigating other issues with the initializers, I decided that showing complex values was mostly not useful, so now only a few detected "simple" expressions are shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants