Skip to content

Commit

Permalink
fix: Remove sources from hidden signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jan 14, 2020
1 parent 1c89283 commit 411a900
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
17 changes: 11 additions & 6 deletions src/lib/converter/plugins/CommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Component, ConverterComponent } from '../components';
import { parseComment, getRawComment } from '../factories/comment';
import { Converter } from '../converter';
import { Context } from '../context';
import { partition, uniq } from 'lodash';
import { SourceReference } from '../../models';

/**
* Structure used by [[ContainerCommentHandler]] to store discovered module comments.
Expand Down Expand Up @@ -226,12 +228,15 @@ export class CommentPlugin extends ConverterComponent {
hidden.forEach(reflection => project.removeReflection(reflection, true));

// remove functions with empty signatures after their signatures have been removed
const hiddenMethods = hidden.map(reflection => reflection.parent!)
.filter(method =>
method.kindOf(ReflectionKind.FunctionOrMethod)
&& method instanceof DeclarationReflection
&& method.signatures?.length === 0);
hiddenMethods.forEach(reflection => project.removeReflection(reflection, true));
const [ allRemoved, someRemoved ] = partition(
hidden.map(reflection => reflection.parent!)
.filter(method => method.kindOf(ReflectionKind.FunctionOrMethod)) as DeclarationReflection[],
method => method.signatures?.length === 0
);
allRemoved.forEach(reflection => project.removeReflection(reflection, true));
someRemoved.forEach(reflection => {
reflection.sources = uniq(reflection.signatures!.reduce<SourceReference[]>((c, s) => c.concat(s.sources || []), []));
});
}

/**
Expand Down
12 changes: 1 addition & 11 deletions src/test/converter/comment/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,10 @@
}
],
"sources": [
{
"fileName": "comment.ts",
"line": 70,
"character": 13
},
{
"fileName": "comment.ts",
"line": 74,
"character": 13
},
{
"fileName": "comment.ts",
"line": 75,
"character": 13
}
]
}
Expand Down Expand Up @@ -339,4 +329,4 @@
]
}
]
}
}

0 comments on commit 411a900

Please sign in to comment.