Skip to content

Commit bef3865

Browse files
committed
Enhanced javadoc taglet support so that we can link to the new MongoDB manual at docs.mongogb.org/manual
1 parent 0cac416 commit bef3865

File tree

6 files changed

+145
-74
lines changed

6 files changed

+145
-74
lines changed

build.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ limitations under the License.
210210
access="protected">
211211
<link href="http://download.oracle.com/javase/1.5.0/docs/api/"/>
212212
<classpath refid="classpath"/>
213-
<taglet name="ApiToolsTaglet" path="build/util"/>
213+
<taglet name="DochubTaglet" path="build/util"/>
214+
<taglet name="ManualTaglet" path="build/util"/>
214215
</javadoc>
215216

216217
<javadoc
@@ -225,7 +226,8 @@ limitations under the License.
225226
access="protected">
226227
<link href="http://download.oracle.com/javase/1.5.0/docs/api/"/>
227228
<classpath refid="classpath"/>
228-
<taglet name="ApiToolsTaglet" path="build/util"/>
229+
<taglet name="DochubTaglet" path="build/util"/>
230+
<taglet name="ManualTaglet" path="build/util"/>
229231
</javadoc>
230232

231233
</target>

src/main/com/mongodb/ReadPreference.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222

2323
/**
24-
* an abstract class that represents preferred replica set members to which a query or command can be sent
24+
* An abstract class that represents preferred replica set members to which a query or command can be sent.
25+
*
26+
* @mongodb.driver.manual applications/replication/#replica-set-read-preference Read Preference
2527
*/
2628
public abstract class ReadPreference {
2729

src/util/ApiToolsTaglet.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/util/DocTaglet.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright (c) 2008 - 2012 10gen, Inc. <http://10gen.com>
3+
* <p/>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p/>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p/>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.sun.javadoc.Tag;
18+
import com.sun.tools.doclets.Taglet;
19+
20+
public abstract class DocTaglet implements Taglet {
21+
22+
public boolean inConstructor() { return true; }
23+
public boolean inField() { return true; }
24+
public boolean inMethod() { return true; }
25+
public boolean inOverview() { return true; }
26+
public boolean inPackage() { return true; }
27+
public boolean inType() { return true; }
28+
29+
public boolean isInlineTag() { return false; }
30+
31+
public String toString( Tag[] tags ){
32+
if ( tags.length == 0 )
33+
return null;
34+
35+
StringBuilder buf = new StringBuilder( "\n<br><DT><B>MongoDB Doc Links</B><DD>" );
36+
buf.append( "<ul>" );
37+
for ( Tag t : tags ){
38+
buf.append( "<li>" ).append( genLink( t.text() ) ).append( "</li>" );
39+
}
40+
buf.append( "</ul>" );
41+
buf.append( "</DD>\n" );
42+
return buf.toString();
43+
}
44+
45+
public String toString( Tag tag ){
46+
return toString(new Tag[]{tag});
47+
}
48+
49+
protected String genLink( String text ){
50+
String relativePath = text;
51+
String display = text;
52+
53+
int firstSpace = text.indexOf(' ');
54+
if (firstSpace != -1) {
55+
relativePath = text.substring(0, firstSpace);
56+
display = text.substring(firstSpace, text.length()).trim();
57+
}
58+
59+
return new StringBuilder()
60+
.append( "<a href='" ).append(getBaseDocURI()).append(relativePath).append( "'>" ).append(display).append( "</a>" )
61+
.toString();
62+
}
63+
64+
protected abstract String getBaseDocURI();
65+
}

src/util/DochubTaglet.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (c) 2008 - 2012 10gen, Inc. <http://10gen.com>
3+
* <p/>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p/>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p/>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.sun.tools.doclets.Taglet;
18+
19+
import java.util.Map;
20+
21+
public class DochubTaglet extends DocTaglet {
22+
23+
public static void register( Map<String, Taglet> tagletMap ){
24+
DochubTaglet t = new DochubTaglet();
25+
tagletMap.put( t.getName() , t );
26+
}
27+
28+
public String getName(){
29+
return "dochub";
30+
}
31+
32+
@Override
33+
protected String getBaseDocURI() {
34+
return "http://dochub.mongodb.org/core/";
35+
}
36+
}

src/util/ManualTaglet.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright (c) 2008 - 2012 10gen, Inc. <http://10gen.com>
3+
* <p/>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p/>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p/>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.sun.tools.doclets.Taglet;
18+
19+
import java.util.Map;
20+
21+
public class ManualTaglet extends DocTaglet {
22+
23+
public static void register( Map<String, Taglet> tagletMap ){
24+
ManualTaglet t = new ManualTaglet();
25+
tagletMap.put( t.getName() , t );
26+
}
27+
28+
public String getName(){
29+
return "mongodb.driver.manual";
30+
}
31+
32+
@Override
33+
protected String getBaseDocURI() {
34+
return "http://docs.mongodb.org/manual/";
35+
}
36+
37+
}

0 commit comments

Comments
 (0)