From 0ce458c3e7e08e65f3517e09ff5de53e24bec85d Mon Sep 17 00:00:00 2001 From: lukstafi Date: Fri, 17 Mar 2023 12:28:59 +0100 Subject: [PATCH] Update the API mirror of README Also add a note on VOCaml advantages (vs. code actions). --- README.md | 2 ++ dune-project | 2 +- index.mld | 32 +++++++++++++++++++++----------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a507b0c..eec84fb 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,8 @@ The `PrintBox` logs are the prettiest, I could not get the `Format`-functor-base [VOCaml helpers for coding in OCaml](https://marketplace.visualstudio.com/items?itemName=lukstafi.vocaml) provide commands to add and remove annotations on selected bindings. They can be used to introduce logging, tune it, and cleanup afterward. It also has a command to populate the _Quick Open_ dialog with a file name and location from a line under cursor. It can be used to jump to the source code from a log file. +Note that you can add and remove type annotations using VSCode OCaml Platform's code actions, and the _Find and Transform_ suggestion below is a more flexible go-to-file solution -- so VOCaml is somewhat redundant. But, it is still valuable: (1) it annotates multiple `let`-bindings at once in a selection, and (2) it annotates the argument types and the return type of a function (as required by `ppx_debug`) when invoked on a function definition. + ### Visualize the flame graph using [Log Inspector](https://marketplace.visualstudio.com/items?itemName=lukstafi.loginspector-submillisecond) [Log Inspector (sub-millisecond)](https://marketplace.visualstudio.com/items?itemName=lukstafi.loginspector-submillisecond)'s main feature is visualizing timestamped logs as flame graphs. To invoke it in VS Code, go to a `Minidebug_runtime.Flushing`-style logs file, press `crtl+shift+P`, and execute the command "Log Inspector: Draw". Example effect: diff --git a/dune-project b/dune-project index ae4be46..34c9f0d 100644 --- a/dune-project +++ b/dune-project @@ -15,7 +15,7 @@ (documentation https://github.com/lukstafi/ppx_minidebug/blob/main/README.md) -(version 0.1.2) +(version 0.1.3) (package (name ppx_minidebug) diff --git a/index.mld b/index.mld index de317fc..168d9c1 100644 --- a/index.mld +++ b/index.mld @@ -43,9 +43,13 @@ let%debug_show test_logging: string = "Hello World" {2 VS Code suggestions} -{3 Visualize the flame graph using - {{:https://marketplace.visualstudio.com/items?itemName=lukstafi.loginspector-submillisecond} - Log Inspector}} +{3 Add / remove type annotations and visit files using {e VOCaml}} + +{{:https://marketplace.visualstudio.com/items?itemName=lukstafi.vocaml}VOCaml helpers for coding in OCaml} provide commands to add and remove annotations on selected bindings. They can be used to introduce logging, tune it, and cleanup afterward. It also has a command to populate the _Quick Open_ dialog with a file name and location from a line under cursor. It can be used to jump to the source code from a log file. + +Note that you can add and remove type annotations using VSCode OCaml Platform's code actions, and the {e Find and Transform} suggestion below is a more flexible go-to-file solution -- so VOCaml is somewhat redundant. But, it is still valuable: (1) it annotates multiple [let]-bindings at once in a selection, and (2) it annotates the argument types and the return type of a function (as required by [ppx_debug]) when invoked on a function definition. + +{3 Visualize the flame graph using {e Log Inspector}} {{:https://marketplace.visualstudio.com/items?itemName=lukstafi.loginspector-submillisecond} Log Inspector (sub-millisecond)}'s main feature is visualizing timestamped logs as flame graphs. @@ -55,12 +59,12 @@ and execute the command {e Log Inspector: Draw}. Note that {{:https://marketplace.visualstudio.com/items?itemName=lukstafi.loginspector-submillisecond} Log Inspector (sub-millisecond)} is a forked variant of the Log Inspector extension. -{3 Go to file location using -{{:https://marketplace.visualstudio.com/items?itemName=ArturoDent.find-and-transform}Find and Transform}} +{3 Go to file location using {e Find and Transform}} + +This will expand your general-purpose VS Code toolbox! {{:https://marketplace.visualstudio.com/items?itemName=ArturoDent.find-and-transform}Find and Transform} -is a powerful VS Code extension, so there might be easier ways to accomplish this, but it gets -the job done. I put the following in my `keybindings.json` file (command: {e Open Keyboard Shortcuts +is a powerful VS Code extension. I put the following in my `keybindings.json` file (command: {e Open Keyboard Shortcuts (JSON)}): {@json[ { @@ -69,10 +73,16 @@ the job done. I put the following in my `keybindings.json` file (command: {e Ope "args": { "description": "Open file at cursor", "find": "\"([^\"]+)\":([0-9]+)", - "replace": [ + "run": [ "$${", - "vscode.commands.executeCommand('workbench.action.quickOpen', `$1:$2`);", - "return '\\\"$1\\\":$2';", + "const pos = new vscode.Position($2, 0);", + "const range = new vscode.Range(pos, pos);", + "const options = {selection: range};", + "const wsFolderUri = vscode.workspace.workspaceFolders[0].uri;", + "const uri = await vscode.Uri.joinPath(wsFolderUri, '$1');", + "await vscode.commands.executeCommand('vscode.open', uri, options);", + + // "await vscode.commands.executeCommand('workbench.action.quickOpen', `$1:$2`);", "}$$", ], "isRegex": true, @@ -80,4 +90,4 @@ the job done. I put the following in my `keybindings.json` file (command: {e Ope } } ]} -Then, pressing `alt+q` will open a pre-populated dialog, and `enter` will get me to the file location. +Then, pressing `alt+q` will open a pre-populated dialog, and `enter` will get me to the file location. The file-and-location detection above matches the default one from the [Flushing] module, you can adjust the [find] pattern to match other formats.