Skip to content

Commit

Permalink
Attempt to register metadata.
Browse files Browse the repository at this point in the history
Haxe will display the documentation if you call `haxe --library echoes --help-user-metas` from the command line, but vshaxe still doesn't pick it up.
  • Loading branch information
player-03 committed Oct 20, 2024
1 parent 2c69110 commit cec7504
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
3 changes: 2 additions & 1 deletion extraParams.hxml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--macro echoes.macro.ComponentStorageBuilder.invalidate()
--macro echoes.macro.ComponentStorageBuilder.invalidate()
--macro echoes.macro.MacroTools.registerDescriptionFiles()
77 changes: 77 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"metadata": ":add",
"doc": "Makes a system function handle add events. The function will be called once an entity has the required components.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":echoes_add",
"doc": "Disambiguation alias for @:add.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":update",
"doc": "Makes a system function handle updates. Each update, it will be called for every entity that has the required components.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":echoes_update",
"doc": "Disambiguation alias for @:update.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":remove",
"doc": "Makes a system function handle remove events. The function will be called when an entity loses one of the required components, if it previously had all of them.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":echoes_remove",
"doc": "Disambiguation alias for @:remove.",
"targets": ["TClassField"],
"links": ["./README.md#usage"]
},
{
"metadata": ":echoes_replace",
"doc": "Marks a type so that when added to an entity, if it already had a component of that type, a remove event will be dispatched first.",
"targets": ["TAbstract", "TClass", "TEnum", "TTypedef"]
},
{
"metadata": ":priority",
"doc": "Sets the priority of a system or system function. Higher priorities happen first, and negative priorities are possible. The default priority is 0.",
"params": ["Integer"],
"targets": ["TClass", "TClassField"],
"links": ["./README.md#priority"]
},
{
"metadata": ":echoes_priority",
"doc": "Disambiguation alias for @:priority.",
"params": ["Integer"],
"targets": ["TClass", "TClassField"],
"links": ["./README.md#priority"]
},
{
"metadata": ":arguments",
"doc": "One or more component types to be taken as arguments in the entity template's constructor. Requires @:build(echoes.Entity.build()).",
"params": ["Type or type check"],
"targets": ["TAbstract"],
"links": ["./README.md#entity-templates", "./README.md#type-check-syntax"]
},
{
"metadata": ":optionalArguments",
"doc": "One or more component types to be taken as optional arguments in the entity template's constructor. Requires @:build(echoes.Entity.build()).",
"params": ["Type or type check"],
"targets": ["TAbstract"],
"links": ["./README.md#entity-templates", "./README.md#type-check-syntax"]
},
{
"metadata": ":echoes_storage",
"doc": "Sets the ComponentStorage instance used to store components of this type.",
"params": ["Constructor call or singleton instance"],
"targets": ["TAbstract", "TClass", "TEnum", "TTypedef"]
}
]
11 changes: 11 additions & 0 deletions src/echoes/macro/MacroTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package echoes.macro;
#if macro

import haxe.Exception;
import haxe.macro.Compiler;
import haxe.macro.Expr;
import haxe.macro.Printer;
import haxe.macro.Type;
Expand Down Expand Up @@ -213,6 +214,16 @@ class MacroTools {
}
}

public static function registerDescriptionFiles():Void {
var path:String = ((?infos:haxe.PosInfos) -> infos.fileName)();
if(!StringTools.endsWith(path, "src/echoes/macro/MacroTools.hx")) {
throw "MacroTools.hx moved, please update its path.";
}
path = path.substring(0, path.length - "src/echoes/macro/MacroTools.hx".length);

Compiler.registerMetadataDescriptionFile(path + "meta.json", "echoes");
}

/**
* Gets the underlying `BaseType`, if available.
*/
Expand Down

0 comments on commit cec7504

Please sign in to comment.