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

[MACRO] Allow macros to modify class documentation #11409

Open
EliteMasterEric opened this issue Nov 24, 2023 · 2 comments
Open

[MACRO] Allow macros to modify class documentation #11409

EliteMasterEric opened this issue Nov 24, 2023 · 2 comments

Comments

@EliteMasterEric
Copy link
Contributor

EliteMasterEric commented Nov 24, 2023

In my attempt to develop a macro which injects documentation into indicated classes and fields, I have not found a means that the former is currently possible.

I tried the obvious, assigning directly inside a build macro:

var cls:ClassType = Context.getLocalClass().get();
cls.doc = "Hello, world!"

This does not function as I would hope (it works great for fields though). The assignment has no effect since I am modifying the response from Ref.get(), not the class itself.

When using an initialization macro, onAfterGenerate and onAfterInitMacros have no access to the classes, while onGenerate and onAfterTyping only provide Refs to the classes. MetadataAccess is provided to inject metadata at this stage, and build macros can be used to modify fields of those types completely, but I have found no means to inject documentation onto the class itself.

Either a dedicated means of injecting class documentation, a built-in compiler metadata which takes documentation to apply as an argument, or a workaround to this issue that I"m overlooking, any of these would be greatly appreciated.

@Simn
Copy link
Member

Simn commented Nov 24, 2023

I"m guessing you want this as a solution to #11375, but running a build macro on everything for this purpose seems really slow and impractical. But at the very least we should make it clear in the documentation that modifying these values has no effect on the internal class instance.

@EliteMasterEric
Copy link
Contributor Author

An alternative could be some metadata like @:doc("Hello, world!") which concatenates metadata to the field, and otherwise acts like @:inheritDoc. That would allow applying documentation via build macro as well, unless the mechanism behind @:inheritDoc is also impractical.

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

No branches or pull requests

2 participants