Skip to content

feat: Improve hover text for common kinds of symbols #94

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

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snapshots/output/multi-project/packages/a/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function a(): string {
// ^ definition @example/a 1.0.0 src/`index.ts`/a().
// documentation ```ts\n() => string\n```
// documentation ```ts\nfunction a(): string\n```
return ''
}

2 changes: 1 addition & 1 deletion snapshots/output/multi-project/packages/b/src/b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

export function b() {
// ^ definition @example/b 1.0.0 src/`b.ts`/b().
// documentation ```ts\n() => string\n```
// documentation ```ts\nfunction b(): string\n```
return a()
// ^ reference @example/a 1.0.0 src/`index.ts`/a().
}
Expand Down
36 changes: 18 additions & 18 deletions snapshots/output/pure-js/src/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function fib(n) {
// ^^^ definition pure-js 1.0.0 src/`main.js`/fib().
// documentation ```ts\n(n: any) => any\n```
// documentation ```ts\nfunction fib(n: any): any\n```
// ^ definition pure-js 1.0.0 src/`main.js`/fib().(n)
// documentation ```ts\nany\n```
// documentation ```ts\n(parameter) n: any\n```
if (n <= 1) {
// ^ reference pure-js 1.0.0 src/`main.js`/fib().(n)
return 0
Expand All @@ -16,9 +16,9 @@

function print_fib(a) {
// ^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/print_fib().
// documentation ```ts\n(a: any) => void\n```
// documentation ```ts\nfunction print_fib(a: any): void\n```
// ^ definition pure-js 1.0.0 src/`main.js`/print_fib().(a)
// documentation ```ts\nany\n```
// documentation ```ts\n(parameter) a: any\n```
console.log(fib(a))
// ^^^^^^^ reference typescript 4.6.2 lib/`lib.dom.d.ts`/console.
// ^^^^^^^ reference @types/node 17.0.14 `globals.d.ts`/console.
Expand All @@ -32,64 +32,64 @@

var y = 'Hello'
// ^ definition pure-js 1.0.0 src/`main.js`/y.
// documentation ```ts\nstring\n```
// documentation ```ts\nvar y: string\n```
function capture() {
// ^^^^^^^ definition pure-js 1.0.0 src/`main.js`/capture().
// documentation ```ts\n() => string\n```
// documentation ```ts\nfunction capture(): string\n```
return y
// ^ reference pure-js 1.0.0 src/`main.js`/y.
}
const capture_lambda = () => {
// ^^^^^^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/capture_lambda.
// documentation ```ts\n() => string\n```
// documentation ```ts\nvar capture_lambda: () => string\n```
return y
// ^ reference pure-js 1.0.0 src/`main.js`/y.
}

for (var i = 0; i <= 10; i++) {}
// ^ definition local 2
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar i: number\n```
// ^ reference local 2
// ^ reference local 2

for (const x of [1, 2, 3]) {
// ^ definition local 5
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar x: number\n```
}

var a = 0
// ^ definition pure-js 1.0.0 src/`main.js`/a.
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar a: number\n```
var a = 1
// ^ definition pure-js 1.0.0 src/`main.js`/a.
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar a: number\n```
print_fib(a)
//^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
// ^ reference pure-js 1.0.0 src/`main.js`/a.
// ^ reference pure-js 1.0.0 src/`main.js`/a.

function forever() {
// ^^^^^^^ definition pure-js 1.0.0 src/`main.js`/forever().
// documentation ```ts\n() => any\n```
// documentation ```ts\nfunction forever(): any\n```
return forever()
// ^^^^^^^ reference pure-js 1.0.0 src/`main.js`/forever().
}

function use_before_def() {
// ^^^^^^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/use_before_def().
// documentation ```ts\n() => void\n```
// documentation ```ts\nfunction use_before_def(): void\n```
print_fib(n)
// ^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
// ^ reference local 8
var n = 10
// ^ definition local 8
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar n: number\n```

if (forever()) {
// ^^^^^^^ reference pure-js 1.0.0 src/`main.js`/forever().
var m = 10
// ^ definition local 11
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar m: number\n```
}
print_fib(m)
// ^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
Expand All @@ -98,15 +98,15 @@

function var_function_scope() {
// ^^^^^^^^^^^^^^^^^^ definition pure-js 1.0.0 src/`main.js`/var_function_scope().
// documentation ```ts\n() => void\n```
// documentation ```ts\nfunction var_function_scope(): void\n```
var k = 0
// ^ definition local 14
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar k: number\n```
if (forever()) {
// ^^^^^^^ reference pure-js 1.0.0 src/`main.js`/forever().
var k = 1
// ^ definition local 14
// documentation ```ts\nnumber\n```
// documentation ```ts\nvar k: number\n```
}
print_fib(k)
// ^^^^^^^^^ reference pure-js 1.0.0 src/`main.js`/print_fib().
Expand Down
12 changes: 6 additions & 6 deletions snapshots/output/react/src/LoaderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
/** Takes loading prop, input component as child */
interface Props {
// ^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#
// documentation ```ts\nProps\n```
// documentation ```ts\ninterface Props\n```
// documentation Takes loading prop, input component as child
loading: boolean
// ^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
// documentation ```ts\nboolean\n```
// documentation ```ts\n(property) loading: boolean\n```
children: React.ReactNode
// ^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/Props#children.
// documentation ```ts\nReactNode\n```
// documentation ```ts\n(property) children: ReactNode\n```
// ^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/
// ^^^^^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/ReactNode#
}

export const LoaderInput: React.FunctionComponent<Props> = ({
// ^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
// documentation ```ts\nFunctionComponent<Props>\n```
// documentation ```ts\nvar LoaderInput: FunctionComponent<Props>\n```
// ^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/FunctionComponent#
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
Expand All @@ -42,12 +42,12 @@

export const LoaderInput2: React.FunctionComponent<Props> = props => {
// ^^^^^^^^^^^^ definition react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput2.
// documentation ```ts\nFunctionComponent<Props>\n```
// documentation ```ts\nvar LoaderInput2: FunctionComponent<Props>\n```
// ^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/FunctionComponent#
// ^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#
// ^^^^^ definition local 6
// documentation ```ts\nPropsWithChildren<Props>\n```
// documentation ```ts\n(parameter) props: PropsWithChildren<Props>\n```
return <LoaderInput loading={true} key="key" children={props.children} />
// ^^^^^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/LoaderInput.
// ^^^^^^^ reference react-example 1.0.0 src/`LoaderInput.tsx`/Props#loading.
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/react/src/MyTSXElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

export interface MyProps {}
// ^^^^^^^ definition react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
// documentation ```ts\nMyProps\n```
// documentation ```ts\ninterface MyProps\n```

export const MyTSXElement: React.FunctionComponent<MyProps> = ({}) => (<p></p>)
// ^^^^^^^^^^^^ definition react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
// documentation ```ts\nFunctionComponent<MyProps>\n```
// documentation ```ts\nvar MyTSXElement: FunctionComponent<MyProps>\n```
// ^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/FunctionComponent#
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/react/src/UseMyTSXElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

export const _: React.FunctionComponent<MyProps> =
// ^ definition react-example 1.0.0 src/`UseMyTSXElement.tsx`/_.
// documentation ```ts\nFunctionComponent<MyProps>\n```
// documentation ```ts\nvar _: FunctionComponent<MyProps>\n```
// ^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/
// ^^^^^^^^^^^^^^^^^ reference @types/react 17.0.0 `index.d.ts`/React/FunctionComponent#
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
Expand Down
46 changes: 23 additions & 23 deletions snapshots/output/syntax/src/accessors.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
class C {
// ^ definition syntax 1.0.0 src/`accessors.ts`/C#
// documentation ```ts\nC\n```
// documentation ```ts\nclass C\n```
_length: number = 0
// ^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#_length.
// documentation ```ts\nnumber\n```
// documentation ```ts\n(property) _length: number\n```
get length(): number {
// ^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#`<get>length`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget length: number\n```
return this._length
// ^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/C#_length.
}
set length(value: number) {
// ^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#`<get>length`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget length: number\n```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect.

Copy link
Contributor Author

@varungandhi-src varungandhi-src Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, there seems to be something consistently wrong with how we're handling accessors. Notice the

definition syntax 1.0.0 src/`accessors.ts`/C#`<get>length`().

right above this, it should be <set> and not <get>. I'll fix the accessors in a separate PR.

// ^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#`<set>length`().(value)
// documentation ```ts\nnumber\n```
// documentation ```ts\n(parameter) value: number\n```
this._length = value
// ^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/C#_length.
// ^^^^^ reference syntax 1.0.0 src/`accessors.ts`/C#`<set>length`().(value)
}

_capacity: number = 0
// ^^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#_capacity.
// documentation ```ts\nnumber\n```
// documentation ```ts\n(property) _capacity: number\n```
get capacity(): number {
// ^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#`<get>capacity`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget capacity: number\n```
return this._capacity
// ^^^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/C#_capacity.
}
}

export class D {
// ^ definition syntax 1.0.0 src/`accessors.ts`/D#
// documentation ```ts\nD\n```
// documentation ```ts\nclass D\n```
_length: number = 0
// ^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#_length.
// documentation ```ts\nnumber\n```
// documentation ```ts\n(property) _length: number\n```
public get length(): number {
// ^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<get>length`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget length: number\n```
return this._length
// ^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#_length.
}
public set length(value: number) {
// ^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<get>length`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget length: number\n```
// ^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<set>length`().(value)
// documentation ```ts\nnumber\n```
// documentation ```ts\n(parameter) value: number\n```
this._length = value
// ^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#_length.
// ^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#`<set>length`().(value)
}

_capacity: number = 0
// ^^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#_capacity.
// documentation ```ts\nnumber\n```
// documentation ```ts\n(property) _capacity: number\n```
public get capacity(): number {
// ^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<get>capacity`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget capacity: number\n```
return this._capacity
// ^^^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#_capacity.
}
private set capacity(value: number) {
// ^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<get>capacity`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget capacity: number\n```
// ^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#`<set>capacity`().(value)
// documentation ```ts\nnumber\n```
// documentation ```ts\n(parameter) value: number\n```
this._capacity = value
// ^^^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#_capacity.
// ^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#`<set>capacity`().(value)
}
public unsafeSetCapacity(value: number): void {
// ^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#unsafeSetCapacity().
// documentation ```ts\n(value: number) => void\n```
// documentation ```ts\n(method) unsafeSetCapacity(value: number): void\n```
// ^^^^^ definition syntax 1.0.0 src/`accessors.ts`/D#unsafeSetCapacity().(value)
// documentation ```ts\nnumber\n```
// documentation ```ts\n(parameter) value: number\n```
this.capacity = value
// ^^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#`<get>capacity`().
// ^^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/D#`<set>capacity`().
Expand All @@ -85,16 +85,16 @@

function g(_: number): void {}
// ^ definition syntax 1.0.0 src/`accessors.ts`/g().
// documentation ```ts\n(_: number) => void\n```
// documentation ```ts\nfunction g(_: number): void\n```
// ^ definition syntax 1.0.0 src/`accessors.ts`/g().(_)
// documentation ```ts\nnumber\n```
// documentation ```ts\n(parameter) _: number\n```

function f() {
// ^ definition syntax 1.0.0 src/`accessors.ts`/f().
// documentation ```ts\n() => void\n```
// documentation ```ts\nfunction f(): void\n```
const c = new C()
// ^ definition local 2
// documentation ```ts\nC\n```
// documentation ```ts\nvar c: C\n```
// ^ reference syntax 1.0.0 src/`accessors.ts`/C#
c.length = 10
// ^ reference local 2
Expand All @@ -117,7 +117,7 @@

const d = new D()
// ^ definition local 5
// documentation ```ts\nD\n```
// documentation ```ts\nvar d: D\n```
// ^ reference syntax 1.0.0 src/`accessors.ts`/D#
d.length = 0
// ^ reference local 5
Expand Down
Loading