From 054d1090cfb27465ff4b25d9885d572e6f326656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=E9=87=91=E5=8F=AF=E6=98=8E?= Date: Sun, 10 Sep 2023 17:24:27 +0200 Subject: [PATCH 1/3] fix(rust): handle destructured params case (#617) --- helper/src/rust/parser.rs | 14 +++++++++----- test/filetypes/rust/functions.vader | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/helper/src/rust/parser.rs b/helper/src/rust/parser.rs index 63cbbfcb..20d604a8 100644 --- a/helper/src/rust/parser.rs +++ b/helper/src/rust/parser.rs @@ -100,15 +100,19 @@ impl<'a> RustParser<'a> { .for_each(|node| { let mut param = Map::new(); - let func_name = node + let name = node .children(&mut node.walk()) .filter(|node| node.kind() == "identifier") .next() - .and_then(|node| Some(self.get_node_text(&node))) - .unwrap(); - param.insert("name".to_string(), Value::String(func_name)); + .and_then(|node| Some(self.get_node_text(&node))); - params.push(Value::Object(param)); + if name.is_some() { + param.insert("name".to_string(), Value::String(name.unwrap())); + } + + if !param.is_empty() { + params.push(Value::Object(param)); + } }); if !params.is_empty() { diff --git a/test/filetypes/rust/functions.vader b/test/filetypes/rust/functions.vader index 7539300e..a151808c 100644 --- a/test/filetypes/rust/functions.vader +++ b/test/filetypes/rust/functions.vader @@ -59,6 +59,29 @@ Expect rust (generated comments with Arguments and Examples sections): } } +# ============================================================================== +# Functions parameter destruction +# ============================================================================== +Given rust (function with destructured params): + pub fn do_thing((i, j): (u8, u8)) -> u8 { + i * j + } + +Do (trigger doge): + \ + +Expect rust (generated comments): + /// [TODO:description] + /// + /// # Examples + /// + /// ``` + /// [TODO:write some example code] + /// ``` + pub fn do_thing((i, j): (u8, u8)) -> u8 { + i * j + } + # ============================================================================== # Functions with errors and safety section # ============================================================================== From 0cdce59caae8e94077e0320bdaf9680049643dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=E9=87=91=E5=8F=AF=E6=98=8E?= Date: Sun, 10 Sep 2023 18:14:15 +0200 Subject: [PATCH 2/3] chore(workflow/tests): use vim v9.0.150 instead of head --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5329b4d7..82abe9cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - vim-version: [v7.4.2119, v8.2.5172, head] + vim-version: [v7.4.2119, v8.2.5172, v9.0.150] runs-on: ${{ matrix.os }} steps: - name: Checkout kkoomen/vim-doge From 90cd80a491a5ee43c9012aa1fc8d89652ce62baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=E9=87=91=E5=8F=AF=E6=98=8E?= Date: Sun, 10 Sep 2023 18:22:01 +0200 Subject: [PATCH 3/3] chore(workflow/tests): add missing zero --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 82abe9cc..08bd9089 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - vim-version: [v7.4.2119, v8.2.5172, v9.0.150] + vim-version: [v7.4.2119, v8.2.5172, v9.0.1500] runs-on: ${{ matrix.os }} steps: - name: Checkout kkoomen/vim-doge