Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 3191b3e

Browse files
committed
Merge commit 'c7700bf'
2 parents 89f0479 + c7700bf commit 3191b3e

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

AndroidDocScraper.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,33 @@ public Java7DocScraper (File dir) throws IOException {
6060
}
6161
}
6262

63+
class Java8DocScraper extends AndroidDocScraper {
64+
static final String pattern_head_javadoc = "<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href=\"[./]*"; // I'm not sure how path could be specified... (./ , ../ , or even /)
65+
static final String reset_pattern_head_javadoc = "<td><code>";
66+
static final String parameter_pair_splitter_javadoc = "&nbsp;";
67+
68+
public Java8DocScraper (File dir) throws IOException {
69+
super (dir, pattern_head_javadoc, reset_pattern_head_javadoc, parameter_pair_splitter_javadoc, true, "-", "-", "-");
70+
}
71+
}
72+
6373
public abstract class AndroidDocScraper implements IDocScraper {
6474

6575
final String pattern_head;
6676
final String reset_pattern_head;
6777
final String parameter_pair_splitter;
78+
final String open_method;
79+
final String param_sep;
80+
final String close_method;
6881
final boolean continuous_param_lines;
6982

7083
File root;
7184

7285
protected AndroidDocScraper (File dir, String patternHead, String resetPatternHead, String parameterPairSplitter, boolean continuousParamLines) throws IOException {
86+
this (dir, patternHead, resetPatternHead, parameterPairSplitter, continuousParamLines, "\\(\\Q", ", ", "\\E\\)");
87+
}
88+
89+
protected AndroidDocScraper (File dir, String patternHead, String resetPatternHead, String parameterPairSplitter, boolean continuousParamLines, String openMethod, String paramSep, String closeMethod) throws IOException {
7390

7491
if (dir == null)
7592
throw new IllegalArgumentException ();
@@ -78,6 +95,9 @@ protected AndroidDocScraper (File dir, String patternHead, String resetPatternHe
7895
reset_pattern_head = resetPatternHead;
7996
parameter_pair_splitter = parameterPairSplitter != null ? parameterPairSplitter : "\\s+";
8097
continuous_param_lines = continuousParamLines;
98+
open_method = openMethod;
99+
param_sep = paramSep;
100+
close_method = closeMethod;
81101

82102
if (!dir.exists())
83103
throw new FileNotFoundException (dir.getAbsolutePath());
@@ -106,10 +126,10 @@ public String[] getParameterNames (ClassNode asm, String name, Type[] ptypes, bo
106126
buffer.append (path);
107127
buffer.append ("#");
108128
buffer.append (name);
109-
buffer.append ("\\(\\Q");
129+
buffer.append (open_method);
110130
for (int i = 0; i < ptypes.length; i++) {
111131
if (i != 0)
112-
buffer.append (", ");
132+
buffer.append (param_sep);
113133
String type = JavaClass.getGenericTypeName (ptypes[i]);
114134
if (isVarArgs && i == ptypes.length - 1)
115135
type = type.replace ("[]", "...");
@@ -120,7 +140,8 @@ public String[] getParameterNames (ClassNode asm, String name, Type[] ptypes, bo
120140
// type = type.substring (0, type.indexOf ('<'));
121141
buffer.append (type);
122142
}
123-
buffer.append("\\E\\)\".*\\((.*)\\)");
143+
buffer.append(close_method);
144+
buffer.append("\".*\\((.*)\\)");
124145
Pattern pattern = Pattern.compile (buffer.toString());
125146

126147
try {
@@ -147,7 +168,7 @@ public String[] getParameterNames (ClassNode asm, String name, Type[] ptypes, bo
147168
}
148169
stream.close();
149170
return result;
150-
}
171+
} else System.err.println ("NOT MATCHING '" + buffer.toString() + "', INPUT: " + text);
151172
// sometimes we get incomplete tag, so cache it until it gets complete or matched.
152173
// I *know* this is a hack.
153174
if (reset_pattern_head == null || text.endsWith (">") || !continuous_param_lines && !text.startsWith (reset_pattern_head))

Start.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ public static void main (String[] args)
4848
String droiddocs = null;
4949
String javadocs = null;
5050
String java7docs = null;
51+
String java8docs = null;
5152
String annots = null;
5253
List<String> jar_paths = new ArrayList<String> ();
5354
String out_path = null;
5455
List<String> additional_jar_paths = new ArrayList<String> ();
55-
String usage = "Usage: jar2xml --jar=<jarfile> [--ref=<jarfile>] --out=<file> [--javadocpath=<javadoc>] [--java7docpath=<java7doc>] [--droiddocpath=<droiddoc>] [--annotations=<xmlfile>]";
56+
String usage = "Usage: jar2xml --jar=<jarfile> [--ref=<jarfile>] --out=<file> [--javadocpath=<javadoc>] [--java7docpath=<java7doc>] [--java8docpath=<java8doc>] [--droiddocpath=<droiddoc>] [--annotations=<xmlfile>]";
5657

5758
for (String arg : args) {
5859
if (arg.startsWith ("--javadocpath=")) {
@@ -63,6 +64,10 @@ public static void main (String[] args)
6364
java7docs = arg.substring (15);
6465
if (!java7docs.endsWith ("/"))
6566
java7docs += "/";
67+
} else if (arg.startsWith ("--java8docpath=")) {
68+
java8docs = arg.substring (15);
69+
if (!java8docs.endsWith ("/"))
70+
java8docs += "/";
6671
} else if (arg.startsWith ("--droiddocpath=")) {
6772
droiddocs = arg.substring (15);
6873
if (!droiddocs.endsWith ("/"))
@@ -106,6 +111,8 @@ public static void main (String[] args)
106111
JavaClass.addDocScraper (new JavaDocScraper (new File (javadocs)));
107112
if (java7docs != null)
108113
JavaClass.addDocScraper (new Java7DocScraper (new File (java7docs)));
114+
if (java8docs != null)
115+
JavaClass.addDocScraper (new Java8DocScraper (new File (java8docs)));
109116
} catch (Exception e) {
110117
e.printStackTrace ();
111118
System.err.println ("warning J2X8001: Couldn't access javadocs at specified docpath. Continuing without it...");

0 commit comments

Comments
 (0)