Skip to content
New issue

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

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

Already on GitHub? # 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.
@mrwilson mrwilson force-pushed the expose-defs-in-modulemeta branch from bce7275 to 0b3ab2f Compare August 12, 2023 11:56
@mrwilson mrwilson force-pushed the expose-defs-in-modulemeta branch from 0b3ab2f to 91315d3 Compare August 12, 2023 12:12
@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
@mrwilson mrwilson deleted the expose-defs-in-modulemeta branch August 14, 2023 08:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants