GhostDoc使用與原始註釋

一、簡介

  GhostDoc是Visual Studio的一個免費插件,可以爲開發人員自動生成XML格式的註釋文檔。

  

  二、下載

  需要的朋友可以去這裏下載,填個Email地址就可以下了:GhostDoc下載地址

  

  三、安裝

  下載安裝完成後,可以在Visual Studio的工具菜單下找到GhostDoc的身影。

 

  三、使用

  在使用的時候,主要是進行設置,設置好了調用快捷鍵就可以了。

 

下面附上,註釋的原始文件。

文件註釋:

<#@ template language="C#" #>
// ***********************************************************************
// Assembly         : <#= Context.AssemblyName #>
// Author           : <#= Context.GetGlobalProperty("UserName") #>
// Created          : <#= Context.DestinationFileCreationDateTime.ToString("MM-dd-yyyy") #>
//
// Last Modified By : <#= Context.GetGlobalProperty("UserName") #>
// Last Modified On : <#= Context.DestinationFileModificationDateTime.ToString("MM-dd-yyyy") #>
// ***********************************************************************
// <copyright file="<#= System.IO.Path.GetFileName(Context.DestinationFile) #>" company="<#= Context.GetGlobalProperty("CompanyName") #>">
//     Copyright (c) <#= Context.GetGlobalProperty("CompanyName") #>. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************


類註釋:

<#@ template language="C#" #>
<#  CodeElement codeElement = Context.CurrentCodeElement; #>
/// <summary>
///<# GenerateSummaryText(); #>
/// </summary>
<#  if(codeElement.HasTypeParameters) 
	{
		for(int i = 0; i < codeElement.TypeParameters.Length; i++) 
		{ 
			TypeParameter typeParameter = codeElement.TypeParameters[i]; 
#>
/// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>
<#		}	
	} 
#>
<#= Context.GetNonGeneratedTags() #>
<# GenerateRemarksText(); #>

<#+
	private void GenerateSummaryText()
	{
		if(Context.HasExistingTagText("summary"))
		{
			this.WriteLine(Context.GetExistingTagText("summary"));
		}
		else
		{
			this.WriteLine("Class " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));
		}
	}
    
	private void GenerateTypeParamText(TypeParameter typeParameter, int index)
	{
		if(Context.HasExistingTagText("typeparam", index)) 
		{ 
			this.Write(Context.GetExistingTagText("typeparam", index));
		} 
		else 
		{
			string typeParameterName = typeParameter.Name;
			if(typeParameterName != null)
			{
				if(typeParameterName.Length == 1)
				{
					this.Write("");
				}
				else
				{
					this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");
				}            
			}          
		} 
	}
	
	private void GenerateRemarksText()
	{
		if(Context.HasExistingTagText("remarks"))
		{ #>
/// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>
<#+	    }
		else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))
		{ 
            // Should you require a default comment, set it in
			// Options -> Global Properties -> DefaultBlankRemarksText		
#>
/// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>
<#+	    }
	}	
#>


接口註釋

<#@ template language="C#" #>
<#  CodeElement codeElement = Context.CurrentCodeElement; #>
/// <summary>
///<# GenerateSummaryText(); #>
/// </summary>
<#	if(codeElement.HasTypeParameters) 
	{
		for(int i = 0; i < codeElement.TypeParameters.Length; i++) 
		{ 
			TypeParameter typeParameter = codeElement.TypeParameters[i]; 
#>
/// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>
<#		}	
	} 
#>
<#= Context.GetNonGeneratedTags() #>
<# GenerateRemarksText(); #>

<#+
	private void GenerateSummaryText()
	{
		if(Context.HasExistingTagText("summary"))
		{
			this.WriteLine(Context.GetExistingTagText("summary"));
		}
		else
		{
			this.WriteLine("Interface " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));
		}
	}

	private void GenerateTypeParamText(TypeParameter typeParameter, int index)
	{
		if(Context.HasExistingTagText("typeparam", index)) 
		{ 
			this.Write(Context.GetExistingTagText("typeparam", index));
		} 
		else 
		{
			string typeParameterName = typeParameter.Name;
			if(typeParameterName != null)
			{
				if(typeParameterName.Length == 1)
				{
					this.Write("");
				}
				else
				{
					this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");
				}            
			}          
		} 
	}
		
	private void GenerateRemarksText()
	{
		if(Context.HasExistingTagText("remarks"))
		{ #>
/// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>
<#+	    }
		else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))
		{ 
            // Should you require a default comment, set it in
			// Options -> Global Properties -> DefaultBlankRemarksText		
#>
/// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>
<#+	    }
	}	
#>


 

發佈了112 篇原創文章 · 獲贊 19 · 訪問量 29萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章