Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed the @cdk.githash links

Change-Id: I048118cbd989ba045589aff7fe0be227d8797c7e
  • Loading branch information...
commit dd9cdb8d9f04294cab19583d4dcdbdda96a41379 1 parent 99c2171
Egon Willighagen authored July 29, 2012
22  src/main/net/sf/cdk/tools/doclets/CDKGitTaglet.java
@@ -38,7 +38,8 @@
38 38
 public class CDKGitTaglet implements Taglet {
39 39
     
40 40
     private static final String NAME = "cdk.githash";
41  
-    private final static Pattern pathPattern = Pattern.compile(".*/(src/.*\\.java)");
  41
+    private final static Pattern pathPattern = Pattern.compile("^(src/.*\\.java)");
  42
+    private final String BRANCH = "cdk-1.4.x";
42 43
     
43 44
     public String getName() {
44 45
         return NAME;
@@ -95,20 +96,19 @@ public String toString(Tag[] tags) {
95 96
     }
96 97
 
97 98
     private String expand(Tag tag) {
98  
-    	// Tag only returns the file name, not the path (anymore)
99  
-    	if (true)
100  
-    	    return "<a href=\"https://github.com/cdk/cdk/tree/cdk-1.4.x/src/main/org/openscience/cdk\" target=\"_blank\">cdk-1.4.x</a>";
101  
-
102 99
     	// create the URL
103 100
     	SourcePosition file = tag.position();
104  
-    	String path = correctSlashes(file.file().getAbsolutePath());
105  
-    	Matcher matcher = pathPattern.matcher(path);
  101
+    	String pathAndFile = file.file().toString();
  102
+    	pathAndFile = pathAndFile.substring(pathAndFile.indexOf("src/main"));
  103
+    	pathAndFile = correctSlashes(pathAndFile);
  104
+    	Matcher matcher = pathPattern.matcher(pathAndFile);
106 105
     	if (matcher.matches()) {
107  
-	    String url = "http://cdk.git.sourceforge.net/git/gitweb.cgi?p=cdk;a=blob;f=" + 
108  
-		matcher.group(1) + ";hb=HEAD";
109  
-        	return "<a href=\"" + url + "\" target=\"_blank\">HEAD</a>";
  106
+    		String url = "https://github.com/cdk/cdk/tree/" + BRANCH + "/" + 
  107
+    				matcher.group(1);
  108
+    		System.out.println("URL: " + url);
  109
+        	return "<a href=\"" + url + "\" target=\"_blank\">" + BRANCH + "</a>";
110 110
     	} else {
111  
-    		System.out.println("Could not resolve class name from: " + path);
  111
+    		System.out.println("Could not resolve class name from: " + pathAndFile);
112 112
     	}
113 113
     	return "";
114 114
     }

0 notes on commit dd9cdb8

Please sign in to comment.
Something went wrong with that request. Please try again.