mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Change docs
command to expect Name
Previously, when given a numbered arg, from some commands (e.g., `find`), it would fail to find the docs because the hash associated with the definition was applied to the `doc`, which then would be incorrect. This now discards hashes up-front, so it can add the `doc` suffix to the name. Fixes #3939.
This commit is contained in:
parent
7d7047967a
commit
b985bb1728
@ -1758,7 +1758,7 @@ displayI outputLoc hq = do
|
||||
let ns = UF.addNamesFromTypeCheckedUnisonFile unisonFile names
|
||||
doDisplay outputLoc ns tm
|
||||
|
||||
docsI :: Path.HQSplit' -> Cli ()
|
||||
docsI :: Name -> Cli ()
|
||||
docsI src = do
|
||||
findInScratchfileByName
|
||||
where
|
||||
@ -1766,14 +1766,8 @@ docsI src = do
|
||||
(fileByName) First check the file for `foo.doc`, and if found do `display foo.doc`
|
||||
(codebaseByName) Lastly check for `foo.doc` in the codebase and if found do `display foo.doc`
|
||||
-}
|
||||
hq :: HQ.HashQualified Name
|
||||
hq =
|
||||
let hq' :: HQ'.HashQualified Name
|
||||
hq' = Path.unsafeToName' <$> Name.convert src
|
||||
in Name.convert hq'
|
||||
|
||||
dotDoc :: HQ.HashQualified Name
|
||||
dotDoc = hq <&> \n -> Name.joinDot n (Name.fromSegment "doc")
|
||||
dotDoc = Name.convert . Name.joinDot src $ Name.fromSegment "doc"
|
||||
|
||||
findInScratchfileByName :: Cli ()
|
||||
findInScratchfileByName = do
|
||||
|
@ -174,7 +174,7 @@ data Input
|
||||
| -- Display provided definitions.
|
||||
DisplayI OutputLocation (NonEmpty (HQ.HashQualified Name))
|
||||
| -- Display docs for provided terms.
|
||||
DocsI (NonEmpty Path.HQSplit')
|
||||
DocsI (NonEmpty Name)
|
||||
| -- other
|
||||
FindI Bool FindScope [String] -- FindI isVerbose findScope query
|
||||
| FindShallowI Path'
|
||||
|
@ -992,7 +992,7 @@ docs =
|
||||
"`docs` without arguments invokes a search to select which definition to view documentation for, which requires that `fzf` can be found within your PATH."
|
||||
]
|
||||
)
|
||||
$ maybe (Left $ I.help docs) (fmap Input.DocsI . traverse handleHashQualifiedSplit'Arg) . NE.nonEmpty
|
||||
$ maybe (Left $ I.help docs) (fmap Input.DocsI . traverse handleNameArg) . NE.nonEmpty
|
||||
|
||||
api :: InputPattern
|
||||
api =
|
||||
|
@ -35,22 +35,6 @@ meh = 9
|
||||
|
||||
.> docs 1
|
||||
|
||||
⚠️
|
||||
|
||||
The following names were not found in the codebase. Check your spelling.
|
||||
meh.doc#3n6of1k7qmgib9jda9ov1obetubfmladketn40gqifp4pfdea8it6ofa920l1topi2pd32vlsbfu3q41fkbt8coa38akg9eetto09j8
|
||||
A simple doc.
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
🛑
|
||||
|
||||
The transcript failed due to an error in the stanza above. The error is:
|
||||
|
||||
|
||||
⚠️
|
||||
|
||||
The following names were not found in the codebase. Check your spelling.
|
||||
meh.doc#3n6of1k7qmgib9jda9ov1obetubfmladketn40gqifp4pfdea8it6ofa920l1topi2pd32vlsbfu3q41fkbt8coa38akg9eetto09j8
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user