Skip to content
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

runtime mirrors: access to doc-comments #15704

Closed
DartBot opened this issue Dec 18, 2013 · 6 comments
Closed

runtime mirrors: access to doc-comments #15704

DartBot opened this issue Dec 18, 2013 · 6 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-mirrors type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Dec 18, 2013

This issue was originally filed by @seaneagan


In unscripted (http://pub.dartlang.org/packages/unscripted) it would be ideal for users to define the help text as doc-comments:

  /// ...

instead of metadata annotations:

  @­Command(help: '...')

dart:mirrors already has:

https://api.dartlang.org/docs/channels/be/latest/dart_mirrors/Comment.html

which says:

  Class used for encoding comments as metadata annotations.

but they are not currently exposed anywhere. For doc-comments the logical place would be in DeclarationMirror probably as items in metadata. Non-doc-comments are less useful, and less obvious how to expose, so they could be left for source mirrors and/or the analyzer package.

Original mailing list discussion:

https://groups.google.com/a/dartlang.org/forum/#!searchin/misc/doc$20comments$20metadata/misc/pDyDWw0AXDc/R0hbdkwUunoJ

@floitschG
Copy link
Contributor

Added Area-Pkg, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Dec 18, 2013

This comment was originally written by @seaneagan


This is for dart:mirrors, so Area-Library ?

@DartBot
Copy link
Author

DartBot commented Jan 15, 2014

This comment was originally written by @seaneagan


Apparently including Comments in DeclarationMirror.metadata is already implemented by dart2js mirrors:

https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart#­364

@sethladd
Copy link
Contributor

Removed Type-Defect, Area-Pkg labels.
Added Type-Enhancement, Area-Library, Library-Mirrors labels.

@DartBot
Copy link
Author

DartBot commented Feb 26, 2015

This comment was originally written by @seaneagan


Another use case for this:

google/grinder.dart#103

I think the reflectable package should be able to solve this nicely, so filed an issue there:

google/reflectable.dart#3

@eernstg
Copy link
Member

eernstg commented Mar 11, 2015

The dart2js_mirrors.dart link in #­3 does not work from here (possibly not at all) any more, and the version of that file that I can find may differ from what you have seen. However, I tried out this:

import 'dart:mirrors';

/// DartDoc comment
class A {}

main() {
  DeclarationMirror declarationMirror = reflectType(A);
  List metadata = declarationMirror.metadata;
  print(metadata);
}

which prints the empty list (so the doc comment is not included). I guess this is because mirrors.compiler.commentMap[getBeginToken()] is empty, but in any case it looks like a bug. So I'll assume that it will be supported. Based on that, it makes sense to make Reflectable behave in the same way (such that doc comments are included in the result returned by metadata on a DeclarationMirror). See google/reflectable.dart#3 for a slightly more detailed explanation.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-mirrors labels Mar 11, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-mirrors type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants