@@ -51,26 +51,28 @@ class HtmlGeneratorBackend extends DartdocGeneratorBackend {
5151 // Allow overwrite of favicon.
5252 var bytes = resourceProvider.getFile (options.favicon).readAsBytesSync ();
5353 writer.writeBytes (
54- resourceProvider.pathContext. join ('static-assets' , 'favicon.png' ),
54+ _pathJoin ('static-assets' , 'favicon.png' ),
5555 bytes,
5656 allowOverwrite: true ,
5757 );
5858 }
5959 }
6060
6161 Future <void > _copyResources (FileWriter writer) async {
62- for (var resourcePath in resources.resourceNames) {
63- if (! resourcePath.startsWith (_dartdocResourcePrefix)) {
64- throw StateError ('Resource paths must start with '
65- '$_dartdocResourcePrefix , encountered $resourcePath ' );
66- }
67- var destFileName = resourcePath.substring (_dartdocResourcePrefix.length);
68- var destFilePath =
69- resourceProvider.pathContext.join ('static-assets' , destFileName);
70- writer.writeBytes (destFilePath,
71- await resourceProvider.loadResourceAsBytes (resourcePath));
62+ var resourcesDir = options.resourcesDir ??
63+ (await resourceProvider.getResourceFolder (_dartdocResourcePrefix)).path;
64+ for (var resourceFileName in resources.resourceNames) {
65+ var destinationPath = _pathJoin ('static-assets' , resourceFileName);
66+ var sourcePath = _pathJoin (resourcesDir, resourceFileName);
67+ writer.writeBytes (
68+ destinationPath,
69+ resourceProvider.getFile (sourcePath).readAsBytesSync (),
70+ );
7271 }
7372 }
7473
75- static const _dartdocResourcePrefix = 'package:dartdoc/resources/' ;
74+ String _pathJoin (String a, String b) =>
75+ resourceProvider.pathContext.join (a, b);
76+
77+ static const _dartdocResourcePrefix = 'package:dartdoc/resources' ;
7678}
0 commit comments