[groovy] branch master updated: Add docs for runtime groovydoc

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[groovy] branch master updated: Add docs for runtime groovydoc

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

The following commit(s) were added to refs/heads/master by this push:
     new 7d3b5be  Add docs for runtime groovydoc
7d3b5be is described below

commit 7d3b5bea85a0a4f7de17069dd31fadee43348410
Author: Daniel Sun <[hidden email]>
AuthorDate: Wed Jan 15 09:34:45 2020 +0800

    Add docs for runtime groovydoc
 src/spec/doc/core-syntax.adoc | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/spec/doc/core-syntax.adoc b/src/spec/doc/core-syntax.adoc
index 72c0a4b..2b947ee 100644
--- a/src/spec/doc/core-syntax.adoc
+++ b/src/spec/doc/core-syntax.adoc
@@ -70,6 +70,31 @@ include::{projectdir}/src/spec/test/SyntaxTest.groovy[tags=groovydoc_comment,ind
 Groovydoc follows the same conventions as Java's own Javadoc.
 So you'll be able to use the same tags as with Javadoc.
+In addition, Groovy supports *Runtime Groovydoc* since 3.0.0, i.e. Groovydoc can be retained at runtime.
+NOTE: Runtime Groovydoc is disabled by default. It can be enabled by adding JVM option `-Dgroovy.attach.runtime.groovydoc=true`
+The Runtime Groovydoc starts with `/\**@` and ends with `*/`, for example:
+ * Some class groovydoc for Foo
+ */
+class Foo {
+    /**@
+     * Some method groovydoc for bar
+     */
+    void bar() {
+    }
+assert Foo.class.groovydoc.content.contains('Some class groovydoc for Foo') // <1>
+assert Foo.class.getMethod('bar', new Class[0]).groovydoc.content.contains('Some method groovydoc for bar') // <2>
+<1> Get the runtime groovydoc for class `Foo`
+<2> Get the runtime groovydoc for method `bar`
 === Shebang line
 Beside the single-line comment, there is a special line comment, often called the _shebang_ line understood by UNIX systems

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun