Skip to content

Commit bde62d0

Browse files
committed
Fix doc generation
1 parent 7379d03 commit bde62d0

File tree

10 files changed

+71
-65
lines changed

10 files changed

+71
-65
lines changed

.github/workflows/gradle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ jobs:
8080
id: docs
8181
env:
8282
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
83-
run: ./gradlew docs --refresh-dependencies
83+
run: ./gradlew docs:docs --refresh-dependencies
8484
- name: "📤 Publish docs to Github Pages"
8585
if: steps.docs.outcome == 'success'
8686
uses: grails/github-pages-deploy-action@v2
8787
env:
8888
TARGET_REPOSITORY: ${{ github.repository }}
8989
GH_TOKEN: ${{ secrets.GH_TOKEN }}
9090
BRANCH: gh-pages
91-
FOLDER: build/docs
91+
FOLDER: docs/build/docs
9292
COMMIT_EMAIL: grails-build@users.noreply.github.com
9393
COMMIT_NAME: grails-build

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ jobs:
110110
- name: "📖 Generate documentation"
111111
env:
112112
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
113-
run: ./gradlew docs
113+
run: ./gradlew docs:docs
114114
- name: "📤 Publish documentation to Github Pages"
115115
if: success()
116116
uses: grails/github-pages-deploy-action@grails
117117
env:
118118
BETA: ${{ contains(needs.publish.outputs.release_version, 'M') || contains(needs.publish.outputs.release_version, 'RC') }}
119119
GH_TOKEN: ${{ secrets.GH_TOKEN }}
120120
BRANCH: gh-pages
121-
FOLDER: build/docs
121+
FOLDER: docs/build/docs
122122
VERSION: ${{ needs.publish.outputs.release_version }}
123123
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }}
124124
COMMIT_NAME: ${{ env.GIT_USER_NAME }}

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,3 @@ subprojects {
4646
}
4747
}
4848
}
49-
50-
apply from: rootProject.file("gradle/documentation-config.gradle")

docs/build.gradle

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,75 @@ apply plugin: 'groovy'
1313

1414
dependencies {
1515
implementation platform("org.grails:grails-bom:$grailsVersion")
16+
implementation 'org.apache.groovy:groovy-groovydoc'
17+
implementation 'org.apache.groovy:groovy-ant'
1618
implementation 'org.springframework:spring-core'
1719
}
1820

1921
tasks.register('resolveSpringVersion') {
2022
group = 'documentation'
2123
description = 'Resolve Spring Version from the BOM'
24+
2225
ext.resolved = configurations.compileClasspath
2326
.resolvedConfiguration
2427
.resolvedArtifacts
2528
.find {
2629
it.moduleVersion.id.group == 'org.springframework' &&
2730
it.moduleVersion.id.name.contains('spring-core')
2831
}.moduleVersion.id.version
32+
2933
logger.lifecycle('Resolved Spring Framework version for Guide links: {}', resolved)
3034
}
3135

36+
tasks.register('cleanDocs', Delete) {
37+
group = 'documentation'
38+
delete(project.layout.buildDirectory.dir('docs'))
39+
}
40+
41+
tasks.register('aggregateGroovydoc', Groovydoc) {
42+
group = 'documentation'
43+
description = 'Copies Groovy API Documentation for all supporting projects'
44+
45+
Set<Project> groovyDocProjects = rootProject.subprojects.findAll {
46+
it.name != 'docs' && !it.name.startsWith('example')
47+
}
48+
dependsOn(['cleanDocs'] + groovyDocProjects.collect { ":${it.name}:classes" as String })
49+
50+
source = groovyDocProjects.collectMany { prj ->
51+
def dirs = []
52+
// Always include main/groovy.
53+
dirs += prj.sourceSets.main.groovy.srcDirs
3254

33-
// TODO: PublishGuide should eventually ensure the build directory exists
34-
tasks.register('docsBuild') {
35-
doFirst {
36-
project.layout.buildDirectory.get().asFile.mkdirs()
55+
// If this subproject defines an “ast” source set, include it.
56+
def astSourceSet = prj.sourceSets.findByName('ast')
57+
if (astSourceSet != null) {
58+
dirs += astSourceSet.groovy.srcDirs
59+
}
60+
dirs
3761
}
38-
// Do not cache this task since the directory must exist if publishGuide is going to run
39-
outputs.upToDateWhen { false }
62+
63+
def groovydocClasspath = files(configurations.compileClasspath + groovyDocProjects.configurations.compileClasspath)
64+
classpath = groovydocClasspath
65+
groovyClasspath = groovydocClasspath
66+
67+
docTitle = "Grails Cache Plugin - ${project.version}"
68+
access = GroovydocAccess.PROTECTED
69+
includeAuthor = true
70+
includeMainForScripts = false
71+
processScripts = false
72+
73+
destinationDir = project.layout.buildDirectory.dir('docs/api').get().asFile
74+
75+
doLast { delete(project.layout.buildDirectory.dir('tmp')) }
76+
77+
inputs.files(source)
78+
outputs.dir(destinationDir)
4079
}
4180

4281
tasks.register('publishGuide', PublishGuide) {
4382
group = 'documentation'
4483
description = 'Generate Guide'
45-
dependsOn('docsBuild', 'resolveSpringVersion')
84+
dependsOn('aggregateGroovydoc', 'resolveSpringVersion')
4685

4786
targetDir = project.layout.buildDirectory.dir('docs').get().asFile
4887
outputs.dir(targetDir) // ensure gradle understands what this task generates
@@ -78,3 +117,8 @@ tasks.register('publishGuide', PublishGuide) {
78117
'''.stripIndent(8)
79118
}
80119
}
120+
121+
tasks.register('docs') {
122+
group = 'documentation'
123+
dependsOn('aggregateGroovydoc', 'publishGuide')
124+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
The Grails Cache plugin provides powerful and easy to use caching functionality to Grails applications and plugins.
22

3-
IMPORTANT: Cache version 4.0.0 and higher requires GORM 6.1.x or higher
3+
IMPORTANT: Cache version 8.0.0 and higher requires Grails 7 or later.

docs/src/main/docs/guide/introduction/changeLog.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[changeLog]]
22
=== Change log
33

4-
For recent versions please check the release notes https://github.com/grails-plugins/grails-cache/releases[here]
4+
For later versions please check the release notes https://github.com/grails-plugins/grails-cache/releases[here]
55

66
=== Version 4.0.0
77

docs/src/main/docs/guide/usage/unittests.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ method is invoked.
55

66
[source,groovy]
77
----
8-
include::{sourcedir}/grails-app/services/com/demo/BasicCachingService.groovy[tags=get_data,indent=0]
8+
include::{exampleSourcedir}/grails-app/services/com/demo/BasicCachingService.groovy[tags=get_data,indent=0]
99
----
1010

1111
[source,groovy]
1212
----
13-
include::{sourcedir}/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy[]
13+
include::{exampleSourcedir}/src/test/groovy/com/demo/BasicCachingServiceNoCacheManagerSpec.groovy[]
1414
----
1515

1616
In order for caching to be active when the unit test is running, cache manager
@@ -19,5 +19,5 @@ test.
1919

2020
[source,groovy]
2121
----
22-
include::{sourcedir}/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy[]
22+
include::{exampleSourcedir}/src/test/groovy/com/demo/BasicCachingServiceSpec.groovy[]
2323
----

example/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ bootRun {
7171
}
7272

7373
apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
74-
apply from: rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
74+
apply from: rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
75+
76+
// no groovy doc for example
77+
tasks.withType(Groovydoc).configureEach {
78+
enabled = false
79+
}

gradle/documentation-config.gradle

Lines changed: 0 additions & 46 deletions
This file was deleted.

plugin/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ dependencies {
4040

4141
apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
4242
apply from: rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
43+
44+
// groovy docs will be generated by the docs project
45+
tasks.withType(Groovydoc).configureEach {
46+
enabled = false
47+
}

0 commit comments

Comments
 (0)