feat(language-service): Show documentation on hover (#34506)

This commit adds dpcumentation to the hover tooltip.

PR closes https://github.com/angular/vscode-ng-language-service/issues/321

PR Close #34506
This commit is contained in:
Keen Yee Liau
2019-12-19 18:33:26 -08:00
committed by Alex Rickabaugh
parent 284559614e
commit 166009584f
8 changed files with 70 additions and 4 deletions

View File

@ -205,6 +205,24 @@ describe('hover', () => {
});
expect(toText(displayParts)).toBe('(method) $any: $any');
});
it('should provide documentation for a property', () => {
mockHost.override(TEST_TEMPLATE, `<div>{{~{cursor}title}}</div>`);
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
const quickInfo = ngLS.getHoverAt(TEST_TEMPLATE, marker.start);
expect(quickInfo).toBeDefined();
const documentation = toText(quickInfo !.documentation);
expect(documentation).toBe('This is the title of the `TemplateReference` Component.');
});
it('should provide documentation for a selector', () => {
mockHost.override(TEST_TEMPLATE, `<~{cursor}test-comp></test-comp>`);
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
const quickInfo = ngLS.getHoverAt(TEST_TEMPLATE, marker.start);
expect(quickInfo).toBeDefined();
const documentation = toText(quickInfo !.documentation);
expect(documentation).toBe('This Component provides the `test-comp` selector.');
});
});
function toText(displayParts?: ts.SymbolDisplayPart[]): string {

View File

@ -132,6 +132,9 @@ export class AsyncForUsingComponent {
export class References {
}
/**
* This Component provides the `test-comp` selector.
*/
/*BeginTestComponent*/ @Component({
selector: 'test-comp',
template: '<div>Testing: {{name}}</div>',
@ -145,6 +148,9 @@ export class TestComponent {
templateUrl: 'test.ng',
})
export class TemplateReference {
/**
* This is the title of the `TemplateReference` Component.
*/
title = 'Some title';
hero: Hero = {id: 1, name: 'Windstorm'};
heroes: Hero[] = [this.hero];