diff --git a/unison-src/transcripts/doc2markdown.md b/unison-src/transcripts/doc2markdown.md index 52217ef4b8..a7ac7a808b 100644 --- a/unison-src/transcripts/doc2markdown.md +++ b/unison-src/transcripts/doc2markdown.md @@ -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 +``` diff --git a/unison-src/transcripts/doc2markdown.output.md b/unison-src/transcripts/doc2markdown.output.md index 472ed00ab8..c9b98f984f 100644 --- a/unison-src/transcripts/doc2markdown.output.md +++ b/unison-src/transcripts/doc2markdown.output.md @@ -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 + ``` diff --git a/unison-syntax/src/Unison/Syntax/Lexer.hs b/unison-syntax/src/Unison/Syntax/Lexer.hs index 9e0beb95f5..5551069d90 100644 --- a/unison-syntax/src/Unison/Syntax/Lexer.hs +++ b/unison-syntax/src/Unison/Syntax/Lexer.hs @@ -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)