Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsromero committed Jun 18, 2023
1 parent 3c58a01 commit ed339d9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.asciidoctor.maven.site;

import org.apache.maven.project.MavenProject;
import org.asciidoctor.Attributes;
import org.asciidoctor.AttributesBuilder;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
Expand All @@ -9,7 +10,10 @@
import org.codehaus.plexus.util.xml.Xpp3Dom;

import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -29,17 +33,21 @@ public SiteConversionConfiguration processAsciiDocConfig(Xpp3Dom siteConfig,

AsciidoctorHelper.addProperties(project.getProperties(), presetAttributes);

final Xpp3Dom siteConfiguration = Optional.ofNullable(siteConfig)
.map(sc -> sc.getChild("asciidoc"))
.orElse(null);
final Attributes attributes = presetAttributes.build();

if (siteConfiguration == null) {
final OptionsBuilder options = presetOptions.attributes(presetAttributes.build());
return new SiteConversionConfiguration(options.build(), Collections.emptyList());
if (siteConfig == null) {
final Options options = presetOptions.attributes(attributes).build();
return new SiteConversionConfiguration(options, Collections.emptyList());
}

final Xpp3Dom asciidocConfig = siteConfig.getChild("asciidoc");
if (asciidocConfig == null) {
final Options options = presetOptions.attributes(attributes).build();
return new SiteConversionConfiguration(options, Collections.emptyList());
}

final List<String> gemsToRequire = new ArrayList<>();
for (Xpp3Dom asciidocOpt : siteConfiguration.getChildren()) {
for (Xpp3Dom asciidocOpt : asciidocConfig.getChildren()) {
String optName = asciidocOpt.getName();

if ("requires".equals(optName)) {
Expand Down Expand Up @@ -79,12 +87,12 @@ public SiteConversionConfiguration processAsciiDocConfig(Xpp3Dom siteConfig,
}
}

final Options options = presetOptions.attributes(presetAttributes.build()).build();
final Options options = presetOptions.attributes(attributes).build();
return new SiteConversionConfiguration(options, gemsToRequire);
}

private File resolveProjectDir(MavenProject project, String path) {
final File filePath = new File(path);
return !filePath.isAbsolute() ? new File(project.getBasedir(), filePath.toString()): filePath;
return !filePath.isAbsolute() ? new File(project.getBasedir(), filePath.toString()) : filePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public ManpageInlineMacroProcessor(String macroName) {

@Override
public String process(ContentNode parent, String target, Map<String, Object> attributes) {

final Map<String, Object> options = new HashMap<>();
options.put("type", ":link");
options.put("target", target + ".html");
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.java.version>11</project.java.version>
<project.execution.environment>JavaSE-1.8</project.execution.environment>
<asciidoctorj.version>2.5.10</asciidoctorj.version>
<asciidoctorj.version>3.0.0-alpha.1</asciidoctorj.version>
<jruby.version>9.4.2.0</jruby.version>
<maven.project.version>3.9.1</maven.project.version>
<maven.jacoco.plugin.version>0.8.8</maven.jacoco.plugin.version>
Expand Down

0 comments on commit ed339d9

Please sign in to comment.