Skip to content

Commit

Permalink
Use CommonMark-compatible info strings everywhere
Browse files Browse the repository at this point in the history
The bulk of this updates transcripts to put spaces around the language
name in code blocks. E.g.,
```` markdown
```ucm:hide
````
becomes
```` markdown
``` ucm :hide
````

This corresponds to
https://share.unison-lang.org/@unison/website/contributions/11, which
updates the docs in the same way.

This is effectively a fix for #5214, but that issue also has good recommendations for future changes to info strings, so
I don’t know that it should be closed.
  • Loading branch information
sellout committed Oct 8, 2024
1 parent aba7145 commit 75c228f
Show file tree
Hide file tree
Showing 387 changed files with 2,406 additions and 2,489 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ assignees: ''
Please attach a [ucm transcript](https://www.unison-lang.org/docs/tooling/transcripts/) if possible, calling out the unexpected behavior in the text. e.g.

Input:
````
```unison:hide
```` markdown
``` unison :hide
a = 1
```
Here I typo the next command and `ucm` silently does nothing. I would have expected an error message:
```ucm
``` ucm
.> add b
```
````

Output:
````
```unison
```` markdown
``` unison
a = 1
```

Here I typo the next command and `ucm` silently does nothing, I would have expected an error message:
```ucm
``` ucm
.> add b



```
````
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,14 @@ jobs:
path: ${{ runner.temp }}/setup-jit.md
write-mode: overwrite
contents: |
```ucm
``` ucm
scratch/main> project.create-empty jit-setup
jit-setup/main> lib.install ${{ env.jit_version }}
```
```unison
``` unison
go = generateSchemeBoot "${{ env.jit_generated_src_scheme }}"
```
```ucm
``` ucm
jit-setup/main> run go
```
- name: download ucm artifact
Expand Down
2 changes: 1 addition & 1 deletion docs/repoformats/v2.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ In order to avoid fully rewriting the ABT to update `TextId` and `ObjectId` repl

An example:

```unison
``` unison
type Tree = Branch Tree Tree | INode (Optional ##Int) | BNode Boolean
```
This gives us a decl with two constructor types:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Integration test: transcript

```ucm:hide
``` ucm :hide
scratch/main> builtins.mergeio lib.builtins
scratch/main> load ./unison-src/transcripts-using-base/base.u
scratch/main> add
```

```unison
``` unison
use lib.builtins
unique type MyBool = MyTrue | MyFalse
Expand All @@ -33,7 +33,7 @@ main = do
_ -> ()
```

```ucm
``` ucm
scratch/main> add
scratch/main> compile main ./unison-cli-integration/integration-tests/IntegrationTests/main
```
6 changes: 3 additions & 3 deletions unison-cli/src/Unison/Codebase/Transcript/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ fenced = do
pure . Ucm hide err <$> (spaces *> P.manyTill ucmLine P.eof)
"unison" -> do
-- todo: this has to be more interesting
-- ```unison:hide
-- ```unison
-- ```unison:hide:all scratch.u
-- ``` unison :hide
-- ``` unison
-- ``` unison :hide:all scratch.u
hide <- lineToken hidden
err <- lineToken expectingError
fileName <- optional untilSpace1
Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/Codebase/Transcript/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime ucmVersion
scratchFileUpdates <- Q.flush ucmScratchFileUpdatesQueue
-- Push them onto the front stanza queue in the correct order.
for (reverse scratchFileUpdates) \(fp, contents) -> do
let fenceDescription = "unison:added-by-ucm " <> fp
let fenceDescription = "unison :added-by-ucm " <> fp
-- Output blocks for any scratch file updates the ucm block triggered.
Q.undequeue inputQueue (Left $ CMarkCodeBlock Nothing fenceDescription contents, Nothing)
awaitInput
Expand Down
6 changes: 3 additions & 3 deletions unison-cli/src/Unison/LSP/Completion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,18 @@ completionItemResolveHandler message respond = do
LD.TermReferent ref -> do
typ <- LSPQ.getTypeOfReferent fileUri ref
let renderedType = ": " <> (Text.pack $ TypePrinter.prettyStr (Just typeWidth) (PPED.suffixifiedPPE pped) typ)
let doc = toMarkup (Text.unlines $ ["```unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
let doc = toMarkup (Text.unlines $ ["``` unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
pure $ (completion {_detail = Just renderedType, _documentation = Just doc} :: CompletionItem)
LD.TypeReference ref ->
case ref of
Reference.Builtin {} -> do
let renderedBuiltin = ": <builtin>"
let doc = toMarkup (Text.unlines $ ["```unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
let doc = toMarkup (Text.unlines $ ["``` unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
pure $ (completion {_detail = Just renderedBuiltin, _documentation = Just doc} :: CompletionItem)
Reference.DerivedId refId -> do
decl <- LSPQ.getTypeDeclaration fileUri refId
let renderedDecl = ": " <> (Text.pack . Pretty.toPlain typeWidth . Pretty.syntaxToColor $ DeclPrinter.prettyDecl pped ref (HQ.NameOnly relativeName) decl)
let doc = toMarkup (Text.unlines $ ["```unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
let doc = toMarkup (Text.unlines $ ["``` unison", Name.toText fullyQualifiedName, "```"] ++ renderedDocs)
pure $ (completion {_detail = Just renderedDecl, _documentation = Just doc} :: CompletionItem)
_ -> empty
where
Expand Down
2 changes: 1 addition & 1 deletion unison-cli/src/Unison/LSP/Hover.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ hoverInfo uri pos =
(hoverInfoForRef <|> hoverInfoForLiteral)
where
markdownify :: Text -> Text
markdownify rendered = Text.unlines ["```unison", rendered, "```"]
markdownify rendered = Text.unlines ["``` unison", rendered, "```"]
prettyWidth :: Pretty.Width
prettyWidth = 40
hoverInfoForRef :: MaybeT Lsp Text
Expand Down
6 changes: 3 additions & 3 deletions unison-cli/tests/Unison/Test/ClearCache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ test = scope "clearWatchCache" $
Ucm.runTranscript
c
[i|
```ucm
``` ucm
scratch/main> alias.term ##Nat.+ +
```
```unison
``` unison
> 1 + 1
```
|]
Expand All @@ -37,7 +37,7 @@ test = scope "clearWatchCache" $
Ucm.runTranscript
c
[i|
```ucm
``` ucm
scratch/main> debug.clear-cache
```
|]
Expand Down
2 changes: 1 addition & 1 deletion unison-src/builtin-tests/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ otherwise it may reuse a previously cached codebase.
Thus, make sure the contents of this file define the contents of the cache
(e.g. don't pull `latest`.)

```ucm
``` ucm
scratch/main> pull @unison/base/releases/2.5.0 .base
scratch/main> builtins.mergeio
scratch/main> undo
Expand Down
6 changes: 3 additions & 3 deletions unison-src/builtin-tests/interpreter-tests.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ If you want to add or update tests, you can create a branch of that project, and

Before merging the PR on Github, we'll merge your branch on Share and restore `runtime_tests_version` to /main or maybe a release.

```ucm:hide:error
``` ucm :hide:error
scratch/main> this is a hack to trigger an error, in order to swallow any error on the next line.
scratch/main> we delete the project to avoid any merge conflicts or complaints from ucm.
scratch/main> delete.project runtime-tests
```
```ucm:hide
``` ucm :hide
scratch/main> clone ${runtime_tests_version} runtime-tests/selected
```

```ucm
``` ucm
runtime-tests/selected> run tests
runtime-tests/selected> run tests.interpreter.only
```
12 changes: 6 additions & 6 deletions unison-src/builtin-tests/jit-tests.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ If you want to add or update tests, you can create a branch of that project, and

Before merging the PR on Github, we'll merge your branch on Share and restore `runtime_tests_version` to /main or maybe a release.

```ucm:hide:error
``` ucm :hide:error
scratch/main> this is a hack to trigger an error, in order to swallow any error on the next line.
scratch/main> we delete the project to avoid any merge conflicts or complaints from ucm.
scratch/main> delete.project runtime-tests
```
```ucm:hide
``` ucm :hide
scratch/main> clone ${runtime_tests_version} runtime-tests/selected
```

```ucm
``` ucm
runtime-tests/selected> run.native tests
runtime-tests/selected> run.native tests.jit.only
```

Per Dan:
It's testing a flaw in how we were sending code from a scratch file to the native runtime, when that happened multiple times.
Related to the verifiable refs and recursive functions.
```unison
``` unison
foo = do
go : Nat ->{Exception} ()
go = cases
Expand All @@ -30,7 +30,7 @@ foo = do
go 1000
```

```ucm
``` ucm
scratch/main> run.native foo
scratch/main> run.native foo
```
Expand All @@ -39,6 +39,6 @@ This can also only be tested by separately running this test, because
it is exercising the protocol that ucm uses to talk to the jit during
an exception.

```ucm:error
``` ucm :error
runtime-tests/selected> run.native testBug
```
42 changes: 21 additions & 21 deletions unison-src/transcripts-manual/benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
```ucm:hide
``` ucm :hide
scratch/main> pull unison.public.base.releases.M4d base
scratch/main> pull runarorama.public.sort.data sort
```

```unison:hide
``` unison :hide
benchmarkFilePath = FilePath "unison-src/transcripts-manual/benchmarks/output.bench.txt"
archiveFilePath = FilePath "unison-src/transcripts-manual/benchmarks/output"
timeit : Text -> '{IO,Exception} a ->{IO,Exception} a
timeit label a =
timeit label a =
before = !realtime
r = !a
after = !realtime
elapsed = Duration.between before after
elapsedText = Duration.toText elapsed
go file =
go file =
putText file ("\n" ++ label ++ " " ++ Int.toText (Duration.countMicroseconds elapsed) ++ " # " ++ elapsedText)
printLine ("\n\n ******** \n")
printLine (label ++ " took " ++ elapsedText)
bracket '(FilePath.open benchmarkFilePath FileMode.Append) Handle.close go
r
prepare = do
-- if benchmarkFilePath exists, move it to blah-<datetime>.txt for archive purposes
prepare = do
-- if benchmarkFilePath exists, move it to blah-<datetime>.txt for archive purposes
use Text ++
if FilePath.exists benchmarkFilePath then
createDirectory archiveFilePath
now = OffsetDateTime.toText (atUTC !realtime)
timestamped = FilePath.toText archiveFilePath ++ "/" ++ now ++ "-bench.txt"
timestamped = FilePath.toText archiveFilePath ++ "/" ++ now ++ "-bench.txt"
renameFile benchmarkFilePath (FilePath timestamped)
else
else
()
```

```ucm:hide
``` ucm :hide
scratch/main> add
scratch/main> run prepare
```

## Benchmarks

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/each.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/listmap.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/listfilter.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/random.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/simpleloop.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/fibonacci.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/map.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/natmap.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/stm.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/tmap.u
scratch/main> run main
```

```ucm
``` ucm
scratch/main> load unison-src/transcripts-manual/benchmarks/array-sort.u
scratch/main> run main
```
```
6 changes: 3 additions & 3 deletions unison-src/transcripts-manual/docs.to-html.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
```ucm
``` ucm
test-html-docs/main> builtins.mergeio lib.builtins
```

```unison
``` unison
{{A doc directly in the namespace.}}
some.ns.direct = 1
Expand All @@ -13,7 +13,7 @@ some.ns.pretty.deeply.nested = 2
some.outside = 3
```

```ucm
``` ucm
test-html-docs/main> add
test-html-docs/main> docs.to-html some.ns unison-src/transcripts-manual/docs.to-html
```
7 changes: 3 additions & 4 deletions unison-src/transcripts-manual/gen-racket-libs.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

When we start out, `./scheme-libs/racket` contains a bunch of library files that we'll need. They define the Unison builtins for Racket.

Next, we'll download the jit project and generate a few Racket files from it.

```ucm
``` ucm
jit-setup/main> lib.install @unison/internal/releases/0.0.20
```

```unison
``` unison
go = generateSchemeBoot "scheme-libs/racket"
```

```ucm
``` ucm
jit-setup/main> run go
```

Expand Down
Loading

0 comments on commit 75c228f

Please sign in to comment.