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

Custom metadata and defines (documentation, completion) #10858

Merged
merged 31 commits into from
Nov 29, 2022

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Nov 19, 2022

See #10844

Note: can also make use of HaxeFoundation/haxelib#573 so that libs can declare files similar to our own meta.json / define.json files directly in their haxelib.json.


Allows user (and mostly libs) to declare their custom medatada and defines in a similar way as we do with meta.json and define.json, so that editors can provide completion / documentation for those.

Adds 4 haxe.macro.Compiler endpoints:

Adds two haxe compiler arguments:

  • --help-user-metas to display user-defined metadata documentation for current compilation context
  • --help-user-defines to display user-defined defines documentation for current compilation context

Example usage (with partial documentation; can also use a build.hxml file and grab documentation from libs):

$ haxe -lib react-next --help-user-metas
 @:noPublicProps: Disallow public props for this component when used in jsx.
                  (from react-next)
 @:publicProps  : (<TProps>) Set public props type to ensure jsx type checking.
                  (from react-next)
 @:wrap         : (<HOC>) Wrap current class component in a HOC. (from react-next)
$ haxe -lib react-next --help-user-defines
 react-global          : Use window.React instead of require() from
                         modular/webpack. (from react-next)
 react-hot             : Adds some data needed for react hot reloading with
                         modular/webpack. (from react-next)
 react-no-inline       : Skip React.createElement inlining optimization.
                         (from react-next)
 react-runtime-warnings: Enable some runtime warnings for debug purpose.
                         (from react-next)

There are likely things that could be written in a better way, have a better name, etc.
Please give some feedback :)

src/core/define.ml Outdated Show resolved Hide resolved
src/core/meta.ml Outdated Show resolved Hide resolved
src/macro/macroApi.ml Outdated Show resolved Hide resolved
src/core/meta.ml Outdated Show resolved Hide resolved
@Gama11
Copy link
Member

Gama11 commented Nov 20, 2022

Haven't checked the code, so maybe you already did this, but: There should probably be some flag in the display API to tell apart custom defines / metas from built-in ones, so the editor can choose to render them a bit differently.

Actually, even better, maybe some kind of origin field, which could be a library name for instance, so the editor can show from which library a meta originates.

@skial skial mentioned this pull request Nov 23, 2022
1 task
@kLabz kLabz force-pushed the feature/custom-meta-and-defines branch from 34a8b1d to 8eb1278 Compare November 23, 2022 18:44
src/macro/macroApi.ml Outdated Show resolved Hide resolved
src/core/meta.ml Outdated Show resolved Hide resolved
@kLabz kLabz force-pushed the feature/custom-meta-and-defines branch from 79f7a1c to 82814a9 Compare November 27, 2022 22:22
@Simn Simn merged commit 13a8e48 into HaxeFoundation:development Nov 29, 2022
@Simn
Copy link
Member

Simn commented Nov 29, 2022

Thank you, and good job! This is a really neat addition.

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

Successfully merging this pull request may close these issues.

3 participants