in maven-tagdoc-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/tagdoc/TagdocReport.java [113:290]
private void _generateTagDocs() throws Exception
{
FacesConfigBean facesConfig = getFacesConfig();
if (!facesConfig.hasComponents())
{
getLog().info("Nothing to generate - no components found");
return;
}
// Need to cycle through the components two times, hence need two iterators.
// components Iterator will be used when actually writing out the tag doc
// compIter Iterator will be used when creating the maps of component relationships
Iterator<ComponentBean> components = facesConfig.components();
components = new FilteredIterator<ComponentBean>(components, new SkipFilter());
components = new FilteredIterator<ComponentBean>(components, new ComponentTagFilter());
components = new FilteredIterator<ComponentBean>(components, new ComponentNamespaceFilter());
Iterator<ComponentBean> compIter = facesConfig.components();
compIter = new FilteredIterator<ComponentBean>(compIter, new SkipFilter());
compIter = new FilteredIterator<ComponentBean>(compIter, new ComponentTagFilter());
compIter = new FilteredIterator<ComponentBean>(compIter, new ComponentNamespaceFilter());
// compTypeMap holds a map of compononent types to tag names that implement that component type
// The map is built using getComponentType method on the component bean to determine the
// component type of a given tag name
Map<String, List<QName>> compTypeMap = new HashMap<String, List<QName>> ();
// contractMap holds a map of contract name to tag names that satisify that contract.
// The map is built using the getSatisfiedContracts method API on the component bean to determine
// which contracts are satisfied for a given tagname
Map<String, List<QName>> contractMap = new HashMap<String, List<QName>>();
while (compIter.hasNext())
{
ComponentBean compBean = compIter.next();
List<QName> tagNames;
String compType = compBean.getComponentType();
if (compType != null &&
compTypeMap.containsKey (compType) &&
compBean.getTagName() != null)
{
// the component type map already contains an entry for this component type
tagNames = compTypeMap.get(compType);
}
else
{
// the component type map does not contain an entry for this component type
// so create a new ArrayList that will be used to store the tag names of
// component that have this component type
tagNames = new ArrayList<QName>();
}
tagNames.add(compBean.getTagName());
compTypeMap.put (compType, tagNames);
if (compBean.hasSatisfiedContracts())
{
Iterator<String> satContractsIter = compBean.satisfiedContracts();
while (satContractsIter.hasNext())
{
String satContract = satContractsIter.next();
if (contractMap.containsKey (satContract))
{
// the contract map already contains an entry for this contract
tagNames = contractMap.get(satContract);
}
else
{
// the contract map does not contain an entry for this contract, so
// create a new ArrayList which will be used to store the tag names of
// components that satisfy this contract
tagNames = new ArrayList<QName>();
}
tagNames.add(compBean.getTagName());
contractMap.put (satContract, tagNames);
}
}
}
Iterator<ValidatorBean> validators = facesConfig.validators();
validators = new FilteredIterator<ValidatorBean>(validators, new ValidatorTagFilter());
validators = new FilteredIterator<ValidatorBean>(validators, new ValidatorNamespaceFilter());
Iterator<ConverterBean> converters = facesConfig.converters();
converters = new FilteredIterator<ConverterBean>(converters, new ConverterTagFilter());
converters = new FilteredIterator<ConverterBean>(converters, new ConverterNamespaceFilter());
// =-=AEW Note that only updating out-of-date components, etc. is
// permanently tricky, even if we had proper detection in place,
// because the index always has to have all docs
/*
if (!components.hasNext() && !converters.hasNext() && !validators.hasNext())
{
getLog().info("Nothing to generate - all docs are up to date");
return;
}
*/
Set<String> componentPages = new TreeSet<String>();
Set<String> converterPages = new TreeSet<String>();
Set<String> validatorPages = new TreeSet<String>();
int count = 0;
while (components.hasNext())
{
String pageName = _generateComponentDoc(components.next(), compTypeMap, contractMap);
if (pageName != null)
{
componentPages.add(pageName);
count++;
}
}
while (converters.hasNext())
{
String pageName = _generateConverterDoc(converters.next());
if (pageName != null)
{
converterPages.add(pageName);
count++;
}
}
while (validators.hasNext())
{
String pageName = _generateValidatorDoc(validators.next());
if (pageName != null)
{
validatorPages.add(pageName);
count++;
}
}
Set<String> otherPages = _gatherOtherTags();
getLog().info("Generated " + count + " page(s)");
Sink sink = getSink();
sink.head();
sink.title();
sink.text("Tag library documentation");
sink.title_();
sink.head_();
sink.body();
sink.sectionTitle1();
sink.text("Tag library information");
sink.sectionTitle1_();
sink.section1();
for (Iterator<Map.Entry<String, String>> i = taglibs.entrySet().iterator(); i.hasNext(); )
{
Map.Entry<String, String> entry = i.next();
sink.paragraph();
sink.bold();
sink.text("Short name:");
sink.bold_();
sink.nonBreakingSpace();
sink.text(entry.getKey());
sink.lineBreak();
sink.bold();
sink.text("Namespace:");
sink.bold_();
sink.nonBreakingSpace();
sink.text(entry.getValue());
sink.lineBreak();
sink.paragraph_();
}
sink.section1_();
_writeIndexSection(sink, componentPages, "Components");
_writeIndexSection(sink, converterPages, "Converters");
_writeIndexSection(sink, validatorPages, "Validators");
_writeIndexSection(sink, otherPages, "Miscellaneous");
sink.body_();
}