* Make helmadoc work with multiple application repositories.
This commit is contained in:
parent
3a55bd1b5e
commit
05bce5953e
2 changed files with 46 additions and 39 deletions
|
@ -17,8 +17,8 @@
|
||||||
package helma.doc;
|
package helma.doc;
|
||||||
|
|
||||||
import helma.framework.IPathElement;
|
import helma.framework.IPathElement;
|
||||||
import helma.framework.repository.FileResource;
|
import helma.framework.core.Application;
|
||||||
import helma.framework.repository.FileResource;
|
import helma.framework.repository.FileRepository;
|
||||||
import helma.main.Server;
|
import helma.main.Server;
|
||||||
import helma.util.ResourceProperties;
|
import helma.util.ResourceProperties;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -27,19 +27,21 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DocApplication extends DocDirElement {
|
public class DocApplication extends DocElement {
|
||||||
|
|
||||||
|
Application app;
|
||||||
HashSet excluded;
|
HashSet excluded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new DocApplication object.
|
* Creates a new DocApplication object.
|
||||||
*
|
*
|
||||||
* @param name ...
|
* @param app
|
||||||
* @param location ...
|
|
||||||
*
|
*
|
||||||
* @throws DocException ...
|
* @throws DocException ...
|
||||||
*/
|
*/
|
||||||
public DocApplication(String name, File location) throws DocException {
|
public DocApplication(Application app) throws DocException {
|
||||||
super(name, location, APPLICATION);
|
super(app.getName(), app.getAppDir(), APPLICATION);
|
||||||
|
this.app = app;
|
||||||
readProps();
|
readProps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ public class DocApplication extends DocDirElement {
|
||||||
*
|
*
|
||||||
* @param args ...
|
* @param args ...
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
/* public static void main(String[] args) {
|
||||||
System.out.println("this is helma.doc");
|
System.out.println("this is helma.doc");
|
||||||
DocApplication app;
|
DocApplication app;
|
||||||
app = new DocApplication (args[0], args[1]);
|
app = new DocApplication (args[0], args[1]);
|
||||||
|
@ -90,20 +92,13 @@ public class DocApplication extends DocDirElement {
|
||||||
|
|
||||||
// System.out.println (func.getContent ());
|
// System.out.println (func.getContent ());
|
||||||
// System.out.println ("\n\n\ncomment = " + func.getComment ());
|
// System.out.println ("\n\n\ncomment = " + func.getComment ());
|
||||||
}
|
} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reads the app.properties file and parses for helma.excludeDocs
|
* reads the app.properties file and parses for helma.excludeDocs
|
||||||
*/
|
*/
|
||||||
private void readProps() {
|
private void readProps() {
|
||||||
File propsFile = new File(location, "app.properties");
|
ResourceProperties appProps = app.getProperties();
|
||||||
ResourceProperties serverProps = null;
|
|
||||||
if (Server.getServer()!=null) {
|
|
||||||
serverProps = Server.getServer().getProperties();
|
|
||||||
}
|
|
||||||
ResourceProperties appProps = new ResourceProperties();
|
|
||||||
appProps.setDefaultProperties(serverProps);
|
|
||||||
appProps.addResource(new FileResource(propsFile));
|
|
||||||
|
|
||||||
excluded = new HashSet();
|
excluded = new HashSet();
|
||||||
addExclude("cvs");
|
addExclude("cvs");
|
||||||
|
@ -147,36 +142,48 @@ public class DocApplication extends DocDirElement {
|
||||||
*/
|
*/
|
||||||
public void readApplication() {
|
public void readApplication() {
|
||||||
readProps();
|
readProps();
|
||||||
|
|
||||||
String[] arr = location.list();
|
|
||||||
|
|
||||||
children.clear();
|
children.clear();
|
||||||
|
|
||||||
for (int i = 0; i < arr.length; i++) {
|
Iterator it = app.getRepositories().iterator();
|
||||||
if (isExcluded(arr[i])) {
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Object next = it.next();
|
||||||
|
|
||||||
|
if (!(next instanceof FileRepository)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
File f = new File(location.getAbsolutePath(), arr[i]);
|
File dir = ((FileRepository) next).getDirectory();
|
||||||
|
|
||||||
if (!f.isDirectory()) {
|
String[] arr = dir.list();
|
||||||
continue;
|
|
||||||
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
if (isExcluded(arr[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File f = new File(dir.getAbsolutePath(), arr[i]);
|
||||||
|
|
||||||
|
if (!f.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
System.err.println("*** NEW PROTOTYPE DOC: " + f);
|
||||||
|
DocPrototype pt = DocPrototype.newInstance(f, this);
|
||||||
|
|
||||||
|
addChild(pt);
|
||||||
|
pt.readFiles();
|
||||||
|
} catch (DocException e) {
|
||||||
|
debug("Couldn't read prototype " + arr[i] + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
for (Iterator i = children.values().iterator(); i.hasNext();) {
|
||||||
DocPrototype pt = DocPrototype.newInstance(f, this);
|
((DocPrototype) i.next()).checkInheritance();
|
||||||
|
|
||||||
addChild(pt);
|
|
||||||
pt.readFiles();
|
|
||||||
} catch (DocException e) {
|
|
||||||
debug("Couldn't read prototype " + arr[i] + ": " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Iterator i = children.values().iterator(); i.hasNext();) {
|
|
||||||
((DocPrototype) i.next()).checkInheritance();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,7 @@ public class RhinoEngine implements ScriptingEngine {
|
||||||
*/
|
*/
|
||||||
public IPathElement getIntrospector() {
|
public IPathElement getIntrospector() {
|
||||||
if (doc == null) {
|
if (doc == null) {
|
||||||
doc = new DocApplication(app.getName(), new File(Server.getServer().getAppsHome(), app.getName()));
|
doc = new DocApplication(app);
|
||||||
doc.readApplication();
|
doc.readApplication();
|
||||||
}
|
}
|
||||||
return doc;
|
return doc;
|
||||||
|
|
Loading…
Add table
Reference in a new issue