Skip to content

Classifies names according to case, uses for filename generation. #1764

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
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ Future<List<DartdocOption>> createDartdocOptions() async {
new DartdocOptionArgFile<List<String>>('includeExternal', null,
isFile: true,
help:
'Additional (external) dart files to include; use "dir/fileName", '
'Additional (external) dart files to include; use "dir/filename", '
'as in lib/material.dart.',
mustExist: true,
splitCommas: true),
Expand Down
17 changes: 14 additions & 3 deletions lib/src/html/html_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,20 @@ class HtmlGenerator extends Generator {
if (!enabled) {
throw new StateError('`write` was called after `generate` completed.');
}
// If you see this assert, we're probably being called to build non-canonical
// docs somehow. Check data.self.isCanonical and callers for bugs.
assert(allowOverwrite || !writtenFiles.contains(filePath));

assert(
!writtenFiles
.map((String file) => file.toLowerCase())
.contains(filePath.toLowerCase()),
'Filename case metamer found. Output would not be correct on a '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where writtenFiles is being populated with lowercase names.

also nit: once it is, this case is actually the union of the previous case and the metamer case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's populated in the .map() in this expression. I can't just populate writtenFiles with lowercase names from the start, because on Linux it would be incorrect because it's case sensitive, and would be looking for the wrong file in the allowOverwrite case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. That's likely to be really slow, as we'll convert the entire set every time, but yes it will work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I'll just make two lists (one actual case, and one lowercase) to make it more efficient.

'case-insensitive filesystem (like macOS). Metamer found was '
'"$filePath", which collides with '
'"${writtenFiles.where((String name) => name.toLowerCase() == filePath.toLowerCase()).join('" and "')}"');

assert(
allowOverwrite || !writtenFiles.contains(filePath),
'Being called to build non-canonical docs somehow. Check '
'data.self.isCanonical and callers for bugs.');

var file = new File(pathLib.join(outputDirectoryPath, filePath));
var parent = file.parent;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/html/html_generator_instance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class HtmlGeneratorInstance {
}
TemplateData data = new LibraryTemplateData(_options, packageGraph, lib);

_build(pathLib.join(lib.dirName, '${lib.fileName}'),
_build(pathLib.join(lib.dirName, '${lib.filename}'),
_templates.libraryTemplate, data);
}

Expand Down
Loading