⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doc2tex.ll

📁 Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具
💻 LL
📖 第 1 页 / 共 3 页
字号:
{    int i;    ClassGraph *cls;    ClassGraph cg(entry, 0);    cg.addBases();    cg.addDirectChilds();    fprintf(out, "\\begin{cxxInheritance}\n");    fprintf(out, "\\paragraph{Inheritance}\\strut\\smallskip\\strut\\\\\n");    for(cls = cg.firstLine; cls != &cg; cls = cls->nextLine)	dumpInheritanceEntry(cls);    fprintf(out, "\\cxxInheritanceEntry[x]{");    for(i = 0; i < cls->indent; ++i)	fprintf(out, "\\cxxNone");    fprintf(out, "}{");    if(cls->entry)	if(!cls->entry->fromUnknownPackage && !onlyClassGraph)	    cls->entry->dumpNumber(out);    fprintf(out, "}{");    if(cls->entry)	printCode(cls->entry, getEntryName(cls->entry));    else	printCode(0, cls->name.c_str());        fprintf(out, "}{");    fprintf(out, "}\n");    for(cls = cls->nextLine; cls; cls = cls->nextLine)	dumpInheritanceEntry(cls);    fprintf(out, "\\end{cxxInheritance}\n");}static char *checkStr(const char *str){    char *new_str = (char *)malloc(strlen(str) + 1);    char *return_str = new_str;    bool sep_flag = false;    strcpy(new_str, str);    while(*new_str != '\0')	if(*new_str == '\n')	    strcpy(new_str, new_str + 1);	else	    {	    if(*new_str == ' ')		sep_flag = true;	    new_str++;	    }    new_str = return_str;    if(!sep_flag)	{	return_str = (char *)malloc(strlen(new_str) + 2);	strcpy(return_str, new_str);	strcat(return_str, " ");	strcpy(new_str, return_str);	}    return_str = (char *)malloc(strlen(new_str) + 2);    strcpy(return_str, new_str);    strcat(return_str, "\n");    return return_str;}static void dumpTeXList(Entry *entry, int *fields, McDArray<McString *> list,			char *description){    int i;    if(list.size() > 0)	{	fprintf(out, "\\cxx%s{\n", description);	fprintf(out, "\\begin{tabular}[t]{lp{0.5\\textwidth}}\n");	for(i = 0; i < list.size(); ++i)	    {	    if(i)		fprintf(out, "\\\\\n");	    fprintf(out, "{\\tt\\strut ");	    inPos = 0;	    inStr = checkStr(list[i]->c_str());	    current = entry;	    doc2texYYrestart(0);	    BEGIN(HTMLsyntax ? HTMLlist : TeXlist);	    doc2texYYlex();	    }	fprintf(out, "\\end{tabular}}\n");	(*fields)++;	}}static void dumpTeXField(Entry *entry, int *fields, McString text, char *description){    if(text.length() > 0)	{	fprintf(out, "\\cxx%s{\n", description);	inPos = 0;	inStr = text.c_str();	current = entry;	doc2texYYrestart(0);	BEGIN(HTMLsyntax ? HTML : 0);	doc2texYYlex();	fprintf(out, "\\strut}\n");	(*fields)++;	}}static int dumpFields(Entry *entry){    int	i, fields = 0;    dumpTeXList(entry, &fields, entry->invariant, "Invariants");    dumpTeXList(entry, &fields, entry->exception, "Exceptions");    dumpTeXList(entry, &fields, entry->param, "Parameter");    dumpTeXList(entry, &fields, entry->retrn, "Return");    dumpTeXList(entry, &fields, entry->precondition, "Preconditions");    dumpTeXList(entry, &fields, entry->postcondition, "Postconditions");    dumpTeXField(entry, &fields, entry->author, "Author");    dumpTeXField(entry, &fields, entry->version, "Version");    dumpTeXField(entry, &fields, entry->deprecated, "Deprecated");    dumpTeXField(entry, &fields, entry->since, "Since");    if(entry->see.size())	{	fprintf(out, "\\cxxSee{");	for(i = 0; i < entry->see.size(); ++i)	    {	    if(i)		fprintf(out, "\\\\\n");	    if(HTMLsyntax)		fprintf(out, "{\\tt\\strut ");	    inPos = 0;	    inStr = entry->see[i]->c_str();	    current = entry;	    doc2texYYrestart(0);	    BEGIN(HTMLsyntax ? HTMLlist : Code);	    doc2texYYlex();	    Entry *ref = getRefEntry(*entry->see[i], current);	    if(ref)		{		fprintf(out, " ($\\rightarrow$");		if(MAKE_DOC(ref))		    {		    ref->dumpNumber(out);		    fprintf(out, ",");		    }		fprintf(out, " {\\em page \\pageref{cxx.");		ref->dumpNumber(out);		fprintf(out, "}})");		}	    }	fprintf(out, "\\strut}\n");	fields++;	}    return fields;}static void strlatex(char *s1, const char *s2){    for(;; ++s2)	{	if((*s2) == '\0')	    {	    *s1 = *s2;	    break;	    }	if((*s2) == '_')	    {	    *s1 = '\\';	    ++s1;	    }	*s1 = *s2;++s1;	}}void dumpEntry(Entry *entry){    Entry *tmp;    Entry *stack[20];    int	fields;    int	stack_cnt = 0;    char *sectionType = 0;    if(entry->fromUnknownPackage)	return;    if(generateIndex)	{ 	fprintf(out, "\\index{");     	tmp = entry;     	while(tmp->parent)	    { 	    stack[stack_cnt++] = tmp; 	    tmp = tmp->parent;     	    }     	while(stack_cnt)     	    {    	    tmp = stack[--stack_cnt]; 	    printYYDOC(tmp, tmp->name, 0); 	    if(stack_cnt) 		fprintf(out, "!");     	    }     	fprintf(out, "}\n");     	switch(entry->section)	    {     	    case VARIABLE_SEC: 		sectionType = "Variables/Constants"; 		break;     	    case FUNCTION_SEC: 		sectionType = "Functions/Methods"; 		break;    	    case MACRO_SEC: 		sectionType = "Macros"; 		break;    	    case CLASS_SEC: 		sectionType = "Classes"; 		break;     	    case INTERFACE_SEC: 		sectionType = "Interfaces"; 		break;     	    case UNION_SEC: 		sectionType = "Unions"; 		break;     	    case NAMESPACE_SEC: 		sectionType = "Namespaces"; 		break;     	    default: 		sectionType = (char *)0; 	    } 	if(sectionType) 	    {	    if(!(entry->section & CLASS_SEC) &&		!(entry->section & INTERFACE_SEC) &&		(entry->section != NAMESPACE_SEC))		{ 	    	fprintf(out, "\\index{{\\bf %s}!", sectionType);		printYYDOC(entry->parent, entry->parent->name, 0);		fprintf(out, "!"); 	    	printYYDOC(entry, entry->name, 0); 	    	fprintf(out, "}\n");		}	    else		{ 	    	fprintf(out, "\\index{{\\bf %s}!", sectionType); 	    	printYYDOC(entry, entry->name, 0); 	    	fprintf(out, "}\n");		} 	    }	}    switch(entry->section)	{	case VARIABLE_SEC:	    fprintf(out, "\\begin{cxxvariable}\n");	    break;	case FUNCTION_SEC:	    fprintf(out, "\\begin{cxxfunction}\n");	    break;	case MACRO_SEC:	    fprintf(out, "\\begin{cxxmacro}\n");	    break;	case CLASS_SEC:	    fprintf(out, "\\begin{cxxclass}\n");	    break;	case INTERFACE_SEC:	    fprintf(out, "\\begin{cxxinterface}\n");	    break;	case UNION_SEC:	    fprintf(out, "\\begin{cxxunion}\n");	    break;	case NAMESPACE_SEC:	    fprintf(out, "\\begin{cxxnamespace}\n");	    break;	default:	    fprintf(out, "\\begin{cxxentry}\n");	    break;	}    dumpCxxItem(entry);    char file_name[BUFSIZ];    strlatex(file_name, entry->file.c_str());    if(showFilenames &&	entry->section != PACKAGE_SEC &&	entry->section != MANUAL_SEC)	fprintf(out, "In file %s:%d \\\\\n", (const char *)file_name, entry->startLine);    fields = dumpFields(entry);    if(HAS_BASES(entry) || entry->pubChilds.size() || entry->proChilds.size())	dumpHierarchy(entry);    if(entry->sub)	if((entry->section & INTERFACE_SEC) || (entry->section & CLASS_SEC))	    {	    for(tmp = entry->sub; tmp; tmp = tmp->next)		if(tmp->protection == PUBL)		    {		    fprintf(out, "\\begin{cxxpublic}\n");		    for(tmp = entry->sub; tmp; tmp = tmp->next)			if(tmp->protection == PUBL)			    {			    fprintf(out, "\\cxxitem");			    dumpCxxItem(tmp);			    }		    fprintf(out, "\\end{cxxpublic}\n");		    break;		    }	    for(tmp = entry->sub; tmp; tmp = tmp->next)		if(tmp->protection == PROT)		    {		    fprintf(out, "\\begin{cxxprotected}\n");		    for(tmp = entry->sub; tmp; tmp = tmp->next)			if(tmp->protection == PROT)			    {			    fprintf(out, "\\cxxitem");			    dumpCxxItem(tmp);			    }		    fprintf(out, "\\end{cxxprotected}\n");		    break;		    }	    if(withPrivate)		{		for(tmp = entry->sub; tmp; tmp = tmp->next)		    if(tmp->protection == PRIV)			{			fprintf(out, "\\begin{cxxprivate}\n");			for(tmp = entry->sub; tmp; tmp = tmp->next)			    if(tmp->protection == PRIV)				{				fprintf(out, "\\cxxitem");				dumpCxxItem(tmp);				}			fprintf(out, "\\end{cxxprivate}\n");			break;			}		}	    }	else	    if(!hideIndexOnEverySection)		{		fprintf(out, "\\begin{cxxnames}\n");	    		for(tmp = entry->sub; tmp; tmp = tmp->next)		    {		    fprintf(out, "\\cxxitem");		    dumpCxxItem(tmp);		    }		fprintf(out, "\\end{cxxnames}\n");		}    if(entry->doc.length())	{	fprintf(out, "\\begin{cxxdoc}\n");	printYYDOC(entry, entry->doc, 0);	fprintf(out, "\n\\end{cxxdoc}\n");	}    for(tmp = entry->sub; tmp; tmp = tmp->next)	if(tmp->protection == PUBL && MAKE_DOC(tmp))	    dumpEntry(tmp);    for(tmp = entry->sub; tmp; tmp = tmp->next)	if(tmp->protection == PROT && MAKE_DOC(tmp))	    dumpEntry(tmp);    if(withPrivate)	for(tmp = entry->sub; tmp; tmp = tmp->next)	    if(tmp->protection == PRIV && MAKE_DOC(tmp))		dumpEntry(tmp);    switch(entry->section)	{	case VARIABLE_SEC:	    fprintf(out, "\\end{cxxvariable}\n");	    break;	case FUNCTION_SEC:	    fprintf(out, "\\end{cxxfunction}\n");	    break;	case UNION_SEC:	    fprintf(out, "\\end{cxxunion}\n");	    break;	case MACRO_SEC:	    fprintf(out, "\\end{cxxmacro}\n");	    break;	case CLASS_SEC:	    fprintf(out, "\\end{cxxclass}\n");	    break;	case INTERFACE_SEC:	    fprintf(out, "\\end{cxxinterface}\n");	    break;	case NAMESPACE_SEC:	    fprintf(out, "\\end{cxxnamespace}\n");	    break;	default:	    fprintf(out, "\\end{cxxentry}\n");	    break;	}}static int atMostDepth(Entry *tmp, int depth){    if(depth && tmp)	return atMostDepth(tmp->parent, depth - 1);    return !tmp;}static bool relevantContents(Entry *tmp){    for(tmp = tmp->sub; tmp; tmp = tmp->next)	if(MAKE_DOC(tmp) && (atMostDepth(tmp, depthTOC + 1) ||	    (tmp->section & CLASS_SEC) ||	    tmp->section == UNION_SEC ||	    tmp->section == MANUAL_SEC ||	    (tmp->section & INTERFACE_SEC) ||	    tmp->section == PACKAGE_SEC ||	    tmp->section == NAMESPACE_SEC))	    return true;    return false;}static void dumpContents(Entry *tmp){    for(tmp = tmp->sub; tmp; tmp = tmp->next)	if(MAKE_DOC(tmp) && (atMostDepth(tmp, depthTOC + 1) ||	    (tmp->section & CLASS_SEC) ||	    tmp->section == UNION_SEC ||	    tmp->section == MANUAL_SEC ||	    (tmp->section & INTERFACE_SEC) ||	    tmp->section == PACKAGE_SEC ||	    tmp->section == NAMESPACE_SEC))	    {	    fprintf(out, "\\cxxContentsEntry{");	    tmp->dumpNumber(out);	    fprintf(out, "}{");	    printCode(tmp, getEntryName(tmp));	    fprintf(out, "}{");	    printYYDOC(tmp, tmp->memo.c_str());	    fprintf(out, "}\n");	    if(tmp->sub && relevantContents(tmp))		{		fprintf(out, "\\begin{cxxContents}\n");		dumpContents(tmp);		fprintf(out, "\\end{cxxContents}\n");		}	    }}static void dumpClassGraph(Entry *entry){    ClassGraph cg(entry, 0);    ClassGraph *cls = &cg;    cg.addBases();    cg.addAllChilds();    fprintf(out, "\\strut\\\\[5pt]\\goodbreak\n");    if((cls->entry->fromUnknownPackage) || (onlyClassGraph))    	fprintf(out, "\\cxxClassGraphEntryUnknownPackage{");    else	{    	fprintf(out, "\\cxxClassGraphEntry{");   	fprintf(out, "}{");	cls->entry->dumpNumber(out);	}    fprintf(out, "}{");    printCode(cls->entry, getEntryName(cls->entry));    fprintf(out, "}{");    fprintf(out, "}\n");    for(cls = cls->nextLine; cls; cls = cls->nextLine)	{	if((cls->entry->fromUnknownPackage) || (onlyClassGraph))	    fprintf(out, "\\cxxClassGraphEntryUnknownPackage{");	else	    fprintf(out, "\\cxxClassGraphEntry{");	for(int i = 0; i < cls->indent; ++i)	    fprintf(out, "\\cxxNone");	printYYGraph(cls->before);	if((!cls->entry->fromUnknownPackage) && (!onlyClassGraph))	    {	    fprintf(out, "}{");	    cls->entry->dumpNumber(out);	    }	fprintf(out, "}{");	printCode(cls->entry, getEntryName (cls->entry));	fprintf(out, "}{");	fprintf(out, "}\n");	}}static void dumpClassGraphs(Entry *tmp){    for(; tmp; tmp = tmp->next)	{	if((tmp->section & CLASS_SEC) &&	    tmp->proBaseclasses.size() == 0 &&	    tmp->pubBaseclasses.size() == 0)	    {	    tmp->currentParent = 0;	    dumpClassGraph(tmp);	    }	dumpClassGraphs(tmp->sub);	}}void usermanTeX(char *str, Entry *root){    Entry *tmp;    initLatex();    if(root->sub && root->sub->next == 0 && root->sub->section == MANUAL_SEC)	{	root = root->sub;	root->parent = 0;	}    if(!onlyClassGraph)	{    	if(root->name.length())	    {	    dumpFields(root);	    fprintf(out, "\\cxxTitle");	    dumpCxxItem(root);    	    }	fprintf(out, "\\begin{cxxContents}\n");    	dumpContents(root);	if(!noClassGraph && relevantClassGraphs(root))    	    fprintf(out, "\\cxxContentsEntry{}{Class Graph}{}");    	fprintf(out, "\\end{cxxContents}\n");    	if(root->name.length())    	    {	    fprintf(out, "\\clearpage\\pagebreak\n");	    if(root->doc.length())		{	    	fprintf(out, "\\begin{cxxdoc}\n");	    	printYYDOC(root, root->doc, 0);	    	fprintf(out, "\n\\end{cxxdoc}\n");		}    	    }    	for(tmp = root->sub; tmp; tmp = tmp->next)	    dumpEntry(tmp);	}    if(!noClassGraph && relevantClassGraphs(root))	{	fprintf(out, "\\begin{cxxClassGraph}\n");	fprintf(out, "\\label{cxx.}\n");	root->currentParent = 0;	dumpClassGraphs(root);	fprintf(out, "\\end{cxxClassGraph}\n");	}    finitLatex();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -