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

haxe.macro.ClassType.doc and haxe.macro.ClassField.doc are always null #7493

Closed
bary12 opened this Issue Sep 29, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@bary12

bary12 commented Sep 29, 2018

(Haxe 3.4.7)

I'm trying to get the docstring of classes and fields in Context.onAfterTyping, but ClassType.doc and ClassField.doc are always null. For example:

Macro.hx

#if macro
import haxe.macro.Type;
import haxe.macro.Context;
#end

class Macro {
    #if macro
    public static function use() {
        Context.onAfterTyping(function(modules: Array<ModuleType>) {
            for (module in modules) {
                switch(module) {
                    case TClassDecl(classRef):
                        var cls = classRef.get();
                        trace('${cls.name}: ${cls.doc}');
                    default:
                }
            }
        });
    }
    #end
}

Main.hx

package ;

/**
    Hello
**/
class Main {
    public static function main() {}
}

build.hxml

-main Main
-js out/out.js
--macro Macro.use()

build output:

Macro.hx:14: Error: null
Macro.hx:14: EvalError: null
Macro.hx:14: RangeError: null
Macro.hx:14: ReferenceError: null
Macro.hx:14: SyntaxError: null
Macro.hx:14: TypeError: null
Macro.hx:14: URIError: null
Macro.hx:14: IntIterator: null
Macro.hx:14: Function_Impl_: null
Macro.hx:14: FlatEnum_Impl_: null
Macro.hx:14: Constructible_Impl_: null
Macro.hx:14: IMap: null
Macro.hx:14: HxOverrides: null
Macro.hx:14: HaxeError: null
Macro.hx:14: Boot: null
Macro.hx:14: ArrayAccess: null
Macro.hx:14: String: null
Macro.hx:14: Std: null
Macro.hx:14: Date: null
Macro.hx:14: Array: null
Macro.hx:14: EnumTools: null
Macro.hx:14: EnumValueTools: null
Macro.hx:14: Lib: null
Macro.hx:14: Reflect: null
Macro.hx:14: Main: null
Macro.hx:14: Type: null
Macro.hx:14: Math: null

According to the API documentation, doc is the "associated documentation" of the class or class field, which I assume should work. Is this a documentation ambiguity and doc actually refers to something else?

@Simn

This comment has been minimized.

Member

Simn commented Sep 29, 2018

Try compiling with -D use_rtti_doc

@bary12

This comment has been minimized.

bary12 commented Sep 29, 2018

Thanks @Simn , That worked

@bary12 bary12 closed this Sep 29, 2018

@Simn

This comment has been minimized.

Member

Simn commented Sep 29, 2018

Let me keep this open, I want to review if this is still necessary at all because we default to it when the compilation server runs anyway.

@Simn Simn reopened this Sep 29, 2018

@Simn Simn self-assigned this Sep 29, 2018

@Simn Simn added this to the Release 4.0 milestone Sep 29, 2018

@Simn Simn closed this in 38e8754 Sep 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment