compile完了之后,发现了几个问题。
1、每个type的html中,诸如:class/namespace等,都是E文的,而不是中文的。看起来不爽。
2、对于任何一个class,都会有object类的一些方法,如:"Equals","Finalize","GetHashCode","GetType","MemberwiseClone","ToString","GetObject"这些方法。我不想让它显示出来。
然后开始看ndoc的source,跟踪了一会,发现问题1中,在Documenter下面的每个adapter下面的xslt目录下,那些xslt文件包含了这些内容。修改之,重新编译,搞定。
对于问题2,找到了代码,在MsdnDocumenter.cs中的方法:MakeHtmlForMethods。修改如下:
private void MakeHtmlForMethods(WhichType whichType, XmlNode typeNode)
{
XmlNodeList declaredMethodNodes = typeNode.SelectNodes("method[not(@declaringType)]");
if (declaredMethodNodes.Count > 0)
{
bool bOverloaded = false;
string fileName;
string typeName = typeNode.Attributes["name"].Value;
string typeID = typeNode.Attributes["id"].Value;
XmlNodeList methodNodes = typeNode.SelectNodes("method");
int nNodes = methodNodes.Count;
int[] indexes = SortNodesByAttribute(methodNodes, "id");
fileName = GetFilenameForMethods(whichType, typeNode);
htmlHelp.AddFileToContents("Methods", fileName);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddParam("id", String.Empty, typeID);
arguments.AddParam("member-type", String.Empty, "method");
TransformAndWriteResult(xsltIndividualMembers, arguments, fileName);
htmlHelp.OpenBookInContents();
// 鞠强添加的部分
string[] skipped = new string[]{"Equals","Finalize","GetHashCode","GetType","MemberwiseClone","ToString","GetObject"};
// 添加完成
for (int i = 0; i < nNodes; i++)
{
XmlNode methodNode = methodNodes[indexes[i]];
string methodName = (string)methodNode.Attributes["name"].Value;
string methodID = (string)methodNode.Attributes["id"].Value;
// 鞠强修改:
// 目的是不显示如下7个Object的方法:
// Equals
// Finalize
// GetHashCode
// GetType
// MemberwiseClone
// ToString
// GetObject
int qq = 0;
for(qq=0;qq<skipped.Length;qq++)
{
// 如果在上述范围之内,就不处理
if(methodName == skipped[qq])break;
}
if(qq<skipped.Length)continue;
// 修改完毕
if (IsMethodFirstOverload(methodNodes, indexes, i))
{
bOverloaded = true;
fileName = GetFilenameForMethodOverloads(typeNode, methodNode);
htmlHelp.AddFileToContents(methodName + " Method", fileName);
arguments = new XsltArgumentList();
arguments.AddParam("member-id", String.Empty, methodID);
TransformAndWriteResult(xsltMemberOverload, arguments, fileName);
htmlHelp.OpenBookInContents();
}
if (methodNode.Attributes["declaringType"] == null)
{
fileName = GetFilenameForMethod(methodNode);
if (bOverloaded)
{
XmlNodeList parameterNodes = xmlDocumentation.SelectNodes("/ndoc/assembly/module/namespace/" + lowerCaseTypeNames[whichType] + "[@name="" + typeName + ""]/method[@id="" + methodID + ""]/parameter");
htmlHelp.AddFileToContents(methodName + " Method " + GetParamList(parameterNodes), fileName,
HtmlHelpIcon.Page );
}
else
{
htmlHelp.AddFileToContents(methodName + " Method", fileName,
HtmlHelpIcon.Page );
}
XsltArgumentList arguments2 = new XsltArgumentList();
arguments2.AddParam("member-id", String.Empty, methodID);
TransformAndWriteResult(xsltMember, arguments2, fileName);
}
if (bOverloaded && IsMethodLastOverload(methodNodes, indexes, i))
{
bOverloaded = false;
htmlHelp.CloseBookInContents();
}
}
htmlHelp.CloseBookInContents();
}
}
{
XmlNodeList declaredMethodNodes = typeNode.SelectNodes("method[not(@declaringType)]");
if (declaredMethodNodes.Count > 0)
{
bool bOverloaded = false;
string fileName;
string typeName = typeNode.Attributes["name"].Value;
string typeID = typeNode.Attributes["id"].Value;
XmlNodeList methodNodes = typeNode.SelectNodes("method");
int nNodes = methodNodes.Count;
int[] indexes = SortNodesByAttribute(methodNodes, "id");
fileName = GetFilenameForMethods(whichType, typeNode);
htmlHelp.AddFileToContents("Methods", fileName);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddParam("id", String.Empty, typeID);
arguments.AddParam("member-type", String.Empty, "method");
TransformAndWriteResult(xsltIndividualMembers, arguments, fileName);
htmlHelp.OpenBookInContents();
// 鞠强添加的部分
string[] skipped = new string[]{"Equals","Finalize","GetHashCode","GetType","MemberwiseClone","ToString","GetObject"};
// 添加完成
for (int i = 0; i < nNodes; i++)
{
XmlNode methodNode = methodNodes[indexes[i]];
string methodName = (string)methodNode.Attributes["name"].Value;
string methodID = (string)methodNode.Attributes["id"].Value;
// 鞠强修改:
// 目的是不显示如下7个Object的方法:
// Equals
// Finalize
// GetHashCode
// GetType
// MemberwiseClone
// ToString
// GetObject
int qq = 0;
for(qq=0;qq<skipped.Length;qq++)
{
// 如果在上述范围之内,就不处理
if(methodName == skipped[qq])break;
}
if(qq<skipped.Length)continue;
// 修改完毕
if (IsMethodFirstOverload(methodNodes, indexes, i))
{
bOverloaded = true;
fileName = GetFilenameForMethodOverloads(typeNode, methodNode);
htmlHelp.AddFileToContents(methodName + " Method", fileName);
arguments = new XsltArgumentList();
arguments.AddParam("member-id", String.Empty, methodID);
TransformAndWriteResult(xsltMemberOverload, arguments, fileName);
htmlHelp.OpenBookInContents();
}
if (methodNode.Attributes["declaringType"] == null)
{
fileName = GetFilenameForMethod(methodNode);
if (bOverloaded)
{
XmlNodeList parameterNodes = xmlDocumentation.SelectNodes("/ndoc/assembly/module/namespace/" + lowerCaseTypeNames[whichType] + "[@name="" + typeName + ""]/method[@id="" + methodID + ""]/parameter");
htmlHelp.AddFileToContents(methodName + " Method " + GetParamList(parameterNodes), fileName,
HtmlHelpIcon.Page );
}
else
{
htmlHelp.AddFileToContents(methodName + " Method", fileName,
HtmlHelpIcon.Page );
}
XsltArgumentList arguments2 = new XsltArgumentList();
arguments2.AddParam("member-id", String.Empty, methodID);
TransformAndWriteResult(xsltMember, arguments2, fileName);
}
if (bOverloaded && IsMethodLastOverload(methodNodes, indexes, i))
{
bOverloaded = false;
htmlHelp.CloseBookInContents();
}
}
htmlHelp.CloseBookInContents();
}
}
不知道,我插入的代码为什么不管用呢?!那7个方法,还是继续显示出来了。。。