Skip to content

feat: support doc comments in Candid bindings generator#640

Merged
ilbertt merged 6 commits into
masterfrom
luca/SDK-2211-doc-comments-candid
Jul 10, 2025
Merged

feat: support doc comments in Candid bindings generator#640
ilbertt merged 6 commits into
masterfrom
luca/SDK-2211-doc-comments-candid

Conversation

@ilbertt

@ilbertt ilbertt commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Overview
Adds support for doc comments in the Candid bindings generator.

@ilbertt ilbertt requested a review from a team as a code owner July 10, 2025 09:36
Comment thread rust/candid_parser/tests/assets/ok/example.d.ts
Comment thread rust/candid_parser/tests/assets/ok/example.js
Comment thread rust/candid_parser/tests/assets/ok/example.mo
Comment thread rust/candid_parser/tests/assets/ok/example.rs
Comment thread rust/candid_parser/src/bindings/typescript.rs
Comment thread rust/candid_parser/src/bindings/motoko.rs
@github-actions

github-actions Bot commented Jul 10, 2025

Copy link
Copy Markdown
Name Max Mem (Kb) Encode Decode
blob 4_224 4_206_559 ($\textcolor{red}{0.00\%}$) 2_121_065 ($\textcolor{red}{0.00\%}$)
btreemap 75_456 4_261_360_630 ($\textcolor{red}{0.00\%}$) 15_241_691_028 ($\textcolor{red}{0.33\%}$)
nns 192 1_966_455 ($\textcolor{red}{0.00\%}$) 5_474_107 ($\textcolor{red}{0.23\%}$)
nns_list_proposal 1_088 6_814_372 ($\textcolor{red}{0.04\%}$) 67_872_454 ($\textcolor{red}{1.31\%}$)
option_list 128 7_481_063 ($\textcolor{red}{0.00\%}$) 25_776_931 ($\textcolor{red}{0.96\%}$)
text 6_336 4_203_506 ($\textcolor{red}{0.00\%}$) 7_877_229 ($\textcolor{red}{0.00\%}$)
variant_list 128 7_537_258 ($\textcolor{red}{0.01\%}$) 24_342_804 ($\textcolor{red}{1.27\%}$)
vec_int16 16_704 123_693_002 ($\textcolor{red}{0.00\%}$) 1_069_570_587 ($\textcolor{red}{4.94\%}$)
  • Parser cost: 15_218_740 ($\textcolor{red}{0.00\%}$)
  • Extra args: 3_146_907 ($\textcolor{green}{-0.58\%}$)
Click to see raw report
---------------------------------------------------

Benchmark: blob
  total:
    instructions: 6.33 M (0.00%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.21 M (0.00%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 2.12 M (0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: text
  total:
    instructions: 12.08 M (0.00%) (change within noise threshold)
    heap_increase: 99 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.20 M (0.00%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 7.88 M (0.00%) (change within noise threshold)
    heap_increase: 33 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: vec_int16
  total:
    instructions: 1.19 B (regressed by 4.40%)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 123.69 M (0.00%) (change within noise threshold)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 1.07 B (regressed by 4.94%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: btreemap
  total:
    instructions: 19.50 B (0.26%) (change within noise threshold)
    heap_increase: 1179 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.26 B (0.00%) (change within noise threshold)
    heap_increase: 159 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 15.24 B (0.33%) (change within noise threshold)
    heap_increase: 1020 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: option_list
  total:
    instructions: 33.26 M (0.74%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.48 M (0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 25.78 M (0.96%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: variant_list
  total:
    instructions: 31.88 M (0.97%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.54 M (0.01%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 24.34 M (1.27%) (change within noise threshold)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns
  total:
    instructions: 23.50 M (0.06%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  0. Parsing (scope):
    calls: 1 (no change)
    instructions: 15.22 M (0.00%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 1.97 M (0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 5.47 M (0.23%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns_list_proposal
  total:
    instructions: 74.69 M (1.19%) (change within noise threshold)
    heap_increase: 17 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 6.81 M (0.04%) (change within noise threshold)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 67.87 M (1.31%) (change within noise threshold)
    heap_increase: 14 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: extra_args
  total:
    instructions: 3.15 M (-0.58%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Summary:
  instructions:
    status:   Regressions detected 🔴
    counts:   [total 9 | regressed 1 | improved 0 | new 0 | unchanged 8]
    change:   [max +50.33M | p75 +878.74K | median +245.85K | p25 +30 | min -18.49K]
    change %: [max +4.40% | p75 +0.97% | median +0.26% | p25 0.00% | min -0.58%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 9 | regressed 0 | improved 0 | new 0 | unchanged 9]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 9 | regressed 0 | improved 0 | new 0 | unchanged 9]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------

Only significant changes:
| status | name                   | calls |   ins |  ins Δ% |  HI |  HI Δ% | SMI |  SMI Δ% |
|--------|------------------------|-------|-------|---------|-----|--------|-----|---------|
|   +    | vec_int16::2. Decoding |     1 | 1.07B |  +4.94% |   0 |  0.00% |   0 |   0.00% |
|   +    | vec_int16              |       | 1.19B |  +4.40% | 261 |  0.00% |   0 |   0.00% |

ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change

---------------------------------------------------
Successfully persisted results to canbench_results.yml

Comment thread rust/candid_parser/tests/assets/example.did
@ilbertt ilbertt force-pushed the luca/SDK-2211-doc-comments-candid branch from fe36371 to bb7f4db Compare July 10, 2025 10:39
Comment thread rust/candid/src/pretty/candid.rs

@christoph-dfinity christoph-dfinity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@ilbertt ilbertt merged commit e4ee1c6 into master Jul 10, 2025
11 checks passed
@ilbertt ilbertt deleted the luca/SDK-2211-doc-comments-candid branch July 10, 2025 15:51
ilbertt added a commit that referenced this pull request Jul 14, 2025
Describes the changes from the following PRs:
- #637
- #638
- #640
- #641
@ilbertt ilbertt mentioned this pull request Jul 14, 2025
ilbertt added a commit that referenced this pull request Jul 14, 2025
**Overview**
Describes the changes from the following PRs:
- #637
- #638
- #640
- #641
ilbertt added a commit that referenced this pull request Jul 14, 2025
Describes the changes from the following PRs:
- #637
- #638
- #640
- #641
@ilbertt ilbertt mentioned this pull request Jul 14, 2025
ilbertt added a commit that referenced this pull request Jul 14, 2025
**Overview**
Describes the changes from the following PRs:
- #637
- #638
- #640
- #641
lwshang added a commit that referenced this pull request Jul 25, 2025
…ate (#652)

This PR refactors recent changes (#612 and #640) to avoid a major
version bump in `candid` crate.
> * Breaking changes:
> + `pp_args` and `pp_init_args` now require a `&[ArgType]` parameter.
The `pp_rets` function has been added, with the signature of the old
`pp_args`.
> + `pretty::candid::pp_label` now takes a `&Label` parameter, instead
of a `&SharedLabel`.


The previously altered API (`pp_args`, `pp_init_args`, `pp_label`) has
been restored to maintain backward compatibility.

The intended new behavior is now exposed via new, non-breaking methods:
`pp_named_args`, `pp_named_init_args` and `pp_label_raw`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants