2022-05-02 18:55:15 +03:00
|
|
|
# Get Definitions Test
|
|
|
|
|
|
|
|
```ucm:hide
|
2024-06-25 21:32:44 +03:00
|
|
|
scratch/main> builtins.mergeio lib.builtins
|
2022-05-02 18:55:15 +03:00
|
|
|
```
|
|
|
|
|
2022-08-17 00:02:52 +03:00
|
|
|
```unison:hide
|
2024-06-25 21:32:44 +03:00
|
|
|
nested.names.x.doc = {{ Documentation }}
|
|
|
|
nested.names.x = 42
|
2022-05-02 18:55:15 +03:00
|
|
|
```
|
|
|
|
|
2022-08-17 00:02:52 +03:00
|
|
|
```ucm:hide
|
2024-06-25 21:32:44 +03:00
|
|
|
scratch/main> add
|
2022-05-02 18:55:15 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
```api
|
2023-12-08 02:18:55 +03:00
|
|
|
-- Should NOT find names by suffix
|
2024-06-25 21:32:44 +03:00
|
|
|
GET /api/projects/scratch/branches/main/getDefinition?names=x
|
2022-05-02 18:55:15 +03:00
|
|
|
|
|
|
|
-- Term names should strip relativeTo prefix.
|
2024-06-25 21:32:44 +03:00
|
|
|
GET /api/projects/scratch/branches/main/getDefinition?names=names.x&relativeTo=nested
|
2022-05-05 20:19:09 +03:00
|
|
|
|
|
|
|
-- Should find definitions by hash, names should be relative
|
2024-06-25 21:32:44 +03:00
|
|
|
GET /api/projects/scratch/branches/main/getDefinition?names=%23qkhkl0n238&relativeTo=nested
|
2022-05-02 18:55:15 +03:00
|
|
|
```
|
2022-08-17 00:02:52 +03:00
|
|
|
|
|
|
|
```unison:hide
|
2024-06-25 21:32:44 +03:00
|
|
|
doctest.thing.doc = {{ The correct docs for the thing }}
|
|
|
|
doctest.thing = "A thing"
|
|
|
|
doctest.thingalias.doc = {{ Docs for the alias, should not be displayed }}
|
|
|
|
doctest.thingalias = "A thing"
|
|
|
|
doctest.otherstuff.thing.doc = {{ A doc for a different term with the same name, should not be displayed }}
|
|
|
|
doctest.otherstuff.thing = "A different thing"
|
2022-08-17 00:02:52 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
```ucm:hide
|
2024-06-25 21:32:44 +03:00
|
|
|
scratch/main> add
|
2022-08-17 00:02:52 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Only docs for the term we request should be returned, even if there are other term docs with the same suffix.
|
|
|
|
|
|
|
|
```api
|
2024-06-25 21:32:44 +03:00
|
|
|
GET /api/projects/scratch/branches/main/getDefinition?names=thing&relativeTo=doctest
|
2022-08-17 00:02:52 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
If we request a doc, the api should return the source, but also the rendered doc should appear in the 'termDocs' list.
|
|
|
|
|
|
|
|
```api
|
2024-06-25 21:32:44 +03:00
|
|
|
GET /api/projects/scratch/branches/main/getDefinition?names=thing.doc&relativeTo=doctest
|
2022-08-17 00:02:52 +03:00
|
|
|
```
|