Repository navigation
Added description for packages implementation - #65
Conversation
Pete Gonzalez (octogonz)
left a comment
There was a problem hiding this comment.
I added some notes
|
Please test against sp-client before merging your PR |
| } | ||
| try { | ||
| const jsdoc: string = TypeScriptHelpers.getJsDocComments(node, console.log); | ||
| if (jsdoc && jsdoc.trim()) { |
There was a problem hiding this comment.
Delete this COMMENT= code; it was just for testing. Also delete the console.log('**') thing above.
| console.log(`${indent}${kindName}: [${trimmedText}]`); | ||
| for (const childNode of node.getChildren()) { | ||
| PrettyPrinter.dumpTree(childNode, indent + ' '); | ||
| try { |
There was a problem hiding this comment.
Keep this try/catch block though; it was a fix for a legitimate issue. The "expected exception" here is okay, since the function is only used for debugging.
| if (this.apiItem instanceof ApiPackage) { | ||
| if (apiTagCount > 0) { | ||
| const tag: string = '@' + ApiTag[this.apiTag].toLowerCase(); | ||
| this.reportError(`The ${tag} tag is not allowed on the package`); |
There was a problem hiding this comment.
Suggest to clarify The ${tag} tag is not allowed on the package, which is always public
| private static _getOptions(analyzer: Analyzer, rootFileSymbol: ts.Symbol): IApiItemOptions { | ||
| let statement: ts.VariableStatement; | ||
| let foundDescription: ts.Node = undefined; | ||
| for (const statementNode of (rootFileSymbol.declarations[0] as ts.SourceFile).statements) { |
There was a problem hiding this comment.
Clean up the (rootFileSymbol.declarations[0] as ts.SourceFile) expression
| let foundDescription: ts.Node = undefined; | ||
| for (const statementNode of (rootFileSymbol.declarations[0] as ts.SourceFile).statements) { | ||
| if (statementNode.kind === ts.SyntaxKind.VariableStatement) { | ||
| statement = statementNode as ts.VariableStatement; |
There was a problem hiding this comment.
This typecast should be unnecessary. Could take a quick look at why the tagged union isn't working?
https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#tagged-union-types
https://www.typescriptlang.org/docs/handbook/advanced-types.html
There was a problem hiding this comment.
The second link was very useful.
"If we have a value that has a union type, we can only access members that are common to all types in the union."
"If a value has the type A | B, we only know for certain that it has members that both A and B have. In this example, Bird has a member named fly. We can’t be sure whether a variable typed as Bird | Fish has a fly method. If the variable is really a Fish at runtime, then calling pet.fly() will fail."
| statement = statementNode as ts.VariableStatement; | ||
| for (const statementDeclaration of statement.declarationList.declarations) { | ||
| if (statementDeclaration.name.getText() === 'packageDescription') { | ||
| // The following line is useful for debugging |
There was a problem hiding this comment.
Clean up
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
If they omit or misspell packageDescription, could you add a warning to *.api.ts? Something like this:
// (No packageDescription for this package) | "type": "string", | ||
| "enum": [ "package" ] | ||
| }, | ||
| "summary": { |
…ned up comments and type casting
| if (node.kind === ts.SyntaxKind.FromKeyword) { | ||
| console.log('**'); | ||
| } | ||
| try { |
There was a problem hiding this comment.
This code doesn't do anything
Added description for packages implementation
Added description for packages implementation
Uh oh!
There was an error while loading. Please reload this page.