-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathLibraryWriter.java
More file actions
79 lines (62 loc) · 1.71 KB
/
LibraryWriter.java
File metadata and controls
79 lines (62 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package writers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.PackageDoc;
public class LibraryWriter extends BaseWriter {
PackageDoc doc;
String pkg;
LibraryIndexWriter indexWriter;
String dir;
static TemplateWriter templateWriter;
static ArrayList<String> writtenLibraries;
public LibraryWriter(){
if(templateWriter == null ){
templateWriter = new TemplateWriter();
}
if(writtenLibraries == null){
writtenLibraries = new ArrayList<String>();
}
}
public void write(PackageDoc doc)
{
// check for xml files that haven't been read
if(writtenLibraries.contains(doc.name())){
return;
}
writtenLibraries.add(doc.name());
String[] parts = doc.name().split("\\.");
String pkg = parts[parts.length-1] + "/";
dir = "libraries/"+pkg;
Shared.i().createOutputDirectory(dir);
indexWriter = new LibraryIndexWriter(doc, dir);
//grab all relevant information for the doc
for( ClassDoc classDoc : doc.allClasses() ){
// document the class if it has a @webref tag
try
{
new ClassWriter().write(classDoc);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String path = Shared.i().getXMLDirectory() + "LIB_" + pkg;
writeRemainingXml( path);
}
private void writeRemainingXml( String xmlDir )
{
File directory = new File( xmlDir );
File[] files = directory.listFiles();
for( File f : files )
{
if( f.getAbsolutePath().endsWith("xml") )
{
// try writing everything (will not overwrite any existing docs)
XMLReferenceWriter.parseFile( f.getAbsoluteFile(), dir, indexWriter );
}
}
}
}