|
7 | 7 |
|
8 | 8 | > Adds code intelligence to code views on the web |
9 | 9 |
|
10 | | -## API |
| 10 | +## What it does |
11 | 11 |
|
12 | | -Use in React TODO |
| 12 | +- Listens to hover and click events on the code view |
| 13 | +- On mouse hovers, determines the line+column position, does an LSP hover request and renders it in a nice tooltip overlay at the token |
| 14 | +- Shows buttons for go-to-definition, find-references, find-implementations |
| 15 | +- When clicking a token, pins the tooltip to that token |
| 16 | +- Highlights the hovered token |
13 | 17 |
|
14 | | -Use with native DOM TODO |
| 18 | +## Usage |
| 19 | + |
| 20 | +- Call `createHoverifier()` to create a `Hoverifier` object (there should only be one on the page, to have only one HoverOverlay shown). |
| 21 | +- The Hoverifier exposes an Observable `hoverStateUpdates` that a consumer can subscribe to, which emits all data needed to render the `HoverOverlay` React component. |
| 22 | +- For each code view on the page, call `hoverifier.hoverify()`, passing the position events coming from `findPositionsFromEvents()`. |
| 23 | +- `hoverify()` returns a `Subscription` that will "unhoverify" the code view again if unsubscribed from |
15 | 24 |
|
16 | 25 | ## Development |
17 | 26 |
|
18 | | -```shell |
19 | | -npm i |
| 27 | +```sh |
| 28 | +npm install |
20 | 29 | npm test |
| 30 | + |
| 31 | +# Helpful options: |
| 32 | +npm test -- --single-run # Don't rerun on changes |
| 33 | +npm test -- --browsers Chrome # Only run in Chrome |
21 | 34 | ``` |
22 | 35 |
|
23 | 36 | Development is done by running tests. [Karma](https://github.com/karma-runner/karma) is used to run |
24 | 37 | [Mocha](https://github.com/mochajs/mocha) tests in the browser. You can debug by opening http://localhost:9876/debug.html in |
25 | | -a browser while the test running is active. |
| 38 | +a browser while the test running is active. The tests will rerun automatically when files are changed. |
| 39 | + |
| 40 | +You can run specific tests by [adding `.only` to `describe` or `it` calls](https://mochajs.org/#exclusive-tests). |
| 41 | + |
| 42 | +## Releases |
| 43 | + |
| 44 | +Releases are done automatically in CI when commits are merged into master by analyzing [Conventional Commit Messages](https://conventionalcommits.org/). |
| 45 | +After running `npm install`, commit messages will be linted automatically when committing. |
| 46 | +You may have to rebase a branch before merging to ensure it has a proper commit history. |
| 47 | + |
| 48 | +## Glossary |
26 | 49 |
|
27 | | -All tests are ran against DOM that is generated to match the DOM used by the supported code hosts. |
| 50 | +| Term | Definition | |
| 51 | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 52 | +| Code view | The DOM element that contains all the line elements | |
| 53 | +| Line number element | The DOM element that contains the line number label for that line | |
| 54 | +| Code element | The DOM element that contains the code for one line | |
| 55 | +| Diff part | The part of the diff, either base, head or both (if the line didn't change). Each line belongs to one diff part, and therefor to a different commit ID and potentially different file path. | |
| 56 | +| Hover overlay | Also called tooltip | |
0 commit comments