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

spec: clarify file versus package attributes with examples #3683

Open
mvdan opened this issue Jan 16, 2025 · 0 comments
Open

spec: clarify file versus package attributes with examples #3683

mvdan opened this issue Jan 16, 2025 · 0 comments

Comments

@mvdan
Copy link
Member

mvdan commented Jan 16, 2025

CUE currently supports attributes attached to just one file, such as:

@extern(embed)

package foo

a: _ @embed(file=foo.json)

Here, @extern(embed) only affects its file, and not any other files part of the same instance of package foo.

Any top-level attributes after a package clause (or without a package clause) are attached to the package (or rather its instance), so they do get unified as part of it and affect all other files which are part of the same instance. For example:

package foo

@go(some_go_code_generation_option)

Here, the attribute will affect how e.g. cue exp gengotypes generates Go code for the entire CUE package instance.

https://cuelang.org/docs/reference/spec/#attributes needs to be expanded; it currently only explains package attributes, showing one brief example. It needs to explain file-scoped attributes too, and show an example of them too.

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

1 participant