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

📄 html.cc

📁 Doc++,可以根据你的C/C++和java的源码文件中的注释行自动生成Html说明文件的工具
💻 CC
📖 第 1 页 / 共 4 页
字号:
    using addMember. It returns NULL in case this is a new Member, != 0    otherwise.*/class MemberList {	McHashTable<char *, Entry *> list;    public:	MemberList() : list((Entry *)NULL)	    {}	/** Add a new member. Returns NULL, if no compatible member	    has yet occurred.	*/	Entry *addMember(Entry *e, Entry *father)	    {	    McString signature = e->name;	    char *tmp;	    if(language == LANG_JAVA || language == LANG_PHP)		signature += e->args;	    tmp = strdup(signature.c_str());	    Entry **val = list.insert(tmp);	    if(*val == 0)		{		*val = father;		return 0;		}	    else		{#ifdef DEBUG		if(verb)		    printf(_("Member `%s' was there\n"), tmp);#endif		free(tmp);		}	    return *val;	    }};void showSubMembers(FILE *f, Entry *entry);void showMembers(Entry *e, FILE *f, int links, MemberList *ignore = 0){    static struct {	char *heading;	int protection;	int secMask;    } sections[] = {      { _("<DT><H3>Public Fields</H3><DD>"), PUBL, VARIABLE_SEC },      { _("<DT><H3>Public Methods</H3><DD>"), PUBL, FUNCTION_SEC},      { _("<DT><H3>Public Members</H3><DD>"), PUBL, ~(VARIABLE_SEC | FUNCTION_SEC) },      { _("<DT><H3>Protected Fields</H3><DD>"), PROT, VARIABLE_SEC },      { _("<DT><H3>Protected Methods</H3><DD>"), PROT, FUNCTION_SEC },      { _("<DT><H3>Protected Members</H3><DD>"), PROT, ~(VARIABLE_SEC | FUNCTION_SEC) },      { _("<DT><H3>Private Fields</H3><DD>"), PRIV, VARIABLE_SEC },      { _("<DT><H3>Private Methods</H3><DD>"), PRIV, FUNCTION_SEC },      { _("<DT><H3>Private Members</H3><DD>"), PRIV, ~(VARIABLE_SEC | FUNCTION_SEC) },      { 0, 0, 0 }};    int i;    Entry *tmp, *type, *othersFather;    MemberWriter *memberWriter;    bool ignoreThisOne;    fprintf(f, "<DL>\n");    if(withTables && links)	memberWriter = new MemberWriterTable();    else	memberWriter = new MemberWriter();    for(i = 0; sections[i].heading; i++)	if(withPrivate || sections[i].protection != PRIV)	    {	    memberWriter->startList(f, sections[i].heading, links);	    for(tmp = e->sub; tmp; tmp = tmp->next)		{                type = tmp;                if(tmp->section & MANUAL_SEC)                    {                    if(tmp->sub)                         type=tmp->sub;                    else                        continue; // skip empty sections                    }     		if(tmp->protection == sections[i].protection &&		    (type->section & sections[i].secMask))		    if(links ||			(tmp->name != e->name && (tmp->name[0] != '~' ||			    strcmp(tmp->name.c_str() + 1, e->name.c_str()) != 0)))			{			ignoreThisOne = false;			if(ignore)			    {			    othersFather = ignore->addMember(tmp, e);			    if(othersFather != 0 && othersFather != e)				ignoreThisOne = true;			    }			bool withSub = (tmp->section == MANUAL_SEC && showMembersInTOC);			if(!ignoreThisOne || links)			    memberWriter->addMember(tmp, links, withSub);			}		}	    memberWriter->endList();	    }    delete memberWriter;    fprintf(f, "</DL>\n");}void writeInherited(Entry *k, FILE *f, MemberList *list = 0){    int i;    showMembers(k, f, 0, list);    for(i = 0; i < k->baseclasses.size(); i++)	{	fprintf(f, _("<HR><H3>Inherited from <A HREF=\"%s\">%s</A>:</H3>\n"),	    (k->baseclasses)[i]->fileName.c_str(),	    (k->baseclasses)[i]->hname);	writeInherited((k->baseclasses)[i], f, list);	}}void writeHTMLList(FILE *f, McDArray<McString *> list, char *description){    int i, k;    if(list.size() > 0)	{	fprintf(f, "<DT><B>%s:</B><DD>", description);	for(i = 0; i < list.size(); i++)	    {	    k = 0;	    fprintf(f, "  ");	    while(k < list[i]->length())		fprintf(f, "%c", (*list[i])[k++]);	    fprintf(f, "<BR>");	    }	}}/** This function writes the @-fields (except @memo, @name) of the    specified entry*/void writeTags(FILE *f, Entry *entry){    int i, k;    fprintf(f, "<DL><DT>");    writeHTMLList(f, entry->invariant, "Invariants");    if(entry->exception.size())	{	fprintf(f, _("<DT><B>Throws:</B><DD>"));	for(i = 0; i < entry->exception.size(); i++)	    {	    k = 0;	    McString s;	    while(k < entry->exception[i]->length() &&		(myisalnum((*entry->exception[i])[k]) ||		(*entry->exception[i])[k] == '_' ||		(*entry->exception[i])[k] == '<' ||		(*entry->exception[i])[k] == '>' ||		(*entry->exception[i])[k] == ':'))		s += (*entry->exception[i])[k++];	    fprintf(f, "<B>%s</B> ", strToHtml(s, 0, entry, true, true));	    while(k < entry->exception[i]->length())		fprintf(f, "%c", (*entry->exception[i])[k++]);	    fprintf(f, "<BR>");	    }	}    if(entry->param.size())	{	fprintf(f, _("<DT><B>Parameters:</B><DD>"));	for(k = 0; k < entry->param.size(); k++)	    {	    i = 0;	    fprintf(f,"<B>");	    while(i < entry->param[k]->length() &&		(myisalnum((*entry->param[k])[i]) || 		(*entry->param[k])[i] == '_'))		fprintf(f, "%c", (*entry->param[k])[i++]);	    fprintf(f, "</B> - ");	    while(i < entry->param[k]->length())		fprintf(f, "%c", (*entry->param[k])[i++]);	    fprintf(f, "<BR>");	    }	}    if(entry->field.size())	{	fprintf(f, _("<DT><B>Fields:</B><DD>"));	for(k = 0; k < entry->field.size(); k++)	    {	    i = 0;	    fprintf(f,"<B>");	    while(i < entry->field[k]->length() &&		(myisalnum((*entry->field[k])[i]) || 		(*entry->field[k])[i] == '_'))		fprintf(f, "%c", (*entry->field[k])[i++]);	    fprintf(f, "</B> - ");	    while(i < entry->field[k]->length())		fprintf(f, "%c", (*entry->field[k])[i++]);	    fprintf(f, "<BR>");	    }	}    writeHTMLList(f, entry->retrn, _("Returns"));    writeHTMLList(f, entry->precondition, _("Preconditions"));
    writeHTMLList(f, entry->postcondition, _("Postconditions"));
    writeHTMLList(f, entry->friends, _("Friends"));    if(entry->author.length())	fprintf(f, _("<DT><B>Author:</B><DD>%s\n"), entry->author.c_str());    if(entry->version.length())	fprintf(f, _("<DT><B>Version:</B><DD>%s\n"), entry->version.c_str());    if(entry->deprecated.length())	fprintf(f, _("<DT><B><I>Deprecated:</I></B><DD>%s\n"), entry->deprecated.c_str());    if(entry->since.length())	fprintf(f, _("<DT><B>Since:</B><DD>%s\n"), entry->since.c_str());    if(entry->see.size())	{	fprintf(f, _("<DT><B>See Also:</B><DD>"));	for(k = 0; k < entry->see.size(); k++)	    if(entry->see[k]->length())		fprintf(f, "%s<BR>", seeToHtml(*entry->see[k], entry));	}    fprintf(f, "<DD></DL><P>");}void writeDoc(FILE *f, Entry *entry){      if(entry->ownPage)	return;    int toBeDocumented = subEntryIsToBeDocumented(entry);    Entry *tmp;    if(toBeDocumented)	{	char *args = (entry->hargs);	char *type = (entry->htype);	printRefLabel(f, entry);	fprintf(f, "<DT>");	fprintf(f, "<IMG ALT=\"o\" BORDER=0 SRC=icon2.gif><TT><B>%s %s",	    type, entry->hname);	fprintf(f, "%s", args);		if(entry->pureVirtual)	    fprintf(f, " = 0");	fprintf(f, "</B></TT>\n");	if(entry->doc.length() > 0)	    fprintf(f, "<DD>%s\n", entry->hdoc);	else	    if(entry->memo.length() > 0)		fprintf(f, "<DD>%s\n", entry->hmemo);	writeTags(f, entry);	}    if(entry->sub)	{	fprintf(f, "<DL>\n");	for(tmp = entry->sub; tmp; tmp = tmp->next)	    writeDoc(f, tmp);	fprintf(f, "</DL>\n");	}}// Replace all occurrences of "pattern" in "str" with "value"static McString substitute(const McString& str,			   const McString& pattern,			   const McString& value){    McString result(str);    int ndx;    while ((ndx = result.index(pattern.c_str(), 0)) >= 0) {	McString before(result, 0, ndx);	McString after(result, ndx + pattern.length(),	    result.length() - (ndx + pattern.length()));	result = before;	result += value;	result += after;    }    return result;}// Given a template string and an entry, substitute entry-specific// data (such as its type or name) and return the result.static McString processTemplate(const McString& tmpl, const Entry *e){    McString result(tmpl);    result = substitute(result, "%file", e->file);    result = substitute(result, "%fullname", e->fullName);    result = substitute(result, "%name", e->name);    result = substitute(result, "%type", e->type);    return result;}int strlenNoHtml(char *in){    int braces = 0;    unsigned int i, count = 0;    for(i = 0; i < strlen(in); i++)	if((in[i] == '<') && (braces == 0))	    braces = 1;	else	    if((in[i] == '>') && (braces == 1))		braces = 0;	    else		if(braces == 0)		    count++;    return count;}void writeHeader(Entry *e, FILE *f){    McString tmp;    int blank_len, arg_len;    char *args, *arg;    if(header.length() == 0 && ownHeader.length() == 0)	{	fprintf(f, "%s", docType);	fprintf(f, "<HTML>\n");	fprintf(f, "<HEAD>\n");	fprintf(f, "   <TITLE>%s %s</TITLE>\n", e->type.c_str(),	    ENTRY_NAME(e).c_str());	fprintf(f, "   <META NAME=\"GENERATOR\" CONTENT=\"DOC++ " DOCXX_VERSION "\">\n");	fprintf(f, "%s", styleSheet.c_str());	fprintf(f, "</HEAD>\n");	tmp = processTemplate(pageHeader, e);	}    else	tmp = processTemplate(header, e);    fprintf(f, "%s\n", tmp.c_str());    if(showFilenames && e->section != PACKAGE_SEC && e->section != MANUAL_SEC)	fprintf(f, _("In file %s:"), e->file.c_str());    if(e->section == PACKAGE_SEC)	{	e->getPackage(tmp);	fprintf(f, _("<H2>Package %s</H2>"), tmp.c_str());	}    else	{	if(withTables)	    {	    fprintf(f, "<TABLE BORDER=0><TR>\n");	    fprintf(f, "<TD VALIGN=TOP>");	    }	fprintf(f, "<H2>");	if(language == LANG_JAVA)	    {	    e->getPackage(tmp);	    if(tmp.length() < 1)		{		blank_len = strlen(e->htype) + strlen(e->hname) + 2;		fprintf(f, "%s <A HREF=\"#DOC.DOCU\"> %s", e->htype, e->hname);		}	    else		{		blank_len = strlen(e->htype) + strlen(tmp.c_str()) + strlen(e->hname) + 2;		fprintf(f, "%s <A HREF=\"#DOC.DOCU\">%s.%s", e->htype,		    tmp.c_str(), e->hname);	        }	    }	else            {	    blank_len = strlen(e->htype) + strlen(ENTRY_NAME(e).c_str()) + 1;	    fprintf(f, "%s <A HREF=\"#DOC.DOCU\">", e->htype);            if(e->section == CLASS_SEC ||        	e->section == NAMESPACE_SEC ||        	e->section == TYPEDEF_SEC ||                e->section == UNION_SEC)		{                char	buf0[256], buf1[256];                Entry*	p = e->parent;                sprintf(buf0, e->name.c_str());                while(p != 0 && p->section == NAMESPACE_SEC)		    {                    sprintf(buf1, "%s::%s", p->name.c_str(), buf0);                    strcpy(buf0, buf1);                    p = p->parent;        	    }                fprintf(f, "%s", buf0);		}	    else                fprintf(f, "%s", ENTRY_NAME(e).c_str());	    }	fprintf(f, "</A></H2>");	if(withTables)	    fprintf(f, "</TD>");	// wrap function declaration with long argument list	if(e->hargs[0] == '(')	    {	    args = (char *)malloc(strlen(e->hargs) + 1);	    strcpy(args, &(e->hargs[1]));	    arg = strtok(args, ",");	    arg_len = strlenNoHtml(arg);	    if(withTables)		fprintf(f, "<TD>");	    fprintf(f, "<H2>(%s", arg);	    while((arg = strtok(NULL, ",")) != NULL)		{		arg_len += strlenNoHtml(arg);		if((arg_len + blank_len) < 62)		    fprintf(f, ", %s", arg);		else		    {		    fprintf(f, ",<BR>&nbsp;%s", arg);		    arg_len = strlenNoHtml(arg);		    }		}	    }	fprintf(f, "</H2>");	if(withTables)	    fprintf(f, "</TD></TR></TABLE>\n");	}    htmlComment(f, e, MEMO);}void writeManPage(Entry *e, FILE *f){    int i, numChilds, numParents = 0;    Entry *c, *tmp;    McString buf;    MemberList list;    MemberWriter memberWriter;#ifdef DEBUG    if(verb)	printf(_("Writing page for `%s %s%s'\n"), e->type.c_str(),	    e->fullName.c_str(), e->args.c_str());#endif    // the page header    writeHeader(e, f);    if(printClassDocBeforeGroup)	{	// the documentation	fprintf(f, _("<HR>\n<H2>Documentation</H2>\n"));	htmlComment (f, e, (DOC | MEMO));	fprintf(f, "\n<A NAME=\"DOC.DOCU\"></A>\n");	}    if(e->isClass())            // is it really a class?	{ 	// the inheritance	numChilds = e->pubChilds.size() + e->proChilds.size() + e->priChilds.size();	if(language == LANG_JAVA)	    numParents = e->pubBaseclasses.size()+ e->proBaseclasses.size() +		e->otherPubBaseclasses.size() + e->otherProBaseclasses.size();	else	    numParents = e->pubBaseclasses.size() + e->priBaseclasses.size() +		e->proBaseclasses.size() + e->otherPubBaseclasses.size() +		e->otherPriBaseclasses.size() + e->otherProBaseclasses.size();	if(numParents > 0 || numChilds > 0 || trivialGraphs)	    {	    fprintf(f, _("<HR>\n\n<H2>Inheritance:</H2>\n"));	    ClassGraphWriter::write(f, e);	    if(language == LANG_JAVA && e->implements.size() > 0)		ClassGraphWriter::writeImplements(f, e);	    }	// the members 	if(e->sub)	    {	    fprintf(f, "<HR>\n\n");	    showMembers(e, f, 1, &list);	    }	}    else                       // this is not a class	{ 	if(e->sub)	    {	    fprintf(f, "\n<HR>\n");	    memberWriter.startList(f, " ", true);	    for(tmp = e->sub; tmp; tmp = tmp->next)		memberWriter.addMember(tmp, true, false);	    }	memberWriter.endList();	}    // the inherited members    if(e->isClass())            // is it really a class?	if(showInherited)	    for(i = 0; i < e->baseclasses.size(); i++)		{		fprintf(f, _("<HR><H3>Inherited from <A HREF=\"%s\">%s</A>:</H3>\n"),		    (e->baseclasses)[i]->fileName.c_str(),		    (e->baseclasses)[i]->hname);		writeInherited((e->baseclasses)[i], f, &list);		}    if(!printClassDocBeforeGroup)	{	// the documentation	fprintf(f, "\n<A NAME=\"DOC.DOCU\"></A>\n");	fprintf(f, _("<HR>\n<H2>Documentation</H2>\n"));	htmlComment (f, e, (DOC | MEMO));	}    if(e->sub)	{	fprintf(f, "<DL>\n");	for(tmp = e->sub; tmp; tmp = tmp->next)	    writeDoc(f, tmp);	fprintf(f, "</DL>\n");	}    // the childrens    if(e->isClass())            // is it really a class?	if(e->pubChilds.size() || e->proChilds.size())	    {	    fprintf(f, _("<HR>\n<DL><DT><B>Direct child classes:\n</B><DD>"));	    c = e;	    for(i = 0; i < c->pubChilds.size(); i++)		fprintf(f, "<A HREF=\"%s\">%s</A><BR>\n",		    c->pubChilds[i]->fileName.c_str(),		    c->pubChilds[i]->hname);	    for(i = 0; i < c->proChilds.size(); i++)		fprintf(f, "<A HREF=\"%s\">%s</A><BR>\n",		    c->proChilds[i]->fileName.c_str(),		    c->proChilds[i]->hname);	    fprintf(f, "</DL>\n\n");	    }	else	    fprintf(f, _("\n<HR><DL><DT><B>This class has no child classes.</B></DL>\n\n"));    writeTags(f, e);    if(javaGraphs)	buf = processTemplate(pageFooterJava, e);    else	buf = processTemplate(pageFooter, e);    fprintf(f, "%s", buf.c_str());    copyright(f);}static FILE *myOpen(const char *dir, const McString& name){    FILE *f;    McString buf = dir;

⌨️ 快捷键说明

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