#include "dirdef.h"
#include "filename.h"
#include "doxygen.h"
#include "util.h"
#include "outputlist.h"
#include "language.h"
//----------------------------------------------------------------------
// method implementation
static int g_dirCount=0;
DirDef::DirDef(const char *path) : Definition(path,1,path)
{
// get display name (stipping the paths mentioned in STRIP_FROM_PATH)
m_dispName = stripFromPath(path);
// get short name (last part of path)
m_shortName = path;
if (m_shortName.at(m_shortName.length()-1)=='/')
{ // strip trailing /
m_shortName = m_shortName.left(m_shortName.length()-1);
}
int pi=m_shortName.findRev('/');
if (pi!=-1)
{ // remove everything till the last /
m_shortName = m_shortName.mid(pi+1);
}
m_subdirs.setAutoDelete(TRUE);
m_fileList = new FileList;
m_classSDict = new ClassSDict(17);
m_dirCount = g_dirCount++;
}
DirDef::~DirDef()
{
}
void DirDef::addSubDir(DirDef *subdir)
{
m_subdirs.inSort(subdir);
subdir->setOuterScope(this);
}
void DirDef::addFile(FileDef *fd)
{
m_fileList->inSort(fd);
fd->setDirDef(this);
}
QCString DirDef::getOutputFileBase() const
{
//return "dir_"+convertNameToFile(name());
return QCString().sprintf("dir_%06d",m_dirCount);
}
void DirDef::writeDetailedDocumentation(OutputList &ol)
{
if (!briefDescription().isEmpty() || !documentation().isEmpty())
{
ol.writeRuler();
ol.pushGeneratorState();
ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::RTF);
ol.writeAnchor(0,"_details");
ol.popGeneratorState();
ol.startGroupHeader();
ol.parseText(theTranslator->trDetailedDescription());
ol.endGroupHeader();
// repeat brief description
if (!briefDescription().isEmpty() && Config_getBool("REPEAT_BRIEF"))
{
ol.parseDoc(briefFile(),briefLine(),this,0,briefDescription(),FALSE,FALSE);
ol.newParagraph();
}
// write documentation
if (!documentation().isEmpty())
{
ol.parseDoc(docFile(),docLine(),this,0,documentation()+"\n",TRUE,FALSE);
}
}
}
void DirDef::writeDocumentation(OutputList &ol)
{
ol.pushGeneratorState();
QCString shortTitle=theTranslator->trDirReference(m_shortName);
QCString title=theTranslator->trDirReference(m_dispName);
startFile(ol,getOutputFileBase(),name(),title);
// write navigation path
writeNavigationPath(ol);
startTitle(ol,getOutputFileBase());
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
ol.parseText(shortTitle);
ol.enableAll();
ol.disable(OutputGenerator::Html);
ol.parseText(title);
ol.popGeneratorState();
endTitle(ol,getOutputFileBase(),title);
// write brief or details (if DETAILS_AT_TOP)
if (Config_getBool("DETAILS_AT_TOP"))
{
writeDetailedDocumentation(ol);
ol.newParagraph();
}
else if (!briefDescription().isEmpty())
{
ol.parseDoc(briefFile(),briefLine(),this,0,briefDescription(),TRUE,FALSE);
ol.writeString(" \n");
ol.pushGeneratorState();
ol.disable(OutputGenerator::Latex);
ol.disable(OutputGenerator::RTF);
ol.disable(OutputGenerator::Man);
ol.startTextLink(0,"_details");
ol.parseText(theTranslator->trMore());
ol.endTextLink();
ol.enableAll();
ol.disableAllBut(OutputGenerator::Man);
ol.newParagraph();
ol.popGeneratorState();
}
ol.startMemberSections();
// write subdir list
if (m_subdirs.count()>0)
{
ol.startMemberHeader();
ol.parseText(theTranslator->trDir(TRUE,FALSE));
ol.endMemberHeader();
ol.startMemberList();
DirDef *dd=m_subdirs.first();
while (dd)
{
ol.startMemberItem(0);
ol.parseText(theTranslator->trDir(FALSE,TRUE));
ol.insertMemberAlign();
ol.writeObjectLink(dd->getReference(),dd->getOutputFileBase(),0,dd->shortName());
ol.endMemberItem();
if (!dd->briefDescription().isEmpty() && Config_getBool("BRIEF_MEMBER_DESC"))
{
ol.startMemberDescription();
ol.parseDoc(briefFile(),briefLine(),dd,0,dd->briefDescription(),FALSE,FALSE);
ol.endMemberDescription();
ol.newParagraph();
}
dd=m_subdirs.next();
}
ol.endMemberList();
}
// write file list
if (m_fileList->count()>0)
{
ol.startMemberHeader();
ol.parseText(theTranslator->trFile(TRUE,FALSE));
ol.endMemberHeader();
ol.startMemberList();
FileDef *fd=m_fileList->first();
while (fd)
{
ol.startMemberItem(0);
ol.docify("file ");
ol.insertMemberAlign();
ol.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),0,fd->name());
//if (!Config_getString("GENERATE_TAGFILE").isEmpty())
//{
// Doxygen::tagFile << "