From a18cc36e8dde913135a7739c333bf3d80e48d0ec Mon Sep 17 00:00:00 2001 From: sharkAndshark Date: Mon, 10 Feb 2025 16:33:32 +0800 Subject: [PATCH 1/2] add doc about debugging --- docs/src/SUMMARY.md | 1 + docs/src/getting-involved.md | 114 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 docs/src/getting-involved.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index f644ffb93..ea833c85d 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -39,4 +39,5 @@ - [Diffing/Patching MBTiles](mbtiles-diff.md) - [Validating MBTiles](mbtiles-validation.md) - [Development](development.md) + - [Getting involved](getting-involved.md) - [Martin as a library](martin-as-a-library.md) diff --git a/docs/src/getting-involved.md b/docs/src/getting-involved.md new file mode 100644 index 000000000..3797591ee --- /dev/null +++ b/docs/src/getting-involved.md @@ -0,0 +1,114 @@ +# Getting involved + +It's time to getting involved once you have the [fork and all required softwares](development.md). + +We souppose you are working on Ubuntu(Or WSL) with Visual Studio Code in this post. + +## Editor Plugins + +Install plugins below: +* [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) +* [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) + +## Debugging into with `launch.json` + +Generally you need to debug martin with specific arguments or config file to fix issue or add feature. + +The most convenient way is to generate a lanunch.json and modify it. + +## Generate + +Press `F1` on your keyboard, and input "Generate Launch Configurations from Cargo.toml". Execute it and save it to your `.vscode` directory. + +## Modify + +Let's say you want to debugging Martin with this command: +```shell +martin postgres://postgres:postgres@localhost:5411/db --default-srid 4490 +``` + +You could find `Debug executable 'martin'` in your `launch.json`, like below: +```json + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'martin'", + "cargo": { + "args": [ + "build", + "--bin=martin", + "--package=martin" + ], + "filter": { + "name": "martin", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, +``` + +Just copy and paste after it, and modify your pasted like this: + +```json + { + "type": "lldb", + "request": "launch", + "name": "my first debug", // name it any as you like + "cargo": { + "args": [ + "build", + "--bin=martin", + "--package=martin" + ], + "filter": { + "name": "martin", + "kind": "bin" + } + }, + "args": ["postgres://postgres:postgres@localhost:5411/db"], // add your arguments here + "env": { + "DEFAULT_SRID": 4490, // add your env here + }, + "cwd": "${workspaceFolder}" + }, +``` + +### Add a breakpoint + +Go to any part you interested in of martin code and add a breakpoint. + +We add a breakpoint here in the [start of martin](https://github.com/maplibre/martin/blob/e628c3973f193a432d3d1282c5893e2339e806b6/martin/src/bin/martin.rs#L10). + +```rust +use clap::Parser; +use log::{error, info, log_enabled}; +use martin::args::{Args, OsEnv}; +use martin::srv::new_server; +use martin::{read_config, Config, MartinResult}; + +const VERSION: &str = env!("CARGO_PKG_VERSION"); + +async fn start(args: Args) -> MartinResult<()> { + info!("Starting Martin v{VERSION}"); +``` + +### Debugging + +Click the `Run and Debug` on the left panel of `Visual Studio Code`. Choose `my first debug`. And Press `F5` on your keyboard. + +Wait the breakpoint get hitted. + + +## Working with Just + + +//todo + + + + + + + From 43cb4da098de6a15c182ef42acb9eb8f598b86de Mon Sep 17 00:00:00 2001 From: sharkAndshark Date: Mon, 10 Feb 2025 16:35:52 +0800 Subject: [PATCH 2/2] typo --- docs/src/getting-involved.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/src/getting-involved.md b/docs/src/getting-involved.md index 3797591ee..0f614c153 100644 --- a/docs/src/getting-involved.md +++ b/docs/src/getting-involved.md @@ -1,8 +1,8 @@ # Getting involved -It's time to getting involved once you have the [fork and all required softwares](development.md). +It's time to get involved once you have the [fork and all required software](development.md). -We souppose you are working on Ubuntu(Or WSL) with Visual Studio Code in this post. +We assume you are working on Ubuntu (or WSL) with Visual Studio Code in this post. ## Editor Plugins @@ -10,11 +10,11 @@ Install plugins below: * [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) * [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) -## Debugging into with `launch.json` +## Debugging with `launch.json` -Generally you need to debug martin with specific arguments or config file to fix issue or add feature. +Generally, you need to debug martin with specific arguments or a config file to fix issues or add features. -The most convenient way is to generate a lanunch.json and modify it. +The most convenient way is to generate a launch.json and modify it. ## Generate @@ -77,7 +77,7 @@ Just copy and paste after it, and modify your pasted like this: ### Add a breakpoint -Go to any part you interested in of martin code and add a breakpoint. +Go to any part you're interested in of martin code and add a breakpoint. We add a breakpoint here in the [start of martin](https://github.com/maplibre/martin/blob/e628c3973f193a432d3d1282c5893e2339e806b6/martin/src/bin/martin.rs#L10). @@ -96,9 +96,9 @@ async fn start(args: Args) -> MartinResult<()> { ### Debugging -Click the `Run and Debug` on the left panel of `Visual Studio Code`. Choose `my first debug`. And Press `F5` on your keyboard. +Click `Run and Debug` on the left panel of `Visual Studio Code`. Choose `my first debug` and press `F5` on your keyboard. -Wait the breakpoint get hitted. +Wait for the breakpoint to be hit. ## Working with Just