Question

I have a function and want to get its docblock with mirrors. Do mirrors already support that?

Was it helpful?

Solution

If you mean comments when you say "DocBlock" or something like javadoc-style comments like:

/**
 * Comment
 */

// Comment

Then this is not possible.

But you can create Annotations and use this as a doc:

@Doc("Some Documentation")
class SomeClass {

}

TypeMirror tm = reflectType(SomeClass );

print((tm.metadata.first.reflectee as Doc).string);

But I guess this is not what you are looking for?

There is a Comment class in dart:mirror - but note that it is not used and dart:mirror is officially "unstable".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top