Skip to content

Commit 77c2690

Browse files
committed
Use 'grace-doc' Gradle plugin to generate documentation
Closes gh-66
1 parent 835d0ac commit 77c2690

28 files changed

+636
-465
lines changed

build.gradle

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ group = "org.graceframework.plugins"
2424

2525
apply plugin: "eclipse"
2626
apply plugin: "idea"
27+
apply plugin: "groovy"
2728
apply plugin: "java-library"
29+
apply plugin: "org.graceframework.grace-doc"
2830
apply plugin: "org.graceframework.grace-plugin"
2931
apply plugin: "org.graceframework.grace-gsp"
3032
apply plugin: "io.github.gradle-nexus.publish-plugin"
@@ -83,12 +85,6 @@ dependencies {
8385
}
8486
}
8587

86-
groovydoc.doFirst {
87-
classpath += (configurations.documentation + configurations.compileClasspath)
88-
}
89-
90-
bootJar.enabled = false
91-
9288
java {
9389
toolchain {
9490
languageVersion = JavaLanguageVersion.of(17)
@@ -105,6 +101,46 @@ tasks.named('compileJava') {
105101
inputs.files(tasks.named('processResources'))
106102
}
107103

104+
105+
def cleanTask = project.tasks.findByName('clean')
106+
if (cleanTask == null) {
107+
task clean(type: Delete) {
108+
delete(buildDir)
109+
}
110+
}
111+
else {
112+
cleanTask.doLast {
113+
ant.delete(dir: 'build/docs')
114+
}
115+
}
116+
117+
tasks.withType(Groovydoc) {
118+
group = 'Documentation'
119+
docTitle = "Grace Fields - ${project.version}"
120+
destinationDir = project.file('build/docs/manual/api')
121+
def files = []
122+
project.rootProject.subprojects
123+
.findAll { !it.name != 'docs' && !it.name.startsWith('examples') }
124+
.each { subproject ->
125+
if(subproject.file('src/main/groovy').exists()) {
126+
files += subproject.files('src/main/groovy')
127+
}
128+
if(subproject.file('src/main/java').exists()) {
129+
files += subproject.files('src/main/java')
130+
}
131+
}
132+
if (project.file('src/main/groovy').exists()) {
133+
files += project.files('src/main/groovy')
134+
}
135+
source = files
136+
classpath += configurations.documentation
137+
}
138+
139+
docs {
140+
dependsOn groovydoc
141+
sourceDir = project.file('src/docs')
142+
}
143+
108144
publishing {
109145
publications {
110146
maven(MavenPublication) {

gradle.properties

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ javaParserCoreVersion=3.26.4
77
joddWotVersion=3.3.8
88
objenesisVersion=3.4
99
scaffoldingVersion=6.3.0-RC1
10-
asciidoc=true
11-
githubSlug=graceframework/grace-fields
12-
githubBranch=master
13-
title=Grace Fields Plugin
14-
projectDesc=Customizable form-field rendering based on overrideable GSP template
15-
guide=../../guide
16-
projectUrl=https://github.com/graceframework/grace-fields
17-
developers=Michael Yan
10+
org.gradle.parallel=true
11+
org.gradle.caching=true
12+
org.gradle.daemon=true

src/main/docs/guide/customizingFieldRendering.adoc renamed to src/docs/guide/customizingFieldRendering.adoc

Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ names are summarized below:
2727

2828

2929
Users upgrading to 1.5 from a previous version should either rename their templates (recommended) or add the following
30-
to `grails-app/conf/application.yml` to change the default templates names to the old names
30+
to `app/conf/application.yml` to change the default templates names to the old names
3131

3232
[source,groovy]
3333
----
@@ -46,42 +46,42 @@ grails:
4646

4747
The template for a field is chosen by a convention using the names of the controller, action, bean class, bean property, theme, etc. All the tags will look for templates in the following directories in decreasing order of preference:
4848

49-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyName*/_themes/*themeName*/`
50-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/_themes/*themeName*/*propertyType*/`
51-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/_themes/*themeName*/`
52-
* `grails-app/views/*controllerNamespace*/*controllerName*/*propertyName*/_themes/*themeName*/`
53-
* `grails-app/views/*controllerNamespace*/*controllerName*/_themes/*themeName*/*propertyType*/`
54-
* `grails-app/views/*controllerNamespace*/*controllerName*/_themes/*themeName*/`
55-
* `grails-app/views/*controllerName*/*actionName*/*propertyName*/_themes/*themeName*/`
56-
* `grails-app/views/*controllerName*/*actionName*/_themes/*themeName*/*propertyType*/`
57-
* `grails-app/views/*controllerName*/*actionName*/_themes/*themeName*/`
58-
* `grails-app/views/*controllerName*/*propertyName*/_themes/*themeName*/`
59-
* `grails-app/views/*controllerName*/_themes/*themeName*/*propertyType*/`
60-
* `grails-app/views/*controllerName*/_themes/*themeName*/`
61-
* `grails-app/views/_fields/_themes/*themeName*/*class*/*propertyName*/`
62-
* `grails-app/views/_fields/_themes/*themeName*/*superclass*/*propertyName*/`
63-
* `grails-app/views/_fields/_themes/*themeName*/*associationType*/`
64-
* `grails-app/views/_fields/_themes/*themeName*/*propertyType*/`
65-
* `grails-app/views/_fields/_themes/*themeName*/*propertySuperclass*/`
66-
* `grails-app/views/_fields/_themes/*themeName*/default/`
67-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyName*/`
68-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyType*/`
69-
* `grails-app/views/*controllerNamespace*/*controllerName*/*actionName*/`
70-
* `grails-app/views/*controllerNamespace*/*controllerName*/*propertyName*/`
71-
* `grails-app/views/*controllerNamespace*/*controllerName*/*propertyType*/`
72-
* `grails-app/views/*controllerNamespace*/*controllerName*/`
73-
* `grails-app/views/*controllerName*/*actionName*/*propertyName*/`
74-
* `grails-app/views/*controllerName*/*actionName*/*propertyType*/`
75-
* `grails-app/views/*controllerName*/*actionName*/`
76-
* `grails-app/views/*controllerName*/*propertyName*/`
77-
* `grails-app/views/*controllerName*/*propertyType*/`
78-
* `grails-app/views/*controllerName*/`
79-
* `grails-app/views/_fields/*class*/*propertyName*/`
80-
* `grails-app/views/_fields/*superclass*/*propertyName*/`
81-
* `grails-app/views/_fields/*associationType*/`
82-
* `grails-app/views/_fields/*propertyType*/`
83-
* `grails-app/views/_fields/*propertySuperclass*/`
84-
* `grails-app/views/_fields/default/`
49+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyName*/_themes/*themeName*/`
50+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/_themes/*themeName*/*propertyType*/`
51+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/_themes/*themeName*/`
52+
* `app/views/*controllerNamespace*/*controllerName*/*propertyName*/_themes/*themeName*/`
53+
* `app/views/*controllerNamespace*/*controllerName*/_themes/*themeName*/*propertyType*/`
54+
* `app/views/*controllerNamespace*/*controllerName*/_themes/*themeName*/`
55+
* `app/views/*controllerName*/*actionName*/*propertyName*/_themes/*themeName*/`
56+
* `app/views/*controllerName*/*actionName*/_themes/*themeName*/*propertyType*/`
57+
* `app/views/*controllerName*/*actionName*/_themes/*themeName*/`
58+
* `app/views/*controllerName*/*propertyName*/_themes/*themeName*/`
59+
* `app/views/*controllerName*/_themes/*themeName*/*propertyType*/`
60+
* `app/views/*controllerName*/_themes/*themeName*/`
61+
* `app/views/_fields/_themes/*themeName*/*class*/*propertyName*/`
62+
* `app/views/_fields/_themes/*themeName*/*superclass*/*propertyName*/`
63+
* `app/views/_fields/_themes/*themeName*/*associationType*/`
64+
* `app/views/_fields/_themes/*themeName*/*propertyType*/`
65+
* `app/views/_fields/_themes/*themeName*/*propertySuperclass*/`
66+
* `app/views/_fields/_themes/*themeName*/default/`
67+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyName*/`
68+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/*propertyType*/`
69+
* `app/views/*controllerNamespace*/*controllerName*/*actionName*/`
70+
* `app/views/*controllerNamespace*/*controllerName*/*propertyName*/`
71+
* `app/views/*controllerNamespace*/*controllerName*/*propertyType*/`
72+
* `app/views/*controllerNamespace*/*controllerName*/`
73+
* `app/views/*controllerName*/*actionName*/*propertyName*/`
74+
* `app/views/*controllerName*/*actionName*/*propertyType*/`
75+
* `app/views/*controllerName*/*actionName*/`
76+
* `app/views/*controllerName*/*propertyName*/`
77+
* `app/views/*controllerName*/*propertyType*/`
78+
* `app/views/*controllerName*/`
79+
* `app/views/_fields/*class*/*propertyName*/`
80+
* `app/views/_fields/*superclass*/*propertyName*/`
81+
* `app/views/_fields/*associationType*/`
82+
* `app/views/_fields/*propertyType*/`
83+
* `app/views/_fields/*propertySuperclass*/`
84+
* `app/views/_fields/default/`
8585

8686
The variables referenced in these paths are:
8787

@@ -123,7 +123,7 @@ All class names are camel-cased simple forms. For example `java.lang.String` bec
123123

124124
Templates are resolved in this order so that you can override in the more specific circumstance and fall back to successively more general defaults. For example, you can define a field template for all `java.lang.String` properties but override a specific property of a particular class to use more specialized rendering.
125125

126-
Templates in plugins are resolved as well. This means plugins such as `Joda Time` can provide default rendering for special property types. A template in your application will take precedence over a template in a plugin at the same 'level'. For example if a plugin provides a `grails-app/views/_fields/string/_widget.gsp` the same template in your application will override it but if the plugin provides `grails-app/views/_fields/person/name/_widget.gsp` it would be used in preference to the more general template in your application.
126+
Templates in plugins are resolved as well. This means plugins such as `Joda Time` can provide default rendering for special property types. A template in your application will take precedence over a template in a plugin at the same 'level'. For example if a plugin provides a `app/views/_fields/string/_widget.gsp` the same template in your application will override it but if the plugin provides `app/views/_fields/person/name/_widget.gsp` it would be used in preference to the more general template in your application.
127127

128128
For most properties the out-of-the-box defaults should provide a good starting point.
129129

@@ -135,45 +135,45 @@ Imagine an object of class `Employee` that extends the class `Person` and has a
135135

136136
You can override the template `f:field` uses with any of these:
137137

138-
* `grails-app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_wrapper.gsp`
139-
* `grails-app/views/*controllerName*/*actionName*/name/_wrapper.gsp`
140-
* `grails-app/views/*controllerName*/*actionName*/string/_wrapper.gsp`
141-
* `grails-app/views/*controllerName*/*actionName*/_wrapper.gsp`
142-
* `grails-app/views/*controllerName*/name/_wrapper.gsp`
143-
* `grails-app/views/*controllerName*/string/_wrapper.gsp`
144-
* `grails-app/views/*controllerName*/_wrapper.gsp`
145-
* `grails-app/views/_fields/employee/name/_wrapper.gsp`
146-
* `grails-app/views/_fields/person/name/_wrapper.gsp`
147-
* `grails-app/views/_fields/string/_wrapper.gsp`
148-
* `grails-app/views/_fields/default/_wrapper.gsp`
138+
* `app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_wrapper.gsp`
139+
* `app/views/*controllerName*/*actionName*/name/_wrapper.gsp`
140+
* `app/views/*controllerName*/*actionName*/string/_wrapper.gsp`
141+
* `app/views/*controllerName*/*actionName*/_wrapper.gsp`
142+
* `app/views/*controllerName*/name/_wrapper.gsp`
143+
* `app/views/*controllerName*/string/_wrapper.gsp`
144+
* `app/views/*controllerName*/_wrapper.gsp`
145+
* `app/views/_fields/employee/name/_wrapper.gsp`
146+
* `app/views/_fields/person/name/_wrapper.gsp`
147+
* `app/views/_fields/string/_wrapper.gsp`
148+
* `app/views/_fields/default/_wrapper.gsp`
149149

150150
override the template `f:widget` uses with any of these:
151151

152-
* `grails-app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_widget.gsp`
153-
* `grails-app/views/*controllerName*/*actionName*/name/_widget.gsp`
154-
* `grails-app/views/*controllerName*/*actionName*/string/_widget.gsp`
155-
* `grails-app/views/*controllerName*/*actionName*/_widget.gsp`
156-
* `grails-app/views/*controllerName*/name/_widget.gsp`
157-
* `grails-app/views/*controllerName*/string/_widget.gsp`
158-
* `grails-app/views/*controllerName*/_widget.gsp`
159-
* `grails-app/views/_fields/employee/name/_widget.gsp`
160-
* `grails-app/views/_fields/person/name/_widget.gsp`
161-
* `grails-app/views/_fields/string/_widget.gsp`
162-
* `grails-app/views/_fields/default/_widget.gsp`
152+
* `app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_widget.gsp`
153+
* `app/views/*controllerName*/*actionName*/name/_widget.gsp`
154+
* `app/views/*controllerName*/*actionName*/string/_widget.gsp`
155+
* `app/views/*controllerName*/*actionName*/_widget.gsp`
156+
* `app/views/*controllerName*/name/_widget.gsp`
157+
* `app/views/*controllerName*/string/_widget.gsp`
158+
* `app/views/*controllerName*/_widget.gsp`
159+
* `app/views/_fields/employee/name/_widget.gsp`
160+
* `app/views/_fields/person/name/_widget.gsp`
161+
* `app/views/_fields/string/_widget.gsp`
162+
* `app/views/_fields/default/_widget.gsp`
163163

164164
And override the template _f:display_ uses with any of these:
165165

166-
* `grails-app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_displayWrapper.gsp`
167-
* `grails-app/views/*controllerName*/*actionName*/name/_displayWrapper.gsp`
168-
* `grails-app/views/*controllerName*/*actionName*/string/_displayWrapper.gsp`
169-
* `grails-app/views/*controllerName*/*actionName*/_displayWrapper.gsp`
170-
* `grails-app/views/*controllerName*/name/_displayWrapper.gsp`
171-
* `grails-app/views/*controllerName*/string/_displayWrapper.gsp`
172-
* `grails-app/views/*controllerName*/_displayWrapper.gsp`
173-
* `grails-app/views/_fields/employee/name/_displayWrapper.gsp`
174-
* `grails-app/views/_fields/person/name/_displayWrapper.gsp`
175-
* `grails-app/views/_fields/string/_displayWrapper.gsp`
176-
* `grails-app/views/_fields/default/_displayWrapper.gsp`
166+
* `app/views/*controllerName*/*actionName*/name/_themes/*themeName*/_displayWrapper.gsp`
167+
* `app/views/*controllerName*/*actionName*/name/_displayWrapper.gsp`
168+
* `app/views/*controllerName*/*actionName*/string/_displayWrapper.gsp`
169+
* `app/views/*controllerName*/*actionName*/_displayWrapper.gsp`
170+
* `app/views/*controllerName*/name/_displayWrapper.gsp`
171+
* `app/views/*controllerName*/string/_displayWrapper.gsp`
172+
* `app/views/*controllerName*/_displayWrapper.gsp`
173+
* `app/views/_fields/employee/name/_displayWrapper.gsp`
174+
* `app/views/_fields/person/name/_displayWrapper.gsp`
175+
* `app/views/_fields/string/_displayWrapper.gsp`
176+
* `app/views/_fields/default/_displayWrapper.gsp`
177177

178178
During template development it is usually recommended to disable template caching in order to allow the plugin to recognize new/renamed/moved templates without restarting the application. See the "Performance" section of the guide for the exact settings.
179179

@@ -194,8 +194,7 @@ grails:
194194
----
195195

196196

197-
=== Default Behaviour - Using Grails Widget Tags
198-
197+
=== Default Behaviour - Using Grace Widget Tags
199198

200199
If no template override is found the plugin will use the standard grails input tags (e.g. `g:select`, `g:checkbox`, `g:field`) for rendering input controls.
201200
Using `f:field` you can pass extra arguments (e.g. `optionKey`, `optionValue`) through to these tags by prefixing them with `widget-`, e.g.
@@ -208,7 +207,6 @@ Using `f:field` you can pass extra arguments (e.g. `optionKey`, `optionValue`) t
208207

209208
=== Template parameters
210209

211-
212210
The `f:field` and `f:widget` tags will pass the following parameters to your templates or to the body of `f:field` if you use one:
213211

214212
.Template Parameters
@@ -276,7 +274,6 @@ NOTE: If the `bean` attribute was not supplied to `f:field` then `bean`, `type`,
276274

277275
=== Field labels
278276

279-
280277
If the `label` attribute is not supplied to the `f:field` tag then the label string passed to the field template is resolved by convention. The plugin uses the following order of preference for the label:
281278

282279
* An i18n message using the key '_beanClass_._path_`.label`'. For example when using `<f:field bean="personInstance" property="address.city"/>` the plugin will try the i18n key `person.address.city.label`. If the property path contains any index it is removed so `<f:field bean="authorInstance" property="books<<0>>.title"/>` would use the key `author.books.title.label`.
@@ -286,7 +283,6 @@ If the `label` attribute is not supplied to the `f:field` tag then the label str
286283

287284
=== Locating Field Templates Directly
288285

289-
290286
Rather than relying on the convention described previously to locate the template(s) to be used for a particular field, it is
291287
instead possible to directly specify the directory containing the templates. This feature was introduced in version 1.5.
292288

@@ -322,7 +318,6 @@ by convention.
322318

323319
=== Locating Templates Directly Example
324320

325-
326321
[source,groovy]
327322
----
328323
// renders _fields/\_themes/bs-horizontal/custom/_wrapper.gsp:

src/main/docs/guide/embeddedProperties.adoc renamed to src/docs/guide/embeddedProperties.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Embedded properties are handled in a special way by the `f:field` and `f:all` ta
1212
</fieldset>
1313
----
1414

15-
You can customize how embedded properties are surrounded by providing a layout at `grails-app/views/layouts/_fields/embedded.gsp` which will override the default layout provided by the plugin.
15+
You can customize how embedded properties are surrounded by providing a layout at `app/views/layouts/_fields/embedded.gsp` which will override the default layout provided by the plugin.
1616

1717
When you use the `f:all` tag it will automatically handle embedded properties in this way.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
== Including Templates in Plugins
22

3-
Plugins can include field and/or input level templates to support special UI rendering or non-standard property types. Just include the templates in the plugin's `grails-app/views` directory as described in the <<customizingFieldRendering,Customizing Field Rendering>> section.
3+
Plugins can include field and/or input level templates to support special UI rendering or non-standard property types. Just include the templates in the plugin's `app/views` directory as described in the <<customizingFieldRendering,Customizing Field Rendering>> section.
44

55
WARNING: If you supply templates in a plugin you should consider declaring a `<%@page defaultCodec="html" %>` directive so that any HTML unsafe property values are escaped properly regardless of the default codec used by client apps.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ include::ref/Tags/display.adoc[]
5353
include::ref/Tags/displayWidget.adoc[]
5454

5555
[[ref-tags-field]]
56-
==== field
56+
== field
5757

5858
include::ref/Tags/field.adoc[]
5959

src/docs/guide/introduction.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
== Introduction
2+
3+
The _Fields plugin_ allows you to customize the rendering of input fields for properties of domain objects, command beans and POGOs based on their type, name, etc. The plugin aims to:
4+
5+
* Use good defaults for fields.
6+
* Make it very easy to override the field rendering for particular properties or property types without having to replace entire form templates.
7+
* Not require you to copy and paste markup for containers, labels and error messages just because you need a different input type.
8+
* Support inputs for property paths of arbitrary depth and with indexing.
9+
* Enable other plugins to provide field rendering for special property types that gets picked up automatically (e.g. the _Joda Time_ plugin can provide templates for the various date/time types).
10+
* Support embedded properties of _GORM_ domain classes.
11+
12+
== Changelog
13+
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Scaffolding templates based on the _Fields_ plugin are quite powerful as they will pick up field and input rendering templates from your application and any plugins that provide them. This means that the useful life of scaffolding templates should be much longer as you do not need to replace the entire _create.gsp_ and/or _edit.gsp_ template just because you want to do something different with a certain property of one particular class.
22

3-
The plugin makes the _renderEditor.template_ file used by standard Grails scaffolding redundant. This template was very limited because it could not be extended by plugins or applications (only replaced) and was unable to support embedded properties of domain classes.
3+
The plugin makes the _renderEditor.template_ file used by standard Grace scaffolding redundant. This template was very limited because it could not be extended by plugins or applications (only replaced) and was unable to support embedded properties of domain classes.
44

55
The _Fields_ plugin includes scaffolding templates you can use in your application by running:
66

77
[source,groovy]
88
----
9-
grails install-form-fields-templates
9+
grace install-form-fields-templates
1010
----
1111

1212
This will overwrite any _create.gsp_ and _edit.gsp_ files you have in `src/templates/scaffolding`.

0 commit comments

Comments
 (0)