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

website: auto-generate builtin documentation from source (incl. examples) #4623

Open
srenatus opened this issue Apr 26, 2022 · 2 comments
Open

Comments

@srenatus
Copy link
Contributor

With #4080 giving us named arguments, we can use that information to autogenerate docs for the function arguments, incl descriptions, on the website.

This could look like the folllowing:

a. named args and descriptions are added to ast.Builtin (or so) via #4080
b. it becomes part of the capabilities.json
c. the website build is modified to read the capabilities.json (copied into website/data) and uses that to render built-in function headers

In a similar way, examples could be added to the website docs.

One approach here would be to use rego files with metadata, like

package examples.builtins["io.jwt.decode_verify"]

# METADATA
# description: |
#   When used in a simple case, io.jwt.decode_verify does this and that.
test_simple {
  jwt := "..."
  criteria := { }
  io.jwt.decode_verify(jwt, criteria) == { ... }
}

# METADATA
# description: To check issuer, the `iss` criterium needs to be provided
test_issuer {
  # ...
}

A helper golang script would read those, and generate some markdown stubs from them, to be included (manually, per-builtin, via shortcodes, maybe?) in the policy-reference.

This way, we should be able to gradually shift the content from the current unstructured markdown format to the in-code Builtin structures, and the example rego files.

Additionally, a CI job would run opa test on those examples.

Related: #2650.

@stale
Copy link

stale bot commented May 26, 2022

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale
Copy link

stale bot commented Apr 7, 2023

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Apr 7, 2023
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