|
Groovy example source code file (SimpleGroovyDoc.java)
The Groovy SimpleGroovyDoc.java source code
/*
* Copyright 2003-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.tools.groovydoc;
import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
import org.codehaus.groovy.groovydoc.GroovyDoc;
import org.codehaus.groovy.groovydoc.GroovyTag;
import java.text.BreakIterator;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SimpleGroovyDoc implements GroovyDoc, GroovyTokenTypes {
private static final Pattern TAG2_PATTERN = Pattern.compile("(?s)([a-z]+)\\s+(.*)");
private static final Pattern TAG3_PATTERN = Pattern.compile("(?s)([a-z]+)\\s+(\\S*)\\s+(.*)");
private String name;
private String commentText = null;
private String rawCommentText = "";
private String firstSentenceCommentText = null;
private int definitionType;
private boolean deprecated;
private boolean isScript;
private GroovyTag[] tags;
public SimpleGroovyDoc(String name) {
this.name = name;
definitionType = CLASS_DEF;
}
public String name() {
return name;
}
public String toString() {
return "" + getClass() + "(" + name + ")";
}
protected void setCommentText(String commentText) {
this.commentText = commentText;
}
protected void setFirstSentenceCommentText(String firstSentenceCommentText) {
this.firstSentenceCommentText = firstSentenceCommentText;
}
public String commentText() {
return commentText;
}
public String firstSentenceCommentText() {
return firstSentenceCommentText;
}
public String getRawCommentText() {
return rawCommentText;
}
public void setRawCommentText(String rawCommentText) {
this.rawCommentText = rawCommentText;
calculateTags(rawCommentText);
}
public void setScript(boolean script) {
isScript = script;
}
private void calculateTags(String rawCommentText) {
String trimmed = rawCommentText.replaceFirst("(?s).*?\\*\\s*@", "@");
if (trimmed.equals(rawCommentText)) return;
String cleaned = trimmed.replaceAll("(?m)^\\s*\\*\\s*([^*]*)$", "$1").trim();
String[] split = cleaned.split("(?m)^@");
List<GroovyTag> result = new ArrayList
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy SimpleGroovyDoc.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.