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

Expose a module's function names in modulemeta #2837

Merged
merged 2 commits into from
Aug 13, 2023

Conversation

mrwilson
Copy link
Contributor

This PR adds a new field, defs, to the output of modulemeta.

This field contains the names and arities of functions defined within that module. For example

module {
  name: "example",
  version: "0.0.0"
};

def foo(): 1;
def bar($baz): $baz + 1;
$ jq -L. --null-input '"example" | modulemeta | .defs[]'

"foo/0"
"bar/1"

The intent of this change is to make it easier for tools / processes built on top of jq to introspect about function definitions within the modules.

This reuses the existing `block_list_funcs` capability and adds an extra field on the `modulemeta` output, called `defs`, containing that list of functions.
@nicowilliams
Copy link
Contributor

Do we want to also list the module's $bindings, if any?

@nicowilliams nicowilliams self-requested a review August 13, 2023 01:46
@nicowilliams
Copy link
Contributor

Thanks!

@nicowilliams nicowilliams merged commit f31c180 into jqlang:master Aug 13, 2023
29 checks passed
@mrwilson mrwilson deleted the expose-defs-in-modulemeta branch August 14, 2023 08:39
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.

None yet

2 participants