سؤال

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

هل كانت مفيدة؟

المحلول

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".

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top