Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/macro/macroApi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1369,10 +1369,11 @@ let decode_type_def v =
let pos = decode_pos (field v "pos") in
let isExtern = decode_opt_bool (field v "isExtern") in
let fields = List.map decode_field (decode_array (field v "fields")) in
let doc = opt decode_string (field v "doc") in
let mk fl dl =
{
d_name = name;
d_doc = None;
d_doc = doc;
d_params = decode_tparams (field v "params");
d_meta = meta;
d_flags = fl;
Expand Down
6 changes: 6 additions & 0 deletions std/haxe/macro/Expr.hx
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,12 @@ typedef TypeDefinition = {
**/
var name : String;

/**
The documentation of the type, if available. If the type has no
documentation, the value is `null`.
**/
@:optional var doc : Null<String>;

/**
The position to the type definition.
**/
Expand Down
1 change: 1 addition & 0 deletions std/haxe/macro/Printer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class Printer {

var str = t == null ? "#NULL" :
(printPackage && t.pack.length > 0 && t.pack[0] != "" ? "package " + t.pack.join(".") + ";\n" : "") +
(t.doc != null && t.doc != "" ? "/**\n" + tabString + StringTools.replace(t.doc, "\n", "\n" + tabString) + "\n**/\n" : "") +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the documentation itself hold tab information too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, i guess not, because i copy-pasted that from the field doc output code, so it's consistent with the field doc behaviour.

(t.meta != null && t.meta.length > 0 ? t.meta.map(printMetadata).join(" ") + " " : "") + (t.isExtern ? "extern " : "") + switch (t.kind) {
case TDEnum:
"enum " + t.name + ((t.params != null && t.params.length > 0) ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " {\n"
Expand Down