You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/01/15 02:34:17 UTC
[groovy] 01/02: Add docs for runtime groovydoc
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit f54a89df4b5edd24d31d52f8547f53cc9f8fccc5
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jan 15 09:34:45 2020 +0800
Add docs for runtime groovydoc
(cherry picked from commit 7d3b5bea85a0a4f7de17069dd31fadee43348410)
---
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:
+
+[source,groovy]
+----
+/**@
+ * 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