Skip to content

Commit

Permalink
Fixes #95
Browse files Browse the repository at this point in the history
Allowing files to start with "assembly" and have "assembly" be the first part of an id.

Signed-off-by: Jason Porter <lightguard.jp@gmail.com>
  • Loading branch information
LightGuard committed Jun 27, 2022
1 parent 5da3e57 commit adfef6d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public int process() {

for (File file : walker.getAdocFiles()) {
// We only want to process chap files, others should be moved to modules.
if (!file.getName().startsWith("chap-")) {
if (!file.getName().startsWith("chap-") && !file.getName().startsWith("assembly-")) {
try {
this.logger.fine("Copying non chap- file '" + file + "' to modules directory");
Path modulesDir = Files.createDirectories(targetDirPath.resolve("modules"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public Assembly(Document doc, List<String> lines, StringBuilder processedBody) {
this.id = this.id.replaceAll("chap-", "");
}

// remove "assembly-" if it is found
if (this.id.contains("assembly-")) {
this.id = this.id.replaceAll("assembly-", "");
}

if (this.id.contains("{context}")) {
this.idWithoutContext = this.id.substring(0, this.id.lastIndexOf("{context}") - 1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,19 @@ public void additionalResources81Test() throws Exception {
assertThat(Files.lines(assemblyFile)).contains("* {URL_PROCESS_SERVICES}[_{PROCESS_SERVICES}_]");
assertThat(Files.lines(assemblyFile)).contains("* {URL_CONFIGURING_KOGITO}[_{CONFIGURING_KOGITO}_]");
}

@Test
public void assemblyInsteadOfChap95Test() throws Exception {
this.executeRunner("docs/issue-95", false);

assertThat(assembliesDir.toFile().exists()).isTrue();
assertThat(assembliesDir.toFile().listFiles(pathname -> pathname.getName().contains(".adoc"))).hasSize(1);

var assemblyFile = assembliesDir.resolve("assembly-kogito-using-dmn-models.adoc");
assertThat(Files.lines(assemblyFile)).contains("[id='assembly-kogito-using-dmn-models']");

modulesDir = modulesDir.resolve("dmn");
assertThat(modulesDir.toFile().exists()).isTrue();
assertThat(modulesDir.toFile().listFiles(pathname -> pathname.getName().contains(".adoc"))).hasSizeGreaterThanOrEqualTo(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void testFileContentsSourceBlock() throws Exception {
var assembliesDir = new File(this.outputDirectory, "assemblies");
assertThat(assembliesDir.listFiles(new AsciidocFileFilter())).hasSize(1);
final var assemblyFile = Objects.requireNonNull(assembliesDir.listFiles(new AsciidocFileFilter()))[0];
assertThat(assemblyFile.getName()).isEqualTo("assembly-assembly-one.adoc");
assertThat(assemblyFile.getName()).isEqualTo("assembly-one.adoc");
}

@Test
Expand Down Expand Up @@ -301,7 +301,7 @@ public void testImagesdirInOutput() throws Exception {
new CommandLine(new ExtractionRunner()).execute(options);

var chap = outputDirectory.toPath().resolve("assemblies")
.resolve("assembly-assembly-one.adoc");
.resolve("assembly-one.adoc");
var module = outputDirectory.toPath().resolve("modules").resolve("content-test").resolve("con-module-two.adoc");

assertThat(Files.readAllLines(chap).get(2)).isEqualTo(":imagesdir: _images");
Expand Down

0 comments on commit adfef6d

Please sign in to comment.