rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 84 forks source link

Allow to iteration over functions available in loaded source #535

Open ModProg opened 1 year ago

ModProg commented 1 year ago

This existed: https://docs.rs/rune/latest/rune/runtime/struct.Unit.html#method.iter_functions but I think was made private.

I'm writing a "wrapper" that allows using public functions as subcommands, I can use lookup_function to check if a function exists, but I cannot print any helpful lists of availible messages.

udoprog commented 1 year ago

I don't mind much making it public, but it's being changed heavily now in relation to runedoc, so it might not be suitable for public consumption in its current iteration.

You can also collect function hashes by using a visitor, like rune test and rune bench does it.

ModProg commented 1 year ago

Access to doc comments would be the next helpful thing, I'm not pressed on having it ASAP as I'm still very much in the beginning of my scripting tool and the happy path is working great (thanks for rune btw).

udoprog commented 1 year ago

You got it!

The best way to access comments consistently right now would be to at some point make doc::Context public. It provides a unified API over compiled sources and the native context.