Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Documentation from gdoc to asciidoc #64

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ on:
types: [opened, reopened, synchronize]
pull_request_target:
types: [opened, reopened, synchronize]
workflow_dispatch:

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: read # limit to read access
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: "📝 Update Release Draft"
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'java-library'
id 'io.github.gradle-nexus.publish-plugin'
id 'maven-publish'
id 'org.asciidoctor.jvm.convert' version '4.0.2'
id 'signing'
}

Expand Down
49 changes: 39 additions & 10 deletions gradle/documentation-config.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import org.grails.gradle.plugin.doc.PublishGuideTask

apply plugin: 'org.grails.grails-doc'

configurations.register('groovydocConfiguration')
configurations.register('guideConfiguration')

dependencies {

add('groovydocConfiguration', localGroovy(), {
because 'groovydoc needs to run with the same version as Gradle'
})

add('guideConfiguration', libs.grails.docs)
add('guideConfiguration', libs.groovy.templates)
add('guideConfiguration', libs.slf4j.nop) // Get rid of logs during guide generation
Expand All @@ -25,8 +19,43 @@ tasks.withType(Groovydoc).configureEach {
groovyClasspath = configurations.groovydocConfiguration
}

tasks.withType(PublishGuideTask).configureEach {
classpath = configurations.guideConfiguration
javadocDir = null
propertiesFile = layout.projectDirectory.file('src/docs/guide.properties').asFile
asciidoctor {
baseDir = file('src/docs')
sourceDir = file('src/docs')
outputDir = file('build/docs/manual')
sources {
include 'index.adoc'
}
jvm {
jvmArgs += [
'--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED',
'--add-opens', 'java.base/java.io=ALL-UNNAMED'
]
}
attributes = [
copyright : 'Apache License, Version 2.0',
docinfo1 : 'true',
doctype : 'book',
encoding : 'utf-8',
icons : 'font',
id : "$rootProject.name:$projectVersion",
idprefix : '',
idseparator : '-',
lang : 'en',
linkattrs : true,
numbered : '',
producer : 'Asciidoctor',
revnumber : projectVersion,
setanchors : true,
'source-highlighter' : 'prettify',
toc : 'left',
toc2 : '',
toclevels : '2',
projectVersion : projectVersion
]
}

tasks.register('docs') {
group = 'documentation'
dependsOn 'asciidoctor', 'groovydoc'
}
33 changes: 33 additions & 0 deletions src/docs/1. Introduction.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
== Introduction

The Grails Mail Plugin provides a convenient DSL for _sending_ email. It supports plain-text, html, attachments, inline
resources and i18n among other features.

Email can be sent using the `mailService` via the `sendMail` method.

Here is an example…

[source,groovy]
----
mailService.sendMail {
to 'fred@gmail.com', 'ginger@gmail.com'
from 'john@gmail.com'
cc 'marge@gmail.com', 'ed@gmail.com'
bcc 'joe@gmail.com'
subject 'Hello John'
text 'Here it some text'
}
----

Here we are sending a plain-text email with no attachments to the given addresses.

The `sendMail` method is injected into all Controllers to simplify access:

[source,groovy]
----
sendMail {
to 'fred@g2one.com'
subject 'Hello Fred'
text 'How are you?'
}
----
49 changes: 49 additions & 0 deletions src/docs/2.1 SMTP Server Configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
=== SMTP Server Configuration

By default, the plugin assumes an unsecured mail server configured on port 25, getting the SMTP host name from the
environment variable SMTP_HOST. However, you can change this via the `grails-app/conf/application.groovy` file.

Here is an example how you would configure the default sender to send with a Gmail account:

[source,groovy]
----
grails {
mail {
host = 'smtp.gmail.com'
port = 465
username = 'youracount@gmail.com'
password = 'yourpassword'
props = [
'mail.smtp.auth': 'true',
'mail.smtp.socketFactory.port': '465',
'mail.smtp.socketFactory.class': 'javax.net.ssl.SSLSocketFactory',
'mail.smtp.socketFactory.fallback': 'false'
]
}
}
----

And the configuration for sending via a Hotmail/Live account:

[source,groovy]
----
grails {
mail {
host = 'smtp.live.com'
port = 587
username = 'youracount@live.com'
password = 'yourpassword'
props = [
'mail.smtp.starttls.enable': 'true',
'mail.smtp.port': '587'
]
}
}
----

If your mail session is provided via JNDI, you can use the `jndiName` setting:

[source,groovy]
----
grails.mail.jndiName = 'myMailSession'
----
18 changes: 18 additions & 0 deletions src/docs/2.2 Defaults Configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=== Defaults Configuration

You can set various _default_ settings via the application configuration that will be used in the absence of explicit
values when sending email.

You can also set the default "from" address to use for messages in `application.groovy` using:

[source,groovy]
----
grails.mail.default.from = 'server@yourhost.com'
----

You can also set the default "to" address to use for messages in `application.groovy` using:

[source,groovy]
----
grails.mail.default.to = 'user@yourhost.com'
----
27 changes: 27 additions & 0 deletions src/docs/2.3 Other Configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
=== Disabling Email Sending

You can completely disable the sending of email by setting:

[source,groovy]
----
grails.mail.disabled = true
----

You may want to set this value for the development and/or test environments. However, this will treat any call to
`mailService.sendMail()` as a no-op which means that the mail plugin will not attempt to render the email message or
assemble any attachments. This can hide issues such as incorrect view names, invalid or non-existent configuration
during development.

Consider using the https://github.com/gpc/greenmail[Greenmail Plugin] which allows you to start an in memory test SMTP
server for local development. This allows you to test more of your code.

=== Overriding Addresses

An alternative to disabling email or using something like the http://www.grails.org/plugin/greenmail[Greenmail Plugin]
, is to use the `overrideAddress` config setting for your development and/or test environment to force all email to be
delivered to a specific address, regardless of what the addresses were at send time:

[source,groovy]
----
grails.mail.overrideAddress = 'test@address.com'
----
42 changes: 42 additions & 0 deletions src/docs/3. Sending Email.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
== Sending Emails

Email is sent using the `sendMail()` method of the `mailService`. This plugin also adds a shortcut `sendMail()` method
to all Controllers and Services in your application that simply delegates to the `mailService`. There is no difference
between the two methods so the choice is stylistic.

[source,groovy]
----
class PersonController {

def create = {
// create user

sendMail {
from 'admin@mysystem.com'
subject 'New user'
text 'A new user has been created'
}
}
}
----

[source,groovy]
----
class PersonController {

def mailService

def create = {
// create user

mailService.sendMail {
from 'admin@mysystem.com'
subject 'New user'
text 'A new user has been created'
}
}
}
----

The `sendMail()` method takes a single `Closure` argument that uses a DSL (Domain Specific Language) to configure the
message to be sent. This section describes the aspects of the DSL.
51 changes: 51 additions & 0 deletions src/docs/3.1 Sender And Recipient.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
=== Recipients

The DSL provides `to`, `cc` and `bcc` methods that allow you to set one or more address values for these recipient types.

[source,groovy]
----
sendMail {
to 'someone@org.com'
cc 'manager@org.com'
bcc 'employee1@org.com', 'employee2@org.com'
// ...
}
----

All methods take one or more String values that are email addresses using the syntax
of http://www.ietf.org/rfc/rfc822.txt.[RFC822]. Typical address syntax is of the form `"user@host.domain"` or
`"Personal Name <user@host.domain>"`.

You can supply multiple values for `to`, `cc` and `bcc`.

[source,groovy]
----
sendMail {
to 'someone@org.com', 'someone.else@org.com'
// …
}
----

If no value is provided for `to` when sending an email, the _default to-address_ will be used.

WARNING: If the configuration property `grails.mail.overrideAddress` is set, each recipient address specified will be
substituted with the override address. See the configuration section for more information.


=== Sender

The sender address of the email is configured with the `from` method.

[source,groovy]
----
sendMail {
from 'me@org.com'
// …
}
----

The `from` method accepts one String value email address using the syntax of
https://www.ietf.org/rfc/rfc822.txt.[RFC822]. Typical address syntax is of the form `"user@host.domain"` or
`"Personal Name <user@host.domain>"`.

If no value is provided for `from` when sending an email, the _default from-address_ will be used.
Loading
Loading