HaxeFoundation / HaxeFoundation/haxe

[MACRO] Allow macros to modify class documentation

Open
#11,409 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

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:

```haxe
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 `Ref`s 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.