Skip to content

Commit

Permalink
Add .editorconfig to help with formatting
Browse files Browse the repository at this point in the history
* Reformated imports for all Java files
* Updated contributing.adoc
  • Loading branch information
abelsromero committed Jan 27, 2024
1 parent 35ec5c0 commit ce9a65a
Show file tree
Hide file tree
Showing 93 changed files with 1,656 additions and 1,586 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
tab_width = 4

[*.java]
ij_java_class_count_to_use_import_on_demand = 99
ij_java_imports_layout = javax.**, java.**, |, *, |, $*

[{*.yml,*.yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Improvements::
* Upgrade Asciidoctorj to v2.5.10 and jRuby to v9.4.2.0 (#647)
* Upgrade Asciidoctorj to v2.5.11 (#688)
* Improve warning message when destination file is going to be replaced (#728)
* Added `.editorconfig` file to facilitate code formatting (#760)

Build / Infrastructure::

Expand Down Expand Up @@ -66,7 +67,6 @@ Build / Infrastructure::
* Automate release using GH Actions (#141)
* Ensure Mojos use correct default values in unit tests (#609)


Maintenance::
* Replace use of reflection by direct JavaExtensionRegistry calls to register extensions (#596)

Expand Down
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
= Asciidoctor Maven Tools (Plugin & Site Integration)
// Metadata
:release-version: 2.2.2
:release-version: 2.2.5
:docs-version: 2.2
:maven-site-plugin-version: 3.9.0
:maven-site-plugin-version: 3.12.1
// Settings
:idprefix:
:idseparator: -
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
package org.asciidoctor.maven.site;

import javax.inject.Inject;
import javax.inject.Provider;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.logging.Logger;

import org.apache.maven.doxia.parser.AbstractTextParser;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.project.MavenProject;
import org.asciidoctor.*;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Attributes;
import org.asciidoctor.AttributesBuilder;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.asciidoctor.maven.log.LogHandler;
import org.asciidoctor.maven.log.LogRecordFormatter;
import org.asciidoctor.maven.log.LogRecordsProcessors;
Expand All @@ -14,13 +26,6 @@
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.Xpp3Dom;

import javax.inject.Inject;
import javax.inject.Provider;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.logging.Logger;

/**
* This class is used by <a href="https://maven.apache.org/doxia/overview.html">the Doxia framework</a>
* to handle the actual parsing of the AsciiDoc input files into HTML to be consumed/wrapped
Expand Down Expand Up @@ -67,7 +72,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
final Asciidoctor asciidoctor = Asciidoctor.Factory.create();

SiteConversionConfiguration conversionConfig = new SiteConversionConfigurationParser(project)
.processAsciiDocConfig(siteConfig, defaultOptions(siteDirectory), defaultAttributes());
.processAsciiDocConfig(siteConfig, defaultOptions(siteDirectory), defaultAttributes());
for (String require : conversionConfig.getRequires()) {
requireLibrary(asciidoctor, require);
}
Expand All @@ -80,7 +85,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
try {
// process log messages according to mojo configuration
new LogRecordsProcessors(logHandler, siteDirectory, errorMessage -> getLog().error(errorMessage))
.processLogRecords(memoryLogHandler);
.processLogRecords(memoryLogHandler);
} catch (Exception exception) {
throw new ParseException(exception.getMessage(), exception);
}
Expand All @@ -91,7 +96,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
private MemoryLogHandler asciidoctorLoggingSetup(Asciidoctor asciidoctor, LogHandler logHandler, File siteDirectory) {

final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(),
logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory)));
logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory)));
asciidoctor.registerLogHandler(memoryLogHandler);
// disable default console output of AsciidoctorJ
Logger.getLogger("asciidoctor").setUseParentHandlers(false);
Expand Down Expand Up @@ -120,15 +125,15 @@ protected File resolveSiteDirectory(MavenProject project, Xpp3Dom siteConfig) {

protected OptionsBuilder defaultOptions(File siteDirectory) {
return Options.builder()
.backend("xhtml")
.safe(SafeMode.UNSAFE)
.baseDir(new File(siteDirectory, ROLE_HINT));
.backend("xhtml")
.safe(SafeMode.UNSAFE)
.baseDir(new File(siteDirectory, ROLE_HINT));
}

protected AttributesBuilder defaultAttributes() {
return Attributes.builder()
.attribute("idprefix", "@")
.attribute("showtitle", "@");
.attribute("idprefix", "@")
.attribute("showtitle", "@");
}

private void requireLibrary(Asciidoctor asciidoctor, String require) {
Expand Down
Loading

0 comments on commit ce9a65a

Please sign in to comment.