Skip to content

Crash generating documentation on package #2479

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

Closed
chrisjones314 opened this issue Jan 9, 2021 · 6 comments
Closed

Crash generating documentation on package #2479

chrisjones314 opened this issue Jan 9, 2021 · 6 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@chrisjones314
Copy link

I run dartdoc in a package and get this exception after about 10 seconds. The package is not public.

dartdoc failed: NoSuchMethodError: The getter 'element' was called on null.
Receiver: null
Tried calling: element
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 new ElementType.from (package:dartdoc/src/element_type.dart:30:11)
#2 new Extension (package:dartdoc/src/model/extension.dart:21:21)
#3 ModelElement._from (package:dartdoc/src/model/model_element.dart:330:14)
#4 new ModelElement.from (package:dartdoc/src/model/model_element.dart:278:40)
#5 Library.extensions. (package:dartdoc/src/model/library.dart:202:34)
#6 MappedIterator.moveNext (dart:_internal/iterable.dart:389:20)
#7 new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)
#8 new _List._ofOther (dart:core-patch/array.dart:106:43)
#9 new _List.of (dart:core-patch/array.dart:57:18)
#10 new List.of (dart:core-patch/array_patch.dart:52:20)
#11 Iterable.toList (dart:core/iterable.dart:404:12)
#12 Library.extensions (package:dartdoc/src/model/library.dart:203:10)
#13 Library.modelElementsMap (package:dartdoc/src/model/library.dart:619:17)
#14 Library.allModelElements (package:dartdoc/src/model/library.dart:659:33)
#15 PackageGraph.allModelElements.. (package:dartdoc/src/model/package_graph.dart:920:48)
#16 SetMixin.forEach (dart:collection/set.dart:142:30)
#17 PackageGraph.allModelElements. (package:dartdoc/src/model/package_graph.dart:919:18)
#18 SetMixin.forEach (dart:collection/set.dart:142:30)
#19 PackageGraph.allModelElements (package:dartdoc/src/model/package_graph.dart:913:52)
#20 PackageGraph.precacheLocalDocs.sync_op (package:dartdoc/src/model/package_graph.dart:126:19)
#21 _SyncIterator.moveNext (dart:core-patch/core_patch.dart:181:26)
#22 Future.wait (dart:async/future.dart:409:26)
#23 PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:74:18)
#24 PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:77:20)

#25 Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:182:20)

#26 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:223:28)

#27 Dartdoc.executeGuarded. (package:dartdoc/dartdoc.dart:500:9)

** Environment **

dartdoc version: 0.37.0
Dart SDK version: 2.12.0-133.2.beta (beta) (Tue Dec 15 09:55:09 2020 +0100) on "macos_x64"
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.25.0-8.1.pre, on Mac OS X 10.14.6 18G1012 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.52.1)
[✓] Connected device (2 available)

** Comment **

I haven't been regularly running dartdoc to this point, so unfortunately virtually any comment could be the cause. If you can point me to a document explaining how to debug dartdoc on a local machine, or explaining how to collect better debugging information, I'd be happy to provide more details or look into it myself.

@jcollins-g
Copy link
Contributor

Dartdoc is somehow confused building type information related to an extension (I can't be more specific without more information). If you can, just in case update to 0.38.0 with pub global activate and try again, though I don't know of any bugs fixed since 0.37.0 that would cover this.

@jcollins-g jcollins-g added P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jan 11, 2021
@chrisjones314
Copy link
Author

I think it must be something about my machine or configuration. I cloned a relatively simple flutter package with good documentation:

https://github.com/boyan01/overlay_support.git

And ran dartdoc within it. I get the same exception:

Documenting overlay_support...
|
dartdoc failed: NoSuchMethodError: The getter 'element' was called on null.
Receiver: null
Tried calling: element
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 new ElementType.from (package:dartdoc/src/element_type.dart:30:11)
#2 new Extension (package:dartdoc/src/model/extension.dart:21:21)
#3 ModelElement._from (package:dartdoc/src/model/model_element.dart:330:14)
#4 new ModelElement.from (package:dartdoc/src/model/model_element.dart:278:40)
#5 Library.extensions. (package:dartdoc/src/model/library.dart:202:34)
#6 MappedIterator.moveNext (dart:_internal/iterable.dart:389:20)
#7 new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)
#8 new _List._ofOther (dart:core-patch/array.dart:106:43)
#9 new _List.of (dart:core-patch/array.dart:57:18)
#10 new List.of (dart:core-patch/array_patch.dart:52:20)
#11 Iterable.toList (dart:core/iterable.dart:404:12)
#12 Library.extensions (package:dartdoc/src/model/library.dart:203:10)
#13 Library.modelElementsMap (package:dartdoc/src/model/library.dart:619:17)
#14 Library.allModelElements (package:dartdoc/src/model/library.dart:659:33)
#15 PackageGraph.allModelElements.. (package:dartdoc/src/model/package_graph.dart:920:48)
#16 SetMixin.forEach (dart:collection/set.dart:142:30)
#17 PackageGraph.allModelElements. (package:dartdoc/src/model/package_graph.dart:919:18)
#18 SetMixin.forEach (dart:collection/set.dart:142:30)
#19 PackageGraph.allModelElements (package:dartdoc/src/model/package_graph.dart:913:52)
#20 PackageGraph.precacheLocalDocs.sync_op (package:dartdoc/src/model/package_graph.dart:126:19)
#21 _SyncIterator.moveNext (dart:core-patch/core_patch.dart:181:26)
#22 Future.wait (dart:async/future.dart:409:26)
#23 PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:74:18)
#24 PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:77:20)

#25 Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:182:20)

#26 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:223:28)

#27 Dartdoc.executeGuarded. (package:dartdoc/dartdoc.dart:500:9)

Note that originally when I tried to run dartdoc, I got an "Invalid argument(s) (path)" exception, and found some documentation stating that I had to set the FLUTTER_ROOT environment variable here:

https://flutter.dev/docs/development/packages-and-plugins/developing-packages

I did that, and I can run the command as they suggest, specifically:

$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dartdoc

But doing so still produces the same exception. Eventually I'd like to publish an open-source package I have been working on, but its not urgent, I was just planning to begin improving the documentation for that purpose.

If there is anything about my particular configuration/environment you think I should investigate, please let me know.

@jcollins-g
Copy link
Contributor

jcollins-g commented Jan 14, 2021

That recommendation is wrong; I'll file an issue. Use pub global activate dartdoc.

edit: That is perhaps too strong; the version inside the Flutter package should work. However, please try using pub global activate dartdoc and verifying that you're running on 0.38.0 or higher.

@chrisjones314
Copy link
Author

chrisjones314 commented Jan 14, 2021

That worked! I did pub global activate dartdoc and then pub global run dartdoc and it worked as expected.

Note that dartdoc --version reports 0.37.0 (still, even after doing the pub global activate), but pub global activate dartdoc --version reports 0.39.0.

This solves my problem, thanks very much for your help!

Unless you think it unnecessary, maybe I will submit a documentation bug over on flutter/flutter to clarify the documentation at:

https://flutter.dev/docs/development/packages-and-plugins/developing-packages

to recommend using this method.

Let me know if you think I should not.

@jcollins-g
Copy link
Contributor

If your path is not set up, pub global activate dartdoc won't change which dartdoc gets run, but you can always use pub to run dartdoc directly as you discovered.

@jcollins-g
Copy link
Contributor

Let me know if you think I should not.

Most users don't actually need to update dartdoc so I'm not sure changing the instructions would be that helpful for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants