Newlines within {{ }} for multi-line docs

This commit is contained in:
Chris Penner 2024-01-31 11:27:49 -08:00
parent bea34375ab
commit cb974e7ae1
4 changed files with 27 additions and 19 deletions

View File

@ -1737,13 +1737,9 @@ prettyDoc2 ::
prettyDoc2 ac tm = do
ppe <- getPPE
let brace p =
fmt S.DocDelimiter "{{"
<> PP.softbreak
<> p
<> PP.softbreak
<> fmt
S.DocDelimiter
"}}"
if PP.isMultiLine p
then fmt S.DocDelimiter "{{" <> PP.newline <> p <> PP.newline <> fmt S.DocDelimiter "}}"
else fmt S.DocDelimiter "{{" <> PP.softbreak <> p <> PP.softbreak <> fmt S.DocDelimiter "}}"
bail tm = brace <$> pretty0 ac tm
-- Finds the longest run of a character and return one bigger than that
longestRun c s =

View File

@ -166,7 +166,8 @@ fix_2224b = cases
fix_2271 : Doc2
fix_2271 =
{{ # Full doc body indented
{{
# Full doc body indented
``` raw
myVal1 = 42
@ -179,7 +180,8 @@ fix_2271 =
indented2="this is two indents"
```
I am two spaces over }}
I am two spaces over
}}
Fix_2337.f : Fix_2337 -> Boolean
Fix_2337.f = cases Fix_2337 a b -> a
@ -304,10 +306,12 @@ fix_4384b = {{ {{ docExampleBlock 0 '99 }} }}
fix_4384c : Doc2
fix_4384c =
use Nat +
{{ {{ docExampleBlock 0 do
{{
{{ docExampleBlock 0 do
x = 1
y = 2
x + y }} }}
x + y }}
}}
fix_4384d : Doc2
fix_4384d =
@ -432,11 +436,13 @@ multiline_list =
nested_fences : Doc2
nested_fences =
{{ ```` raw
{{
```` raw
```unison
r = "boopydoo"
```
```` }}
````
}}
raw_a : Text
raw_a =

View File

@ -553,7 +553,8 @@ Lastly, it's common to build longer documents including subdocuments via `{{ sub
doc.guide : Doc2
doc.guide =
{{ # Unison computable documentation
{{
# Unison computable documentation
{{ basicFormatting }}
@ -565,7 +566,8 @@ Lastly, it's common to build longer documents including subdocuments via `{{ sub
{{ nonUnisonCodeBlocks }}
{{ otherElements }} }}
{{ otherElements }}
}}
.> display doc.guide

View File

@ -52,11 +52,13 @@ type Two = One Nat | Two Text
```
```unison:added-by-ucm scratch.u
x.doc =
{{ # Doc This is a **doc**!
{{
# Doc This is a **doc**!
term link {x}
type link {type Optional} }}
type link {type Optional}
}}
x : Nat -> Nat
x y =
use Nat +
@ -70,11 +72,13 @@ oneLiner = {{ one liner }}
-- Before
explicit.doc =
{{ # Here's a top-level doc
{{
# Here's a top-level doc
With a paragraph
Or two }}
Or two
}}
-- After
Thing.doc = {{ A doc before an ability }}