Skip to content

Commit

Permalink
Deprecate *[eE]xtensions in favour of *[dD]Extensions (asciidoctor#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysb33r committed Apr 25, 2019
1 parent b1f61e5 commit 7b0dc84
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 57 deletions.
14 changes: 7 additions & 7 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ attributeProvider:: Register an additional provider of attributes.
Attribute providers are a means of adding attributes that will not affect the up-to-date status of tasks.
epubVersion:: {asciidoctorj-epub-name} version.
If not specified asciidoctorj-epub will not be on the classpath. If you plan to use the EPUB backend, then you need to set a version here.
extensions:: Groovy DSL extensions.
Use `extensions` to add one or more extensions. Use `setExtensions` to replace the current set of extensions with a new set.
docExtensions:: Groovy DSL extensions.
Use `docExtensions` to add one or more extensions. Use `setDocExtensions` to replace the current set of extensions with a new set.
Extensions can be any kind of object that is serialisable, although in most cases they will be strings or files.
If extensions are detached dependencies, they will not be serialised, but rather will be placed on the classpath in
order that {asciidoctorj-name} can pick them up automatically.
fatalWarnings: Patterns for {asciidoctorj-name} log messages that shuold be treated as fatal errors.
fatalWarnings: Patterns for {asciidoctorj-name} log messages that should be treated as fatal errors.
The list is empty be default. Use `setFatalWarnings` to clear any existing patterns or to decouple a task's configuration from the global
configuration. Use `fatalWarnings` to add more patterns. Pass `missingIncludes()` to add the common use-case of
missing include files.
Expand Down Expand Up @@ -911,7 +911,7 @@ plugins {
}
asciidoctorj {
extensions project(':extension')
docExtensions project(':extension')
}
----

Expand All @@ -922,13 +922,13 @@ In the less-common case where extension is not supplied via the default configur

The next option is to define extensions directly in the build script.
This approach is based on the project asciidoctorj-groovy-dsl that allows to define Asciidoctor extensions in Groovy.
An extension is registered via the `extensions` element.
An extension is registered via the `docExtensions` element.

[source,groovy]
.build.gradle
----
asciidoctorj {
extensions {
docExtensions {
block(name: "BIG", contexts: [":paragraph"]) {
parent, reader, attributes ->
def upperLines = reader.readLines()
Expand All @@ -949,7 +949,7 @@ Groovy extensions can also be included as files.
.build.gradle
----
asciidoctorj {
extensions file('big.groovy')
docExtensions file('big.groovy')
}
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask {

/** Name one or more reveal.js plugins to activate.
*
* Plugins must match bundle names registered in the {@code revealjsPlugins} extensions.
* Plugins must match bundle names registered in the {@code revealjsPlugins} docExtensions.
* If selected plugins from a bundle is requires then they can be specified as {@code 'bundleName/pluginName'}.
*
* @param p List of plugins. Must be convertible to string.
Expand All @@ -163,7 +163,7 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask {

/** Name one or more reveal.js plugins to activate.
*
* Plugins must match bundle names registered in the {@code revealjsPlugins} extensions.
* Plugins must match bundle names registered in the {@code revealjsPlugins} docExtensions.
* If selected plugins from a bundle is requires then they can be specified as {@code 'bundleName/pluginName'}.
*
* @param p List of plugins. Must be convertible to string.
Expand All @@ -174,7 +174,7 @@ class AsciidoctorJRevealJSTask extends AbstractAsciidoctorTask {

/** Set reveal.js plugins to activate.
*
* Plugins must match bundle names registered in the {@code revealjsPlugins} extensions.
* Plugins must match bundle names registered in the {@code revealjsPlugins} docExtensions.
* If selected plugins from a bundle is requires then they can be specified as {@code 'bundleName/pluginName'}.
*
* @param p List of plugins. Must be convertible to string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ asciidoctorj {
}

asciidoctor {
configurations 'asciidocExt'
docExtensions 'asciidocExt'
inProcess JAVA_EXEC
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repositories {
}

asciidoctorj {
extensions project(':extension')
docExtensions project(':extension')
}

asciidoctor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ExtensionsFunctionalSpec extends FunctionalSpecification {
model.processMode, model.version, """
asciidoctor {
asciidoctorj {
extensions {
docExtensions {
block(name: "BIG", contexts: [":paragraph"]) {
parent, reader, attributes ->
def upperLines = reader.readLines()*.toUpperCase()
Expand Down Expand Up @@ -92,7 +92,7 @@ asciidoctor {
asciidoctor {
asciidoctorj {
extensions '''
docExtensions '''
block(name: 'BIG', contexts: [':paragraph']) {
parent, reader, attributes ->
def upperLines = reader.readLines()
Expand Down Expand Up @@ -136,7 +136,7 @@ block('small') {
model.processMode, model.version, """
asciidoctor {
asciidoctorj {
extensions file('src/docs/asciidoc/blockMacro.groovy')
docExtensions file('src/docs/asciidoc/blockMacro.groovy')
}
}
""")
Expand Down Expand Up @@ -164,7 +164,7 @@ asciidoctor {
getBuildFile(
model.processMode, model.version, '''
asciidoctorj {
extensions {
docExtensions {
postprocessor { document, output ->
return "Hi, Mom" + output
}
Expand Down Expand Up @@ -203,7 +203,7 @@ asciidoctor {
model.processMode, model.version, """
asciidoctor {
asciidoctorj {
extensions '''
docExtensions '''
postprocessor {
document, output ->
if (output.contains("blacklisted")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import static org.ysb33r.grolifant.api.StringUtils.stringize
class AsciidoctorCompatibilityTask extends DefaultTask {
private static final String PATH_SEPARATOR = OperatingSystem.current().pathSeparator
private static
final String MIGRATE_GEMS_MSG = 'When upgrading GEMs, \'requires\' will need to be set via the asciidoctorj project and task extensions. Use setGemPaths method in extension(s) to set GEM paths.'
final String MIGRATE_GEMS_MSG = 'When upgrading GEMs, \'requires\' will need to be set via the asciidoctorj project and task docExtensions. Use setGemPaths method in extension(s) to set GEM paths.'

private static final String DEFAULT_BACKEND = AsciidoctorBackend.HTML5.id
private boolean baseDirSetToNull
Expand Down Expand Up @@ -294,7 +294,7 @@ class AsciidoctorCompatibilityTask extends DefaultTask {
*/
@Deprecated
void extensions(Object... exts) {
migrationMessage('extensions', 'Extensions will need to be set via the asciidoctorj project and task extensions')
migrationMessage('docExtensions', 'Extensions will need to be set via the asciidoctorj project and task docExtensions')
if (!exts) return // null check
asciidoctorExtensions.addAll(exts as List)
}
Expand All @@ -307,7 +307,7 @@ class AsciidoctorCompatibilityTask extends DefaultTask {
@SuppressWarnings('ConfusingMethodName')
@Deprecated
void gemPath(Object... f) {
migrationMessage('gemPath', 'GEM paths will need to be set via the asciidoctorj project and task extensions using the gemPaths method')
migrationMessage('gemPath', 'GEM paths will need to be set via the asciidoctorj project and task docExtensions using the gemPaths method')
if (!f) return // null check
this.gemPaths.addAll(f as List)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ JRuby:
Asciidoctor:
${options.size()} options
${attributes.size()} attributes
${asciidoctorExtensions?.size() ?: 0} extensions
${asciidoctorExtensions?.size() ?: 0} docExtensions
logDocuments = ${logDocuments}, copyResources = ${copyResources}, safeMode = ${safeModeLevel}
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class AbstractAsciidoctorTask extends DefaultTask {
* conversion in parallel.
*
* When running sequential, the worker classloader, Asciidoctor instances
* and Asciidoctor extensions will be shared across all of the conversions.
* and Asciidoctor docExtensions will be shared across all of the conversions.
* When running parallel each conversion will be in a separate classloader,
* with a new Asciidoctor instance being initialised for every conversion.
*
* Sequential work might execute slightly faster, but if you have backend-specific
* extensions you might want to consider parallel mode (or use another Asciidoctor
* docExtensions you might want to consider parallel mode (or use another Asciidoctor
* task instance).
*
* Default is parallel.
Expand Down Expand Up @@ -448,7 +448,7 @@ class AbstractAsciidoctorTask extends DefaultTask {

/** Returns all of the specified configurations as a collections of files.
*
* If any extensions are dependencies then they will be included here too.
* If any docExtensions are dependencies then they will be included here too.
*
* @return FileCollection
*/
Expand Down Expand Up @@ -721,7 +721,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
*/
@Internal
protected List<Object> getAsciidoctorJExtensions() {
asciidoctorj.extensions
asciidoctorj.docExtensions
}

/** Obtains a source tree based on patterns.
Expand Down Expand Up @@ -948,7 +948,7 @@ class AbstractAsciidoctorTask extends DefaultTask {

@SuppressWarnings('Instanceof')
private FileCollection findDependenciesInExtensions() {
List<Dependency> deps = asciidoctorj.extensions.findAll {
List<Dependency> deps = asciidoctorj.docExtensions.findAll {
it instanceof Dependency
} as List<Dependency>

Expand All @@ -957,7 +957,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
}

if (!closurePaths.empty) {
// Jumping through hoops to make extensions based upon closures to work.
// Jumping through hoops to make docExtensions based upon closures to work.
closurePaths.add(getClassLocation(org.gradle.internal.scripts.ScriptOrigin))
closurePaths.addAll(ifNoGroovyAddLocal(deps))
}
Expand Down Expand Up @@ -1025,7 +1025,7 @@ class AbstractAsciidoctorTask extends DefaultTask {
}

private List<Closure> findExtensionClosures() {
asciidoctorj.extensions.findAll {
asciidoctorj.docExtensions.findAll {
it instanceof Closure
} as List<Closure>
}
Expand Down
Loading

0 comments on commit 7b0dc84

Please sign in to comment.