Skip to content

Commit

Permalink
Fix special case for type doc in lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Jan 24, 2024
1 parent 58296a7 commit 047ef59
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
17 changes: 17 additions & 0 deletions unison-src/transcripts/doc2markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,20 @@ Table
```ucm
.> debug.doc-to-markdown fulldoc
```

You can add docs to a term or type with a top-level doc literal above the binding:

```unison
{{ This is a term doc }}
myTerm = 10
-- Regression tests for https://github.com/unisonweb/unison/issues/4634
{{ This is a type doc }}
type MyType = MyType
{{ This is a unique type doc }}
unique type MyUniqueType = MyUniqueType
{{ This is a structural type doc }}
structural type MyStructuralType = MyStructuralType
```
38 changes: 38 additions & 0 deletions unison-src/transcripts/doc2markdown.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,42 @@ Table



```
You can add docs to a term or type with a top-level doc literal above the binding:
```unison
{{ This is a term doc }}
myTerm = 10
-- Regression tests for https://github.com/unisonweb/unison/issues/4634
{{ This is a type doc }}
type MyType = MyType
{{ This is a unique type doc }}
unique type MyUniqueType = MyUniqueType
{{ This is a structural type doc }}
structural type MyStructuralType = MyStructuralType
```

```ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
structural type MyStructuralType
(also named builtin.Unit)
type MyType
type MyUniqueType
MyStructuralType.doc : Doc2
MyType.doc : Doc2
MyUniqueType.doc : Doc2
myTerm : Nat
myTerm.doc : Doc2
```
2 changes: 1 addition & 1 deletion unison-syntax/src/Unison/Syntax/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ lexemes' eof =
let lit' s = lit s <* sp
let modifier = typeModifiersAlt lit'
let typeOrAbility' = typeOrAbilityAlt wordyKw
_ <- modifier <* typeOrAbility' *> sp
_ <- optional modifier *> typeOrAbility' *> sp
wordyId
ignore _ _ _ = []
body = join <$> P.many (sectionElem <* CP.space)
Expand Down

0 comments on commit 047ef59

Please sign in to comment.