@@ -19,26 +19,31 @@ const _validFormats = {'html', 'md'};
1919/// together.
2020abstract class FileStructure {
2121 factory FileStructure .fromDocumentable (Documentable documentable) {
22- if (! _validFormats.contains (documentable.config.format)) {
23- throw DartdocFailure (
24- 'Internal error: unrecognized config.format: ${documentable .config .format }' );
22+ /// This assumes all remote packages are HTML.
23+ /// Add configurability for remote formats in dartdoc_options if changing
24+ /// that becomes desireable.
25+ var format = documentable.config.format;
26+ if (documentable.package.documentedWhere == DocumentLocation .remote) {
27+ format = 'html' ;
28+ }
29+ if (! _validFormats.contains (format)) {
30+ throw DartdocFailure ('Internal error: unrecognized format: $format ' );
2531 }
2632 switch (documentable) {
2733 case LibraryContainer ():
2834 // [LibraryContainer]s are not ModelElements, but have documentation.
29- return FileStructure ._fromLibraryContainer (documentable);
35+ return FileStructure ._fromLibraryContainer (documentable, format );
3036 case ModelElement ():
3137 // This should be the common case.
32- return FileStructure ._fromModelElement (documentable);
38+ return FileStructure ._fromModelElement (documentable, format );
3339 default :
3440 throw UnimplementedError (
3541 'Tried to build a FileStructure for an unknown subtype of Documentable: ${documentable .runtimeType }' );
3642 }
3743 }
3844
3945 factory FileStructure ._fromLibraryContainer (
40- LibraryContainer libraryContainer) {
41- final format = libraryContainer.config.format;
46+ LibraryContainer libraryContainer, String format) {
4247 switch (libraryContainer) {
4348 case Category ():
4449 return FileStructureImpl (format, libraryContainer.name, 'topic' );
@@ -50,8 +55,8 @@ abstract class FileStructure {
5055 }
5156 }
5257
53- factory FileStructure ._fromModelElement (ModelElement modelElement) {
54- final format = modelElement.config. format;
58+ factory FileStructure ._fromModelElement (
59+ ModelElement modelElement, String format) {
5560 switch (modelElement) {
5661 case Library ():
5762 return FileStructureImpl (format, modelElement.dirName, 'library' );
@@ -66,8 +71,7 @@ abstract class FileStructure {
6671 return FileStructureImpl (format, modelElement.name,
6772 modelElement.isConst ? 'constant' : null );
6873 default :
69- return FileStructureImpl (
70- modelElement.config.format, modelElement.name, null );
74+ return FileStructureImpl (format, modelElement.name, null );
7175 }
7276 }
7377
0 commit comments