Skip to content

Commit

Permalink
Update the API mirror of README
Browse files Browse the repository at this point in the history
Also add a note on VOCaml advantages (vs. code actions).
  • Loading branch information
lukstafi committed Mar 17, 2023
1 parent 04345f7 commit 0ce458c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 21 additions & 11 deletions index.mld
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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[
{
Expand All @@ -69,15 +73,21 @@ 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,
"restrictFind": "line",
}
}
]}
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.

0 comments on commit 0ce458c

Please sign in to comment.