Skip to content

Commit 13a6be9

Browse files
committed
Merge pull request #30 from jonpryor/jonp-update-bytecode-from-monodroid/a438c473
[Xamarin.Android.Tools.bytecode] Add JavaDoc importing
2 parents d547120 + 5693c60 commit 13a6be9

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

src/Xamarin.Android.Tools.Bytecode/ClassPath.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,21 @@
1111

1212
namespace Xamarin.Android.Tools.Bytecode {
1313

14+
public enum JavaDocletType {
15+
DroidDoc,
16+
Java6,
17+
Java7,
18+
Java8,
19+
}
20+
1421
public class ClassPath {
1522

1623
IList<ClassFile> classFiles = new List<ClassFile> ();
1724

1825
public string ApiSource { get; set; }
1926

27+
public JavaDocletType DocletType { get; set; }
28+
2029
public IEnumerable<string> DocumentationPaths { get; set; }
2130

2231
public bool AutoRename { get; set; }
@@ -213,9 +222,19 @@ void FixupParametersFromDocs (XElement api)
213222
}
214223
}
215224

225+
AndroidDocScraper CreateDocScraper (string dir)
226+
{
227+
switch (DocletType) {
228+
default: return new DroidDocScraper (dir);
229+
case JavaDocletType.Java6: return new JavaDocScraper (dir);
230+
case JavaDocletType.Java7: return new Java7DocScraper (dir);
231+
case JavaDocletType.Java8: return new Java8DocScraper (dir);
232+
}
233+
}
234+
216235
void FixupParametersFromDocs (XElement api, string path)
217236
{
218-
var jdoc = new DroidDocScraper (path);
237+
var jdoc = CreateDocScraper (path);
219238
var elements = api.XPathSelectElements ("./package/class[@visibility = 'public' or @visibility = 'protected']").ToList ();
220239
elements.AddRange (api.XPathSelectElements ("./package/interface[@visibility = 'public' or @visibility = 'protected']"));
221240
foreach (var elem in elements) {

tools/class-parse/Program.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ class App {
1515

1616
public static void Main (string[] args)
1717
{
18+
JavaDocletType docsType = 0;
19+
1820
bool dump = false;
1921
bool help = false;
2022
int verbosity = 0;
2123
bool autorename = false;
2224
var outputFile = (string) null;
23-
var docsPath = (string) null;
25+
var docsPaths = new List<string> ();
2426
var p = new OptionSet () {
2527
"usage: class-dump [-dump] FILES",
2628
"",
@@ -34,8 +36,12 @@ public static void Main (string[] args)
3436
"Write output to {PATH}.",
3537
v => outputFile = v },
3638
{ "docspath=",
37-
"Android documentation path for parameter fixup",
38-
doc => docsPath = doc},
39+
"Documentation {PATH} for parameter fixup",
40+
doc => docsPaths.Add (doc) },
41+
{ "docstype=",
42+
"{TYPE} of the docs within --docspath. Values:\n " +
43+
string.Join ("\n ", JavaDocletTypeMapping.Keys.OrderBy (s => s)),
44+
t => docsType = GetJavaDocletType (t) },
3945
{ "v|verbose:",
4046
"See stack traces on error.",
4147
(int? v) => verbosity = v.HasValue ? v.Value : verbosity + 1 },
@@ -59,7 +65,8 @@ public static void Main (string[] args)
5965
};
6066
var classPath = new ClassPath () {
6167
ApiSource = "class-parse",
62-
DocumentationPaths = !string.IsNullOrEmpty (docsPath) ? new string[] { docsPath } : null,
68+
DocumentationPaths = docsPaths.Count == 0 ? null : docsPaths,
69+
DocletType = docsType,
6370
AutoRename = autorename
6471
};
6572
foreach (var file in files) {
@@ -81,6 +88,21 @@ public static void Main (string[] args)
8188
output.Close ();
8289
}
8390

91+
static Dictionary<string, JavaDocletType> JavaDocletTypeMapping = new Dictionary<string, JavaDocletType> {
92+
{ "droiddoc", JavaDocletType.DroidDoc },
93+
{ "java6", JavaDocletType.Java6 },
94+
{ "java7", JavaDocletType.Java7 },
95+
{ "java8", JavaDocletType.Java8 },
96+
};
97+
98+
static JavaDocletType GetJavaDocletType (string value)
99+
{
100+
JavaDocletType type;
101+
if (value != null && JavaDocletTypeMapping.TryGetValue (value.ToLowerInvariant (), out type))
102+
return type;
103+
return JavaDocletType.DroidDoc;
104+
}
105+
84106
static void DumpFileToXml (ClassPath jar, string file)
85107
{
86108
using (var s = File.OpenRead (file)) {

0 commit comments

Comments
 (0)