From f8939bf6a6a212dfd145e54d17b94fea75dc1a64 Mon Sep 17 00:00:00 2001 From: wisberg Date: Thu, 7 Aug 2003 06:59:04 +0000 Subject: - added support for XML/Ant scripts --- .../internal/tools/build/SampleGatherer.java | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'build') diff --git a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java index 299053b8e..6a4017422 100644 --- a/build/src/org/aspectj/internal/tools/build/SampleGatherer.java +++ b/build/src/org/aspectj/internal/tools/build/SampleGatherer.java @@ -38,10 +38,6 @@ public class SampleGatherer { /** EOL String for gathered lines */ public static final String EOL = "\n"; // XXX - /** lowercase source suffixes identify files to gather samples from */ - public static final String[] SOURCE_SUFFIXES = new String[] - { ".java", ".aj", ".sh", ".txt", ".html", ".htm" }; - static final String START = "START-SAMPLE"; static final String END = "END-SAMPLE"; static final String AUTHOR = "@author"; @@ -140,8 +136,9 @@ public class SampleGatherer { return false; } String path = file.getName().toLowerCase(); - for (int i = 0; i < SOURCE_SUFFIXES.length; i++) { - if (path.endsWith(SOURCE_SUFFIXES[i])) { + String[] suffixes = Sample.Kind.SOURCE_SUFFIXES; + for (int i = 0; i < suffixes.length; i++) { + if (path.endsWith(suffixes[i])) { return true; } } @@ -349,6 +346,12 @@ class Sample { } public static class Kind { + + /** lowercase source suffixes identify files to gather samples from */ + public static final String[] SOURCE_SUFFIXES = new String[] + { ".java", ".aj", ".sh", ".ksh", + ".txt", ".text", ".html", ".htm", ".xml" }; + static final Kind XML = new Kind(); static final Kind HTML = new Kind(); static final Kind PROGRAM = new Kind(); static final Kind SCRIPT = new Kind(); @@ -371,6 +374,9 @@ class Sample { if ((name.endsWith(".txt") || name.endsWith(".text"))) { return TEXT; } + if (name.endsWith(".xml")) { + return XML; + } return OTHER; } private Kind() { @@ -551,6 +557,8 @@ class HTMLSamplesRenderer extends SamplesRenderer { renderHeading(sample.anchorName, sample.anchorTitle, sampleSection); if (sample.kind == Sample.Kind.HTML) { renderHTML(sample); + } else if (sample.kind == Sample.Kind.XML) { + renderXML(sample); } else { renderPre(sample); } @@ -565,12 +573,15 @@ class HTMLSamplesRenderer extends SamplesRenderer { // XXX starting same as pre if (doRenderAuthor(sample)) { currentAuthor = sample.author; - sampleSection.append("

author: " + currentAuthor + "

"); + sampleSection.append("

|   " + currentAuthor); sampleSection.append(EOL); } - sampleSection.append("

from: "); + sampleSection.append("  |  "); sampleSection.append(SampleUtil.renderCodePath(sample.sourcePath)); sampleSection.append(":" + sample.startLine); + sampleSection.append("  |"); + sampleSection.append(EOL); + sampleSection.append("

"); sampleSection.append(EOL); if (doFlags) { boolean flagHeaderDone = false; @@ -592,6 +603,16 @@ class HTMLSamplesRenderer extends SamplesRenderer { } } + protected void renderXML(Sample sample) { + renderStandardHeader(sample); + sampleSection.append("

");
+        sampleSection.append(EOL);
+        sampleSection.append(prepareXMLSample(sample.sampleCode));
+        sampleSection.append(EOL);
+        sampleSection.append("    
"); + sampleSection.append(EOL); + } + protected void renderHTML(Sample sample) { renderStandardHeader(sample); sampleSection.append(EOL); @@ -650,6 +671,12 @@ class HTMLSamplesRenderer extends SamplesRenderer { sink.append(EOL); } + protected String prepareXMLSample(String sampleCode) { + String[] from = new String[] {"\t", "<"}; + String[] to = new String[] {" ", "<"}; + return (SampleUtil.replace(sampleCode, from, to)); + } + protected String prepareHTMLSample(String sampleCode) { String[] from = new String[20]; String[] to = new String[20]; -- cgit v1.2.3