Skip to content

Commit 4a6ea26

Browse files
Copilotobserverw
andauthored
Rename hover API to doc API (#18)
* Initial plan * Rename hover API to doc API - update Python code and schema files Co-authored-by: observerw <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: observerw <[email protected]>
1 parent a703369 commit 4a6ea26

File tree

9 files changed

+39
-39
lines changed

9 files changed

+39
-39
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@
100100
"required": [
101101
"locate"
102102
],
103-
"title": "HoverRequest",
103+
"title": "DocRequest",
104104
"type": "object"
105105
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"markdown": "\n# Hover Information\n\n{{ content }}\n",
2+
"markdown": "\n# Doc Information\n\n{{ content }}\n",
33
"properties": {
44
"content": {
55
"title": "Content",
@@ -9,6 +9,6 @@
99
"required": [
1010
"content"
1111
],
12-
"title": "HoverResponse",
12+
"title": "DocResponse",
1313
"type": "object"
1414
}

schema/hover.md renamed to schema/doc.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Hover API
1+
# Doc API
22

3-
The Hover API provides quick access to documentation, type information, or other
3+
The Doc API provides quick access to documentation, type information, or other
44
relevant metadata for a symbol at a specific location. It's useful for getting
55
context without navigating to the definition.
66

@@ -32,7 +32,7 @@ Request:
3232
}
3333
```
3434

35-
### Scenario 3: Getting hover for a class method
35+
### Scenario 3: Getting documentation for a class method
3636

3737
Request:
3838

@@ -47,7 +47,7 @@ Request:
4747
}
4848
```
4949

50-
### Scenario 4: Getting hover for an imported module
50+
### Scenario 4: Getting documentation for an imported module
5151

5252
Request:
5353

@@ -62,5 +62,5 @@ Request:
6262

6363
## References
6464

65-
- [HoverRequest.json](./HoverRequest.json)
66-
- [HoverResponse.json](./HoverResponse.json)
65+
- [DocRequest.json](./DocRequest.json)
66+
- [DocResponse.json](./DocResponse.json)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@
100100
"required": [
101101
"locate"
102102
],
103-
"title": "HoverRequest",
103+
"title": "DocRequest",
104104
"type": "object"
105105
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"markdown": "\n# Hover Information\n\n{{ content }}\n",
2+
"markdown": "\n# Doc Information\n\n{{ content }}\n",
33
"properties": {
44
"content": {
55
"title": "Content",
@@ -9,6 +9,6 @@
99
"required": [
1010
"content"
1111
],
12-
"title": "HoverResponse",
12+
"title": "DocResponse",
1313
"type": "object"
1414
}

src/lsap/capability/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TypedDict
22

33
from .definition import DefinitionCapability
4-
from .hover import HoverCapability
4+
from .doc import DocCapability
55
from .locate import LocateCapability
66
from .outline import OutlineCapability
77
from .reference import ReferenceCapability
@@ -12,7 +12,7 @@
1212

1313
class Capabilities(TypedDict):
1414
definition: DefinitionCapability
15-
hover: HoverCapability
15+
doc: DocCapability
1616
locate: LocateCapability
1717
outline: OutlineCapability
1818
references: ReferenceCapability
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
from attrs import define
66
from lsp_client.capability.request import WithRequestHover
77

8-
from lsap.schema.hover import HoverRequest, HoverResponse
8+
from lsap.schema.doc import DocRequest, DocResponse
99
from lsap.utils.capability import ensure_capability
1010

1111
from .abc import Capability
1212
from .locate import LocateCapability
1313

1414

1515
@define
16-
class HoverCapability(Capability[HoverRequest, HoverResponse]):
16+
class DocCapability(Capability[DocRequest, DocResponse]):
1717
@cached_property
1818
def locate(self) -> LocateCapability:
1919
return LocateCapability(self.client)
2020

21-
async def __call__(self, req: HoverRequest) -> HoverResponse | None:
21+
async def __call__(self, req: DocRequest) -> DocResponse | None:
2222
if not (loc_resp := await self.locate(req)):
2323
return None
2424

@@ -30,4 +30,4 @@ async def __call__(self, req: HoverRequest) -> HoverResponse | None:
3030
if hover is None:
3131
return None
3232

33-
return HoverResponse(content=hover.value)
33+
return DocResponse(content=hover.value)
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
# Hover API
2+
# Doc API
33
4-
The Hover API provides quick access to documentation, type information, or other
4+
The Doc API provides quick access to documentation, type information, or other
55
relevant metadata for a symbol at a specific location. It's useful for getting
66
context without navigating to the definition.
77
@@ -33,7 +33,7 @@
3333
}
3434
```
3535
36-
### Scenario 3: Getting hover for a class method
36+
### Scenario 3: Getting documentation for a class method
3737
3838
Request:
3939
@@ -48,7 +48,7 @@
4848
}
4949
```
5050
51-
### Scenario 4: Getting hover for an imported module
51+
### Scenario 4: Getting documentation for an imported module
5252
5353
Request:
5454
@@ -70,7 +70,7 @@
7070
from .locate import LocateRequest
7171

7272

73-
class HoverRequest(LocateRequest):
73+
class DocRequest(LocateRequest):
7474
"""
7575
Retrieves documentation or type information for a symbol at a specific location.
7676
@@ -80,15 +80,15 @@ class HoverRequest(LocateRequest):
8080

8181

8282
markdown_template: Final = """
83-
# Hover Information
83+
# Doc Information
8484
8585
{{ content }}
8686
"""
8787

8888

89-
class HoverResponse(Response):
89+
class DocResponse(Response):
9090
content: str
91-
"""The hover content, usually markdown."""
91+
"""The documentation content, usually markdown."""
9292

9393
model_config = ConfigDict(
9494
json_schema_extra={
@@ -98,6 +98,6 @@ class HoverResponse(Response):
9898

9999

100100
__all__ = [
101-
"HoverRequest",
102-
"HoverResponse",
101+
"DocRequest",
102+
"DocResponse",
103103
]
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
from lsprotocol.types import MarkupContent, MarkupKind
77
from lsprotocol.types import Position as LSPPosition
88

9-
from lsap.capability.hover import HoverCapability
10-
from lsap.schema.hover import HoverRequest
9+
from lsap.capability.doc import DocCapability
10+
from lsap.schema.doc import DocRequest
1111
from lsap.schema.locate import LineScope, Locate
1212

1313

14-
class MockHoverClient(MagicMock):
14+
class MockDocClient(MagicMock):
1515
def __init__(self, *args, **kwargs):
1616
class MockProtocols(WithRequestHover, WithRequestDocumentSymbol):
1717
pass
@@ -39,11 +39,11 @@ async def request_document_symbol_list(self, file_path: Path):
3939

4040

4141
@pytest.mark.asyncio
42-
async def test_hover():
43-
client = MockHoverClient()
44-
capability = HoverCapability(client=client) # type: ignore
42+
async def test_doc():
43+
client = MockDocClient()
44+
capability = DocCapability(client=client) # type: ignore
4545

46-
req = HoverRequest(
46+
req = DocRequest(
4747
locate=Locate(file_path=Path("main.py"), scope=LineScope(line=1), find="foo"),
4848
)
4949

@@ -53,11 +53,11 @@ async def test_hover():
5353

5454

5555
@pytest.mark.asyncio
56-
async def test_hover_not_found():
57-
client = MockHoverClient()
58-
capability = HoverCapability(client=client) # type: ignore
56+
async def test_doc_not_found():
57+
client = MockDocClient()
58+
capability = DocCapability(client=client) # type: ignore
5959

60-
req = HoverRequest(
60+
req = DocRequest(
6161
locate=Locate(file_path=Path("main.py"), scope=LineScope(line=1), find="bar"),
6262
)
6363

0 commit comments

Comments
 (0)