Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/main[co

Bug Fixes::

* Fix excluding sources when enclosing parent path starts with _ (#544)
* Fix excluding sources when enclosing parent path starts with _ (#546)
* Treat dot files and folders same as internal #5505)

== v2.2.0 (2021-07-18)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AsciidoctorFileScanner {
public static String[] INTERNAL_FOLDERS_AND_FILES_PATTERNS = {
"**/_*.*",
"**/_*",
"**/.*",
"**/_*/**/*.*",
};

Expand All @@ -40,7 +41,8 @@ public class AsciidoctorFileScanner {
"docinfo-footer.xml",
"*-docinfo.xml",
"*-docinfo-header.xml",
"*-docinfo-footer.xml"};
"*-docinfo-footer.xml"
};


private final BuildContext buildContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private List<File> find(Path sourceDirectory, Pattern sourceDocumentPattern) {
.filter(path -> sourceDocumentPattern.matcher(path.getFileName().toString()).matches())
.filter(path -> {
for (Path part : sourceDirectory.relativize(path)) {
if (part.toString().startsWith("_")) {
char firstCharacter = part.toString().charAt(0);
if (firstCharacter == '_' || firstCharacter == '.') {
return false;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,11 @@ public void should_not_copy_custom_source_documents_when_custom_extensions_are_s
*/
private void assertEqualsStructure(File[] expected, File[] actual) {


List<File> sanitizedExpected = Arrays.stream(expected)
.filter(file -> !file.getName().startsWith("_"))
.filter(file -> {
char firstChar = file.getName().charAt(0);
return firstChar != '_' && firstChar != '.';
})
.collect(Collectors.toList());

List<String> expectedNames = sanitizedExpected.stream().map(File::getName).collect(Collectors.toList());
Expand All @@ -691,7 +693,7 @@ private void assertEqualsStructure(File[] expected, File[] actual) {
if (htmls.length > 0) {
File[] asciidocs = expectedFile.listFiles(f -> {
String asciidocFilePattern = ".*\\." + AsciidoctorFileScanner.ASCIIDOC_FILE_EXTENSIONS_REG_EXP + "$";
return f.getName().matches(asciidocFilePattern) && !f.getName().startsWith("_");
return f.getName().matches(asciidocFilePattern) && !f.getName().startsWith("_") && !f.getName().startsWith(".");
});
Assertions.assertThat(htmls).hasSize(asciidocs.length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void should_exclude_hidden_sources() {
// then
assertThat(files)
.hasSize(6)
.allMatch(file -> !file.getName().startsWith("_"));
.allMatch(file -> !file.getName().startsWith("_") || !file.getName().startsWith("."));
}

@Test
Expand Down Expand Up @@ -144,7 +144,7 @@ private boolean isContainedInInternalDirectory(File file) {
int cursor = 0;
do {
cursor = path.indexOf(File.separator, cursor + 1);
if (path.charAt(cursor + 1) == '_')
if (path.charAt(cursor + 1) == '_' || path.charAt(cursor + 1) == '.')
return true;
} while (cursor != -1);
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:toc: left
:icons:

== Summary
This document won't get converted by default because it is inside a hidden folder. +
Hidden folders begin with underscore `.`.

TIP: How cool is this?
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:toc: left
:icons:

== Summary
This document won't get converted by default because it considered "internal". +
That is, is prefixed with a dot `.`.

TIP: How cool is this?