在库中导入包时,DartDoc生成不起作用

时间:2013-11-15 04:19:49

标签: documentation dart dart-editor

我正在尝试生成dart代码的文档。 我注意到我无法通过DartDoc生成任何文档,因为在我的库中我有时需要导入一些外部库。

下面我有一个显示我实际问题的小例子。

listController.dart

part of controllers;

@NgController (
    selector: '[list-control]',
    publishAs: 'listCtrl'
)
class ListController {

}

controllers.dart

library controllers;

import 'package:angular/angular.dart';

part 'listController.dart';

控制台上的最终结果

Running dartdoc...
Using snapshot /Users/ecomtemarois/Downloads/dart/dart-sdk/bin/snapshots/utils_wrapper.dart.snapshot
Analyzing libraries...
../../../Documents/ecash.dart/ecash/controllers/controllers.dart:3:8: Error: Can't read 'package:angular/angular.dart' (Error reading 'packages/angular/angular.dart' (OS Error: No such file or directory, errno = 2)).
import 'package:angular/angular.dart';
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../Documents/ecash.dart/ecash/controllers/listController.dart:3:2: Error: Cannot resolve 'NgController'.
@NgController (
 ^^^^^^^^^^^^
../../../Documents/ecash.dart/ecash/controllers/listController.dart:3:1: Error: Not a compile-time constant.
@NgController (
^^^^^^^^^^^^^^^^
Error: generation failed: Bad state: Failed to create mirror system.
StackTrace: #0      analyze.<anonymous closure> (file:///Volumes/data/b/build/slave/dart-editor-mac-trunk/build/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart:232)
#1      _Future._propagateToListeners.<anonymous closure> (dart:async/future_impl.dart:457)
#2      _rootRun (dart:async/zone.dart:720)
#3      _RootZone.run (dart:async/zone.dart:862)
#4      _Future._propagateToListeners (dart:async/future_impl.dart:449)
#5      _Future._complete (dart:async/future_impl.dart:302)
#6      Future.forEach.nextElement (dart:async/future.dart:269)
#7      _Future._propagateToListeners.<anonymous closure> (dart:async/future_impl.dart:457)
#8      _rootRun (dart:async/zone.dart:720)
#9      _RootZone.run (dart:async/zone.dart:862)
#10     _Future._propagateToListeners (dart:async/future_impl.dart:449)
#11     _Future._complete (dart:async/future_impl.dart:302)
#12     Future.forEach.nextElement (dart:async/future.dart:269)
#13     _Future._propagateToListeners.<anonymous closure> (dart:async/future_impl.dart:457)
#14     _rootRun (dart:async/zone.dart:720)
#15     _RootZone.run (dart:async/zone.dart:862)
#16     _Future._propagateToListeners (dart:async/future_impl.dart:449)
#17     _Future._complete (dart:async/future_impl.dart:302)
#18     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:358)
#19     _asyncRunCallback (dart:async/schedule_microtask.dart:18)
#20     _createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:11)
#21     _Timer._createTimerHandler._handleTimeout (timer_impl.dart:151)
#22     _Timer._createTimerHandler.<anonymous closure> (timer_impl.dart:166)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:93)

我想知道如何能够访问这些包并仍然能够生成文档。

感谢

1 个答案:

答案 0 :(得分:1)

您的dart文件旁边看起来没有packages目录。如果您正在使用Pub,则应使用pub get命令创建此目录。如果不这样做,您可以使用--package-root=<path>选项提供的路径。

注意:查看您的路径(../../../Documents/ecash.dart/ecash/controllers/listController.dart),您似乎没有遵循Package layout conventions。我建议你遵循它。