001package ball.tools.javadoc; 002/*- 003 * ########################################################################## 004 * Utilities 005 * $Id: LinkManTaglet.html 5431 2020-02-12 19:03:17Z ball $ 006 * $HeadURL: svn+ssh://svn.hcf.dev/var/spool/scm/repository.svn/hcf-dev/blog/2019-03-30-java-interface-facades/src/main/resources/javadoc/src-html/ball/tools/javadoc/LinkManTaglet.html $ 007 * %% 008 * Copyright (C) 2008 - 2020 Allen D. Ball 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * ########################################################################## 022 */ 023import ball.annotation.MatcherGroup; 024import ball.annotation.PatternRegex; 025import ball.annotation.ServiceProviderFor; 026import ball.util.PatternMatcherBean; 027import ball.xml.FluentNode; 028import com.sun.javadoc.Tag; 029import com.sun.tools.doclets.Taglet; 030import java.io.File; 031import java.util.Map; 032import lombok.NoArgsConstructor; 033import lombok.ToString; 034 035/** 036 * Inline {@link Taglet} providing links to {@link.man man(1)} pages. 037 * 038 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball} 039 * @version $Revision: 5431 $ 040 */ 041@ServiceProviderFor({ Taglet.class }) 042@TagletName("link.man") 043@NoArgsConstructor @ToString 044@PatternRegex("(?is)(.+)[(]([\\p{Alnum}])[)]") 045public class LinkManTaglet extends AbstractInlineTaglet 046 implements SunToolsInternalToolkitTaglet, 047 PatternMatcherBean { 048 private static final LinkManTaglet INSTANCE = new LinkManTaglet(); 049 050 public static void register(Map<Object,Object> map) { 051 register(map, INSTANCE); 052 } 053 054 private String name = null; 055 private String section = null; 056 057 @MatcherGroup(1) 058 protected void setName(String string) { name = string; } 059 060 @MatcherGroup(2) 061 protected void setSection(String string) { section = string; } 062 063 @Override 064 public FluentNode toNode(Tag tag) throws Throwable { 065 PatternMatcherBean.super.initialize(tag.text().trim()); 066 067 File path = new File(File.separator); 068 069 path = new File(path, "usr"); 070 path = new File(path, "share"); 071 path = new File(path, "man"); 072 path = new File(path, "htmlman" + section); 073 path = new File(path, name + "." + section + ".html"); 074 075 return a(path.toURI(), code(name + "(" + section + ")")); 076 } 077}