Skip to content

Commit b84dc2e

Browse files
authored
Merge pull request #38 from unisoncomputing/cp/fix-hq-docs
Definition rendering fixes
2 parents 9e9897e + 6f4d5b4 commit b84dc2e

File tree

15 files changed

+186
-100
lines changed

15 files changed

+186
-100
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ jobs:
240240
241241
# Install ucm
242242
mkdir ucm
243-
curl -L https://github.com/unisonweb/unison/releases/download/release%2F0.5.25/ucm-linux.tar.gz | tar -xz -C ucm
243+
curl -L https://github.com/unisonweb/unison/releases/download/release%2F0.5.33/ucm-linux-x64.tar.gz | tar -xz -C ucm
244244
export PATH=$PWD/ucm:$PATH
245245
246246
# Clean up old postgres data if it exists.

src/Share/Postgres/NameLookups/Types.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Share.Postgres.NameLookups.Types
1010
NameLookupReceipt (..),
1111
pathSegmentsToText,
1212
textToPathSegments,
13+
nameToPathSegments,
1314
reversedNameToNamespaceText,
1415
reversedNameToPathSegments,
1516
prefixNamedRef,
@@ -23,6 +24,7 @@ module Share.Postgres.NameLookups.Types
2324
where
2425

2526
import Control.Lens hiding (from)
27+
import Data.Foldable qualified as Foldable
2628
import Data.List.Extra qualified as List
2729
import Data.List.NonEmpty.Extra qualified as NonEmpty
2830
import Data.Text qualified as Text
@@ -34,6 +36,7 @@ import Share.Prelude
3436
import U.Codebase.Referent (ConstructorType)
3537
import Unison.Name (Name)
3638
import Unison.Name qualified as Name
39+
import Unison.NameSegment qualified as NameSegment
3740
import Unison.NameSegment.Internal (NameSegment (..))
3841

3942
-- | Proof that we've checked that a given name lookup exists before we try to use it.
@@ -124,6 +127,11 @@ type NamespaceText = Text
124127
pathSegmentsToText :: PathSegments -> Text
125128
pathSegmentsToText (PathSegments txt) = Text.intercalate "." txt
126129

130+
-- >>> nameToPathSegments (Name.fromSegments (NameSegment "base" :| [NameSegment "data", NameSegment "List"]))
131+
-- PathSegments ["base","data","List"]
132+
nameToPathSegments :: Name -> PathSegments
133+
nameToPathSegments name = (PathSegments . Foldable.toList . fmap NameSegment.toUnescapedText $ Name.segments name)
134+
127135
-- |
128136
-- >>> textToPathSegments "base.data.List"
129137
-- PathSegments ["base","data","List"]

src/Unison/Server/Share/Definitions.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Share.Postgres qualified as PG
2424
import Share.Postgres.Causal.Queries qualified as CausalQ
2525
import Share.Postgres.IDs (CausalId)
2626
import Share.Postgres.NameLookups.Ops qualified as NameLookupOps
27+
import Share.Postgres.NameLookups.Types qualified as NL
2728
import Share.Prelude
2829
import Share.Utils.Caching.JSON qualified as Caching
2930
import Unison.Codebase.Editor.DisplayObject (DisplayObject)
@@ -112,6 +113,10 @@ definitionForHQName perspective rootCausalId renderWidth suffixifyBindings rt pe
112113
let docResults :: Name -> Codebase.CodebaseM e [(HashQualifiedName, UnisonHash, Doc.Doc)]
113114
docResults name = do
114115
Debug.debugM Debug.Server "definitionForHQName: looking up docs for name" name
116+
-- We need to re-lookup the names perspective here because the name we've found
117+
-- may now be in a lib.
118+
namesPerspective <- NameLookupOps.namesPerspectiveForRootAndPath rootBranchNamespaceHashId (NL.nameToPathSegments name)
119+
let nameSearch = PGNameSearch.nameSearchForPerspective namesPerspective
115120
docRefs <- Docs.docsForDefinitionName nameSearch name
116121
Debug.debugM Debug.Server "definitionForHQName: Found these docs" docRefs
117122
renderDocRefs ppedBuilder width rt docRefs
@@ -122,12 +127,14 @@ definitionForHQName perspective rootCausalId renderWidth suffixifyBindings rt pe
122127
typeDefinitions <-
123128
ifor (Backend.typesToSyntaxOf suffixifyBindings width termAndTypePPED (Map.asList_ . traversed) types) \ref tp -> do
124129
let hqTypeName = PPE.typeNameOrHashOnly fqnTermAndTypePPE ref
130+
Debug.debugM Debug.Temp "definitionForHQName: hqTypeName " (ref, hqTypeName)
125131
docs <- maybe (pure []) docResults (HQ.toName hqTypeName)
126132
lift $ Backend.mkTypeDefinition termAndTypePPED width ref docs tp
127133
termDefinitions <-
128134
ifor (Backend.termsToSyntaxOf suffixifyBindings width termAndTypePPED (Map.asList_ . traversed) terms) \reference trm -> do
129135
let referent = Referent.Ref reference
130136
let hqTermName = PPE.termNameOrHashOnly fqnTermAndTypePPE referent
137+
Debug.debugM Debug.Temp "definitionForHQName: hqTermName " (reference, hqTermName)
131138
docs <- maybe (pure []) docResults (HQ.toName hqTermName)
132139
Backend.mkTermDefinition termAndTypePPED width reference docs trm
133140
let renderedDisplayTerms = Map.mapKeys Reference.toText termDefinitions

transcripts/share-apis/contribution-diffs/contribution-diff.json

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
},
100100
{
101101
"annotation": null,
102-
"segment": " "
102+
"segment": "\n"
103+
},
104+
{
105+
"annotation": null,
106+
"segment": " "
103107
},
104108
{
105109
"annotation": {
@@ -197,7 +201,11 @@
197201
},
198202
{
199203
"annotation": null,
200-
"segment": " "
204+
"segment": "\n"
205+
},
206+
{
207+
"annotation": null,
208+
"segment": " "
201209
},
202210
{
203211
"annotation": {
@@ -295,7 +303,11 @@
295303
},
296304
{
297305
"annotation": null,
298-
"segment": " "
306+
"segment": "\n"
307+
},
308+
{
309+
"annotation": null,
310+
"segment": " "
299311
},
300312
{
301313
"annotation": {
@@ -397,7 +409,11 @@
397409
},
398410
{
399411
"annotation": null,
400-
"segment": " "
412+
"segment": "\n"
413+
},
414+
{
415+
"annotation": null,
416+
"segment": " "
401417
},
402418
{
403419
"annotation": {
@@ -494,7 +510,11 @@
494510
},
495511
{
496512
"annotation": null,
497-
"segment": " "
513+
"segment": "\n"
514+
},
515+
{
516+
"annotation": null,
517+
"segment": " "
498518
}
499519
]
500520
},
@@ -617,7 +637,11 @@
617637
},
618638
{
619639
"annotation": null,
620-
"segment": " "
640+
"segment": "\n"
641+
},
642+
{
643+
"annotation": null,
644+
"segment": " "
621645
},
622646
{
623647
"annotation": {
@@ -704,7 +728,11 @@
704728
},
705729
{
706730
"annotation": null,
707-
"segment": " "
731+
"segment": "\n"
732+
},
733+
{
734+
"annotation": null,
735+
"segment": " "
708736
},
709737
{
710738
"annotation": {

transcripts/share-apis/contribution-diffs/namespace-diff.json

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
},
100100
{
101101
"annotation": null,
102-
"segment": " "
102+
"segment": "\n"
103+
},
104+
{
105+
"annotation": null,
106+
"segment": " "
103107
},
104108
{
105109
"annotation": {
@@ -197,7 +201,11 @@
197201
},
198202
{
199203
"annotation": null,
200-
"segment": " "
204+
"segment": "\n"
205+
},
206+
{
207+
"annotation": null,
208+
"segment": " "
201209
},
202210
{
203211
"annotation": {
@@ -295,7 +303,11 @@
295303
},
296304
{
297305
"annotation": null,
298-
"segment": " "
306+
"segment": "\n"
307+
},
308+
{
309+
"annotation": null,
310+
"segment": " "
299311
},
300312
{
301313
"annotation": {
@@ -397,7 +409,11 @@
397409
},
398410
{
399411
"annotation": null,
400-
"segment": " "
412+
"segment": "\n"
413+
},
414+
{
415+
"annotation": null,
416+
"segment": " "
401417
},
402418
{
403419
"annotation": {
@@ -494,7 +510,11 @@
494510
},
495511
{
496512
"annotation": null,
497-
"segment": " "
513+
"segment": "\n"
514+
},
515+
{
516+
"annotation": null,
517+
"segment": " "
498518
}
499519
]
500520
},
@@ -617,7 +637,11 @@
617637
},
618638
{
619639
"annotation": null,
620-
"segment": " "
640+
"segment": "\n"
641+
},
642+
{
643+
"annotation": null,
644+
"segment": " "
621645
},
622646
{
623647
"annotation": {
@@ -704,7 +728,11 @@
704728
},
705729
{
706730
"annotation": null,
707-
"segment": " "
731+
"segment": "\n"
732+
},
733+
{
734+
"annotation": null,
735+
"segment": " "
708736
},
709737
{
710738
"annotation": {
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Add a change to a contributor branch, based on the main branch.
22

3-
``` unison
3+
``` ucm :hide
4+
scratch/main> clone @transcripts/merge/main
5+
6+
@transcripts/merge/main> branch @test/fast-forward-feature
7+
```
8+
9+
``` unison :hide
410
term = "feature"
511
```
612

@@ -9,9 +15,6 @@ Push the feature branch.
915
``` ucm
1016
@transcripts/merge/@test/fast-forward-feature> update
1117
12-
Okay, I'm searching the branch for code that needs to be
13-
updated...
14-
1518
Done.
1619
1720
@transcripts/merge/@test/fast-forward-feature> push @transcripts/merge/@test/fast-forward-feature
@@ -22,5 +25,4 @@ Push the feature branch.
2225
on http://localhost:5424
2326
2427
View it here: @transcripts/merge/@test/fast-forward-feature on http://localhost:5424
25-
2628
```
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
``` ucm :hide
2+
scratch/main> project.create-empty merge
3+
```
4+
15
Create a main branch.
26

3-
``` unison
7+
``` unison :hide
48
term = "start"
59
```
610

@@ -9,9 +13,6 @@ Push it.
913
``` ucm
1014
merge/main> update
1115
12-
Okay, I'm searching the branch for code that needs to be
13-
updated...
14-
1516
Done.
1617
1718
merge/main> push @transcripts/merge/main
@@ -21,5 +22,4 @@ merge/main> push @transcripts/merge/main
2122
I just created @transcripts/merge on http://localhost:5424
2223
2324
View it here: @transcripts/merge/main on http://localhost:5424
24-
2525
```

transcripts/share-apis/contribution-merge/pull-after-merge.output.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ scratch/main> clone @transcripts/merge/main
99
1010
term : ##Text
1111
term = "feature"
12-
1312
```

0 commit comments

Comments
 (0)