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

Allow custom builtin function to provide a description #6449

Closed
lcarva opened this issue Nov 30, 2023 · 2 comments
Closed

Allow custom builtin function to provide a description #6449

lcarva opened this issue Nov 30, 2023 · 2 comments

Comments

@lcarva
Copy link
Contributor

lcarva commented Nov 30, 2023

What is the underlying problem you're trying to solve?

I would like to generate documentation for the custom builtin rego function provided by a certain project, see example. To achieve this, I can iterate through the ast.Builtins slice to extract information about each function, such as name, args, and results. From that, I can format the data as needed. The limitation I'm having is not being able to set a description for the custom rego functions.

Describe the solution

When registering a builtin function, allow a description to be set, maybe here. So that custom builtin functions have the Description attribute set.

@lcarva
Copy link
Contributor Author

lcarva commented Nov 30, 2023

A workaround is to call ast.RegisterBuiltin directly, e.g.:

rego.RegisterBuiltin1(&decl, ...)
ast.RegisterBuiltin(&ast.Builtin{
    Name:             decl.Name,
    Description:      "My descripition",
    Decl:             decl.Decl,
    Nondeterministic: decl.Nondeterministic,
})

@ashutosh-narkar
Copy link
Member

Seems fine to update the Function struct and RegisterBuiltin* logic to include a description.

lcarva added a commit to lcarva/opa that referenced this issue Dec 1, 2023
Fixes: open-policy-agent#6449

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
lcarva added a commit to lcarva/opa that referenced this issue Dec 1, 2023
This allows processes, such as doc generation, to have additional
information about custom builtin functions.

Fixes: open-policy-agent#6449

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
lcarva added a commit to lcarva/opa that referenced this issue Dec 4, 2023
This allows processes, such as doc generation, to have additional
information about custom builtin functions.

Fixes: open-policy-agent#6449

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
lcarva added a commit to lcarva/opa that referenced this issue Dec 4, 2023
This allows processes, such as doc generation, to have additional
information about custom builtin functions.

Fixes: open-policy-agent#6449

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
lcarva added a commit to lcarva/opa that referenced this issue Dec 4, 2023
This allows processes, such as doc generation, to have additional
information about custom builtin functions.

Fixes: open-policy-agent#6449

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants