Dartdoc: 2 同类型的后期字段导致错误

创建于 2020-07-24  ·  17评论  ·  资料来源: dart-lang/dartdoc

使用 2 个相同类型的后期字段,如以下代码:

class A {
  late double a;
  late double b;
}

dartdoc --enable-experiment=non-nullable输出错误:

Generating docs for library a from package:hello_world/a.dart...
  error: failed to write file at: a/A/double.html, for symbol a.A.double: (file:///home/a14n/hello_world/lib/a.dart:2:8)
            Dartdoc generates a path and filename to write to for each symbol.
            a.A.double conflicts with another symbol in the generated path, and
            therefore can not be written out.  Changing the name, library name, or
            class name (if appropriate) of one of the conflicting items can resolve
            the conflict.   Alternatively, use the <strong i="10">@nodoc</strong> tag in one symbol's
            documentation comments to hide it.

只有一个延迟字段不会出现问题。

P1 bug

所有17条评论

FWIW 这个问题阻止了 Flutter 迁移到 nullsafety。

那个难看的表情在哪里……真是个奇怪的错误。 我今天看看这个。

dartdoc 不会将您的源视为已选择加入空安全功能。 这可能有 17 个原因,哈哈。 你能检查以下几点:

  1. 包是否通过 SDK 约束选择了空安全? 我认为这可能涉及 2.9 _或_ 2.10,具体取决于您使用的 Dart 版本。
  2. 包是否通过 analysis_options 选择了空安全?
analyzer:
  enable-experiment:
    - non-nullable
  1. 您是否正在使用null-safety实验运行 dartdoc? 如果您通过 pub 调用它,它可能类似于pub global run dartdoc --enable-experiment=null-safety

是的,我有一个简单的包

//------ analysis_options.yaml
analyzer:
  enable-experiment:
  - non-nullable
//------ pubspec.yaml
name: hello_world
environment:
  sdk: ">=2.9.0-14.0.dev <3.0.0"
//------ lib/a.dart
class A {
  late double a;
  late double b;
}

我运行dartdoc --enable-experiment=non-nullable (与dartdoc --enable-experiment=null-safety相同的错误)。

您可以在我的 flutter PR https://cirrus-ci.com/task/4975447580606464?command=main#L137上看到失败

@srawlins你能重现这个问题吗?

FWIW 这个问题阻止了 Flutter 迁移到 nullsafety

这会阻止迁移吗? 阻止它的某些方面? 您近期有解决方​​法吗?

通过 pubspec 选择加入空安全时,我无法重现这一点:

environment:
  sdk: '>=2.9.0-18.0 <2.9.0'

和 analysis_options:

analyzer:
  enable-experiment:
    - non-nullable

并在头部使用 dartdoc,在头部运行dart

~/code/dart-sdk/sdk/xcodebuild/ReleaseX64/dart-sdk/bin/dart
    --enable-experiment=non-nullable
    ../dart-dartdoc/bin/dartdoc.dart
    --enable-experiment=non-nullable

我正在发布 dartdoc,因为它已经有一段时间了。 我还将检查当前的最新版本。

这会阻止迁移吗? 阻止它的某些方面?

是的,因为docs-linux工作总是失败。 (见颤振/颤振#62157)

您近期有解决方​​法吗?

删除所有late并不是真正的解决方法,因为它需要在任何地方添加!? :-(

失败的工作提到dartdoc version: 0.32.1 。 你能检查一下这个版本是否会触发你这边的问题吗? 如果您看到该问题,则可能意味着它已在某个时候得到修复,下一个版本将解决该问题。

陷阱; 我希望有一些我们可以传递给 dartdoc 的标志(或我们可以省略的标志),这样我们就可以在此期间继续进行。

@srawlins - 我认为这里的修复对于让 nnbd 迁移总体进展很重要。

是的,看起来我可以在 0.32.1 上使用 Dart 2.10.0-dev.something 重现它。 有一个未发布的 0.32.2 可能有效。 我也试试。

我可以在 v0.32.2 git 标签和 master 上使用pub global run进行复制。 我正在研究为什么pub是罪魁祸首。

抓那个。 我的测试文件中有一个杂散的// @dart=2.9 (现在 _too low_ 表明空安全)。

我无法在 dartdoc 0.32.1、git branch v0.32.2 或 head 上用pub run dartdoc重现错误。

FWIW,我在链接的 linux bot 上的 dartdoc 调用中没有看到--enable-experiment=non-nullable

我在您的 cirrus 链接中没有看到--enable-experiment=non-nullable ,也没有在您的 PR 上的最新 cirrus 链接中看到。

接得好! 它应该解决这个问题。

(但在本地我真的不知道我做了什么看到这个问题)

让我们知道这是否有效。 我计划明天早上在内部审查后发布 dartdoc。

添加--enable-experiment=non-nullable修复了该问题。 谢谢你的帮助。

此页面是否有帮助?
0 / 5 - 0 等级