Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data_size not rendered through YARD #342

Open
erickguan opened this issue Jul 16, 2024 · 4 comments
Open

data_size not rendered through YARD #342

erickguan opened this issue Jul 16, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@erickguan
Copy link

Hey,

I have a feature request. In my work, I'm interested in knowing the memory usage of a WASM module. In particular, I want to expose https://docs.rs/wasmtime/latest/wasmtime/struct.Memory.html#method.data_size

I would simply have the same API in Ruby. Happy to contribute a PR.

@saulecabrera
Copy link
Member

Hi @erickguan, having that API surfaced in Ruby makes sense to me. Feel free to send a PR, I'll be happy to review it.

@erickguan
Copy link
Author

Sorry, I missed data_size function in the code. Memory has data_size. But YARD documentation doesn't have it.

image

I debugged a little. bundle exec rake doc generates JSON describing the methods but classes are not in doc. Doc generation from my machine:

image

@saulecabrera
Copy link
Member

That makes sense, thanks for debugging this. The doc rake task generates a json file with the documentation metadata. As far as I can tell, data_size is in there. I still need to figure out why it's not rendered though.

Screenshot 2024-07-19 at 3 10 32 PM

@saulecabrera saulecabrera added the bug Something isn't working label Jul 19, 2024
@saulecabrera saulecabrera changed the title Function reporting wasm module's memory usage data_size not rendered through YARD Jul 19, 2024
@erickguan
Copy link
Author

Does rust change this JSON format between last doc release? I poked my "fresh" environment:

require 'yard'
require 'yard-rustdoc'

json_data = File.read('tmp/doc/wasmtime_rb.json')
puts "Loaded JSON data: #{json_data[0..500]}" # print the first 500 characters to verify

YARD::Registry.load(['tmp/doc/wasmtime_rb.json'])

YARD::Registry.all.each do |obj|
  puts obj.inspect
end
Loaded JSON data: {"root":"0:0:1857","crate_version":"9.0.4","includes_private":true,"index":{"0:187:1036":{"id":"0:187:1036","crate_id":0,"name":"new","span":{"filename":"ext/src/ruby_api/config/tracked_memory_creator.rs","begin":[11,4],"end":[17,5]},"visibility":"crate","docs":null,"links":{},"attrs":[],"deprecation":null,"inner":{"function":{"decl":{"inputs":[["inner",{"resolved_path":{"name":"Box","id":"5:281:2329","args":{"angle_bracketed":{"args":[{"type":{"dyn_trait":{"traits":[{"trait":{"name":"RuntimeLine
#<yardoc module Wasmtime>
#<yardoc class Wasmtime::Error>
#<yardoc class Wasmtime::ResultError>
#<yardoc class Wasmtime::ConversionError>
#<yardoc class Wasmtime::Trap>
#<yardoc constant Wasmtime::Trap::STACK_OVERFLOW>
#<yardoc constant Wasmtime::Trap::MEMORY_OUT_OF_BOUNDS>
#<yardoc constant Wasmtime::Trap::HEAP_MISALIGNED>
#<yardoc constant Wasmtime::Trap::TABLE_OUT_OF_BOUNDS>
#<yardoc constant Wasmtime::Trap::INDIRECT_CALL_TO_NULL>
#<yardoc constant Wasmtime::Trap::BAD_SIGNATURE>
#<yardoc constant Wasmtime::Trap::INTEGER_OVERFLOW>
#<yardoc constant Wasmtime::Trap::INTEGER_DIVISION_BY_ZERO>
#<yardoc constant Wasmtime::Trap::BAD_CONVERSION_TO_INTEGER>
#<yardoc constant Wasmtime::Trap::UNREACHABLE_CODE_REACHED>
#<yardoc constant Wasmtime::Trap::INTERRUPT>
#<yardoc constant Wasmtime::Trap::ALWAYS_TRAP_ADAPTER>
#<yardoc constant Wasmtime::Trap::OUT_OF_FUEL>
#<yardoc constant Wasmtime::Trap::UNKNOWN>
#<yardoc class Wasmtime::WasiExit>
#<yardoc method Wasmtime::WasiExit#code>
#<yardoc method Wasmtime::WasiExit#initialize>
#<yardoc method Wasmtime::WasiExit#message>
#<yardoc constant Wasmtime::VERSION>

I would suspect yard-rustdoc might trailing behind. Maybe validate firstly if rust doc had an update. And perhaps write an issue if rust json doc update cause the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants