Skip to content

Commit

Permalink
refactor: #160 - Remove DocumentationableNode.getDocumentationComment
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed DocumentationableNode.getDocumentationComment.
  • Loading branch information
dsherret committed Dec 9, 2017
1 parent d29820f commit 54c94b1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
10 changes: 0 additions & 10 deletions docs/details/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ function getName(person: Person) {
}
```

### Get string

Use `getDocumentationComment()` to return all the documentation comments separated by new lines as a string:

```typescript
functionDeclaration.getDocumentationComment(); // returns: string | undefined
```

This will return `undefined` if no documentation comment exists.

### Get all documentation nodes

Get all the documentation nodes by using `getDocNodes()`:
Expand Down
14 changes: 0 additions & 14 deletions src/compiler/base/DocumentationableNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import {JSDoc} from "./../doc/JSDoc";
export type DocumentationableNodeExtensionType = Node<any>;

export interface DocumentationableNode {
/**
* Gets the documentation comment text or undefined if none exists.
* This will return multiple documentation comments separated by newlines.
*/
getDocumentationComment(): string | undefined;
/**
* Gets the documentation nodes.
*/
Expand Down Expand Up @@ -45,15 +40,6 @@ export interface DocumentationableNode {

export function DocumentationableNode<T extends Constructor<DocumentationableNodeExtensionType>>(Base: T): Constructor<DocumentationableNode> & T {
return class extends Base implements DocumentationableNode {
getDocumentationComment() {
const docCommentNodes = this.getDocNodes();
if (docCommentNodes.length === 0)
return undefined;

const texts = docCommentNodes.map(n => (n.getComment() || "").trim());
return texts.filter(t => t.length > 0).join(this.global.manipulationSettings.getNewLineKind());
}

getDocNodes(): JSDoc[] {
const nodes = (this.compilerNode as any).jsDoc as ts.JSDoc[] || [];
return nodes.map(n => this.global.compilerFactory.getNodeFromCompilerNode(n, this.sourceFile) as JSDoc);
Expand Down
20 changes: 0 additions & 20 deletions src/tests/compiler/base/documentationableNodeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ describe(nameof(DocumentationableNode), () => {
const multiDocedStatement = statements[1];
const nonDocedStatement = statements[2];

describe(nameof<DocumentationableNode>(n => n.getDocumentationComment), () => {
describe("documentationed node", () => {
it("should get the comment", () => {
expect(docedStatement.getDocumentationComment()).to.equal("Text");
});
});

describe("multi-documentationed node", () => {
it("should get the comment separated by newlines", () => {
expect(multiDocedStatement.getDocumentationComment()).to.equal("First\nSecond");
});
});

describe("not documentationed node", () => {
it("should return undefined", () => {
expect(nonDocedStatement.getDocumentationComment()).to.be.undefined;
});
});
});

describe(nameof<DocumentationableNode>(n => n.getDocNodes), () => {
describe("documentationed node", () => {
const nodes = docedStatement.getDocNodes();
Expand Down

0 comments on commit 54c94b1

Please sign in to comment.