Skip to content

Commit

Permalink
Fix binaryCacheDir / Add useMakeMode / Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
trustin committed Apr 5, 2020
1 parent 2f8ee2d commit 6e69091
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation(group: 'kr.motd.maven', name: 'sphinx-maven-plugin', version: '2.7.0') {
implementation(group: 'kr.motd.maven', name: 'sphinx-maven-plugin', version: '2.9.0') {
exclude group: 'org.apache.maven.shared', module: 'maven-filtering'
exclude group: 'org.apache.maven.reporting', module: 'maven-reporting-api'
exclude group: 'org.apache.maven.reporting', module: 'maven-reporting-impl'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=kr.motd.gradle
name=sphinx-gradle-plugin
version=2.8.1-SNAPSHOT
version=2.9.0-SNAPSHOT
24 changes: 20 additions & 4 deletions src/main/groovy/kr/motd/gradle/sphinx/gradle/SphinxTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SphinxTask extends DefaultTask {
def warningsAsErrors = { false }
def skip = { false }
def useDoctreeCache = { false }
def useMakeMode = { false }

private static def unwrap(Object o) {
if (o instanceof Callable) {
Expand All @@ -55,7 +56,9 @@ class SphinxTask extends DefaultTask {
@InputDirectory
@PathSensitive(PathSensitivity.RELATIVE)
File getBinaryCacheDir() {
return project.file(binaryCacheDir).getCanonicalFile()
def binaryCacheDir = project.file(this.binaryCacheDir)
binaryCacheDir.mkdirs()
return binaryCacheDir.getCanonicalFile()
}

void setBinaryCacheDir(Object binaryCacheDir) {
Expand Down Expand Up @@ -259,6 +262,19 @@ class SphinxTask extends DefaultTask {
setUseDoctreeCache(useDoctreeCache)
}

@Input
boolean getUseMakeMode() {
(useMakeMode instanceof Boolean ? useMakeMode : useMakeMode()).asBoolean()
}

void setUseMakeMode(Object useMakeMode) {
this.useMakeMode = useMakeMode
}

void useMakeMode(Object useMakeMode) {
setUseMakeMode(useMakeMode)
}

@Input
boolean getSkip() {
(skip instanceof Boolean ? skip : skip()).asBoolean()
Expand Down Expand Up @@ -296,6 +312,9 @@ class SphinxTask extends DefaultTask {
private List<String> getSphinxRunnerCmdLine() {
List<String> args = []

args.add(getUseMakeMode() ? '-M' : '-b')
args.add(getBuilder())

if (getVerbose()) {
args.add('-v')
} else {
Expand Down Expand Up @@ -328,9 +347,6 @@ class SphinxTask extends DefaultTask {

args.add('-n')

args.add('-b')
args.add(getBuilder())

args.add(getSourceDirectory().getPath())
args.add(getOutputDirectory().getPath())

Expand Down
4 changes: 2 additions & 2 deletions src/site/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

project = u'sphinx-gradle-plugin'
copyright = u'2017, Trustin Lee et al'
version = '2.8'
release = '2.8.0'
version = '2.9'
release = '2.9.0'

# General options
needs_sphinx = '1.0'
Expand Down
1 change: 1 addition & 0 deletions src/site/sphinx/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Parameter Description
``skip`` Whether Sphinx execution should be skipped. ``false``
``useDoctreeCache`` Whether doctree cache should be used. ``false``
``doctreeCacheDirectory`` The directory containing Sphinx doctree cache. Used only when ``useDoctreeCache`` is ``true`` ``${project.buildDir}/site/.doctrees``
``useMakeMode`` Whether Sphinx should use 'make mode' (``-M`` option) instead of 'build mode' (``-b`` option). ``false``
========================= ================================================================================================= ========================================

Sample Documentation Config
Expand Down
11 changes: 9 additions & 2 deletions src/test/groovy/kr/motd/gradle/sphinx/SphinxTaskTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ class SphinxTaskTest {
assert !task.warningsAsErrors
assert !task.useDoctreeCache
assert task.doctreeCacheDirectory == null
assert !task.useMakeMode
}

@Test
void testOverriddenProperties() {
task.sourceDirectory "${project.projectDir}/src/my/sphinx"
task.outputDirectory "${project.buildDir}/my/sphinx"
task.binaryCacheDir "${project.buildDir}/my/cache"
task.builder 'mo'
task.tags 'foo', 'bar'
task.verbose false
Expand All @@ -49,11 +51,15 @@ class SphinxTaskTest {
task.skip true
task.warningsAsErrors true
task.useDoctreeCache true
task.useMakeMode true

assert "${task.getSourceDirectory()}" ==
assert "${task.sourceDirectory}" ==
"${project.projectDir}${File.separator}src${File.separator}my${File.separator}sphinx"
assert "${task.getOutputDirectory()}" ==
assert "${task.outputDirectory}" ==
"${project.buildDir}${File.separator}my${File.separator}sphinx"
assert "${task.binaryCacheDir}" ==
"${project.buildDir}${File.separator}my${File.separator}cache"
assert task.binaryCacheDir.isDirectory()

assert task.builder == 'mo'
assert task.tags == [ "foo", "bar" ]
Expand All @@ -65,6 +71,7 @@ class SphinxTaskTest {
assert task.useDoctreeCache
assert "${task.doctreeCacheDirectory}" ==
"${project.buildDir}${File.separator}site${File.separator}.doctrees"
assert task.useMakeMode

task.doctreeCacheDirectory "${project.buildDir}/my/doctree-cache"
assert task.doctreeCacheDirectory.isDirectory()
Expand Down

0 comments on commit 6e69091

Please sign in to comment.