Package Torello.HTML.Tools.JavaDoc
Class CleanPackageSummaries
- java.lang.Object
-
- Torello.HTML.Tools.JavaDoc.CleanPackageSummaries
-
public class CleanPackageSummaries extends java.lang.Object
CleanPackageSummaries - Documentation.
Each completeJava Package
has a 'Summary Page' created for it, using an'.html'
file simply named'package-summary.html'
. The general structure of the page is great. The user is encouraged to write a'package-info.java'
file, and include it in the package's source-code directory. The issue is that an'AI'
, of sorts, adds in the list ofclasses, interfaces, enums, exceptions
anderrors
that comprise the package along with a brief-description explaining what thatclass, interface
etc... does.
The problem is that if there is any complexity to the code-comments for any of thoseclasses, interfaces
etc. - the summary itself will looked horribly skewed. This class attempt to 'clean up' the'package-summary.html'
pages by simply removing the extraneous HTML inserted into the page. TheUpgrader Tool
provides a means to insert your own'Summary Cleaner'
- although the default cleaner works very well. To register aPackage Summary Cleaner
with theUpgrader
before it runs, invoke the methodUpgrade.setPackageSummaryCleaner(Consumer)
This type of Lambda is actually very easy to write, if you are capable at using the HTML manipulation and modification methods in theHTML Package
. Review the code in the default cleaner to see how it simply strip away everything after the first sentence in a package summary page.
Hi-Lited Source-Code:
- View Here: Torello/HTML/Tools/JavaDoc/CleanPackageSummaries.java
- Open New Browser-Tab: Torello/HTML/Tools/JavaDoc/CleanPackageSummaries.java
Stateless Class:
This class neither contains any program-state, nor can it be instantiated.
The
The
@StaticFunctional
Annotation may also be called 'The Spaghetti Report'- 1 Constructor(s), 1 declared private, zero-argument constructor
- 2 Method(s), 2 declared static
- 2 Field(s), 2 declared static, 1 declared final
- Fields excused from final modifier (with explanation):
Field 'sw' is not final. Reason: LOGGING
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method static void
defaultCleaner(Vector<HTMLNode> cietSummary)
static void
run(Vector<HTMLNode> jdPage, Consumer<Vector<HTMLNode>> summaryCleaner, StorageWriter sw)
-
-
-
Method Detail
-
defaultCleaner
public static final void defaultCleaner (java.util.Vector<HTMLNode> cietSummary)
Implents a cleaner. This will remove extraneous notes that are inserted by Java Doc into theClass, Interface, Enum, Exception
andError
lists at the top of a'package-summary.html'
page.- Parameters:
cietSummary
- The actual HTML that has been extracted from aClass Summary
- Code:
- Exact Method Body:
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
// System.out.println("INSIDE MY LAMBDA:\n" + Util.pageToString(cietSummary)); int i=0, nodePos=-1; if (sw != null) sw.println("cietSummary: " + C.BGREEN + Util.pageToString(cietSummary) + C.RESET); while ((nodePos == -1) && (i < searches.length)) nodePos = TextNodeFind.first(cietSummary, TextComparitor.CN_CI, searches[i++]); if (nodePos == -1) { sw.println("No String Markers Found! Exiting..."); return; } String s = cietSummary.elementAt(nodePos).str; int pos = StrIndexOf.first_CI(s, searches[--i]); if (sw != null) sw.println("s: " + s); s = s.substring(0, pos); if (sw != null) sw.println("s.substring: " + s); if (s.length() != 0) cietSummary.setElementAt(new TextNode(s), nodePos++); if (nodePos < cietSummary.size()) Util.removeRange(cietSummary, nodePos, cietSummary.size()); Util.removeAllTagNodes(cietSummary); if (sw != null) sw.println( C.BCYAN + Util.pageToString(cietSummary) + C.RESET + "\n************************************************************\n" );
-
run
public static void run (java.util.Vector<HTMLNode> jdPage, java.util.function.Consumer<java.util.Vector<HTMLNode>> summaryCleaner, StorageWriter sw)
This method will clean any potentially skewed or damaged package summary pages. It simply iterates through eachclass, interface, enum, exception
anderror
found on the summary page, and then invokes the cleaner on the HTML that is present in that summary. The default cleaner simply removes everything after the first sentence in the page.- Parameters:
jdPage
- A vectorized Java-Doc Generated HTML Package-Summary Web-Page.summaryCleaner
- This is theConsumer
that should clean the summary.sw
- The log output writer.- Code:
- Exact Method Body:
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
if (sw != null) sw.println("CleanPackageSummaries.run(...):"); CleanPackageSummaries.sw = sw; int count = 0; HNLIInclusive iter = InnerTagInclusiveIterator.get (jdPage, "tr", "class", TextComparitor.C, "altColor", "rowColor"); while (iter.hasNext()) { DotPair dp = iter.nextDotPair(); DotPair cLast = InnerTagFindInclusive.first (jdPage, dp.start, dp.end, "td", "class", TextComparitor.C, "colLast"); if (cLast == null) continue; DotPair div = InnerTagFindInclusive.first (jdPage, cLast.start, cLast.end, "div", "class", TextComparitor.C, "block"); if (div == null) continue; if (div.size() < 3) continue; DotPair divContentsDP = new DotPair(div.start+1, div.end-1); Vector<HTMLNode> divContents = Util.cloneRange(jdPage, divContentsDP); summaryCleaner.accept(divContents); iter.replaceRange(divContentsDP, divContents); count++; } if (sw != null) sw.println( "\tCleaned " + C.BBLUE + StringParse.zeroPad(count) + C.RESET + " '" + C.BCYAN + "package-summary.html" + C.RESET + "' CIETEE-Summary Dividers." );
-
-