static String decodeJavadocTags()

in maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/GeneratorUtils.java [171:221]


    static String decodeJavadocTags(String description) {
        if (description == null || description.isEmpty()) {
            return "";
        }

        StringBuffer decoded = new StringBuffer(description.length() + 1024);

        Matcher matcher = Pattern.compile("\\{@(\\w+)\\s*([^\\}]*)\\}").matcher(description);
        while (matcher.find()) {
            String tag = matcher.group(1);
            String text = matcher.group(2);
            text = text.replace("&", "&");
            text = text.replace("<", "&lt;");
            text = text.replace(">", "&gt;");
            if ("code".equals(tag)) {
                text = "<code>" + text + "</code>";
            } else if ("link".equals(tag) || "linkplain".equals(tag) || "value".equals(tag)) {
                String pattern = "(([^#\\.\\s]+\\.)*([^#\\.\\s]+))?" + "(#([^\\(\\s]*)(\\([^\\)]*\\))?\\s*(\\S.*)?)?";
                final int label = 7;
                final int clazz = 3;
                final int member = 5;
                final int args = 6;
                Matcher link = Pattern.compile(pattern).matcher(text);
                if (link.matches()) {
                    text = link.group(label);
                    if (text == null || text.isEmpty()) {
                        text = link.group(clazz);
                        if (text == null || text.isEmpty()) {
                            text = "";
                        }
                        if (StringUtils.isNotEmpty(link.group(member))) {
                            if (text != null && !text.isEmpty()) {
                                text += '.';
                            }
                            text += link.group(member);
                            if (StringUtils.isNotEmpty(link.group(args))) {
                                text += "()";
                            }
                        }
                    }
                }
                if (!"linkplain".equals(tag)) {
                    text = "<code>" + text + "</code>";
                }
            }
            matcher.appendReplacement(decoded, (text != null) ? quoteReplacement(text) : "");
        }
        matcher.appendTail(decoded);

        return decoded.toString();
    }