美文网首页
生成dart文档

生成dart文档

作者: young蛘 | 来源:发表于2020-07-22 12:06 被阅读0次

    首先启用dartdoc:
    flutter pub global activate dartdoc
    然后执行dartdoc命令
    dartdoc

    执行dartdoc命令后,出现如下错误:

    #0      _validateArgList (package:path/src/context.dart:1101:5)
    #1      Context.join (package:path/src/context.dart:240:5)
    #2      join (package:path/path.dart:262:13)
    #3      createDartdocOptions.<anonymous closure> (package:dartdoc/src/dartdoc_options.dart:1587:16)
    #4      DartdocSyntheticOption._valueAtFromSynthetic (package:dartdoc/src/dartdoc_options.dart:798:44)
    #5      DartdocOptionArgSynth.valueAt (package:dartdoc/src/dartdoc_options.dart:756:12)
    #6      DartdocOptionContext.sdkDir (package:dartdoc/src/dartdoc_options.dart:1405:44)
    #7      PubPackageBuilder.sdk (package:dartdoc/src/model/package_builder.dart:81:60)
    #8      PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:67:7)
    #9      Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:175:41)
    #10     Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:216:34)
    #11     _rootRun (dart:async/zone.dart:1184:13)
    #12     _CustomZone.run (dart:async/zone.dart:1077:19)
    #13     _runZoned (dart:async/zone.dart:1619:10)
    #14     runZonedGuarded (dart:async/zone.dart:1608:12)
    #15     Dartdoc.executeGuarded (package:dartdoc/dartdoc.dart:475:5)
    #16     main (file:///Users/chongyang/Library/flutter/.pub-cache/hosted/pub.flutter-io.cn/dartdoc-0.32.1/bin/dartdoc.dart:24:11)
    <asynchronous suspension>
    #17     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
    #18     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
    

    搜索到原因为未设置FLUTTER_ROOT到环境变量中。(在我的系统中设置的变量名是FLUTTER_HOME,推断dartdoc只查找默认值是FLUTTER_ROOT的环境变量)。
    将FLUTTER_ROOT添加到环境变量后,文档生成成功。(如何添加环境变量,请出门左转问度娘)
    生成的文档在[项目根目录]/doc/api下。

    相关文章

      网友评论

          本文标题:生成dart文档

          本文链接:https://www.haomeiwen.com/subject/vguzkktx.html