GhostDoc使用与原始注释

一、简介

  GhostDoc是Visual Studio的一个免费插件,可以为开发人员自动生成XML格式的注释文档。

  

  二、下载

  需要的朋友可以去这里下载,填个Email地址就可以下了:GhostDoc下载地址

  

  三、安装

  下载安装完成后,可以在Visual Studio的工具菜单下找到GhostDoc的身影。

 

  三、使用

  在使用的时候,主要是进行设置,设置好了调用快捷键就可以了。

 

下面附上,注释的原始文件。

文件注释:

[csharp]  view plain copy
  1. <#@ template language="C#" #>  
  2. // ***********************************************************************  
  3. // Assembly         : <#= Context.AssemblyName #>  
  4. // Author           : <#= Context.GetGlobalProperty("UserName") #>  
  5. // Created          : <#= Context.DestinationFileCreationDateTime.ToString("MM-dd-yyyy") #>  
  6. //  
  7. // Last Modified By : <#= Context.GetGlobalProperty("UserName") #>  
  8. // Last Modified On : <#= Context.DestinationFileModificationDateTime.ToString("MM-dd-yyyy") #>  
  9. // ***********************************************************************  
  10. // <copyright file="<#= System.IO.Path.GetFileName(Context.DestinationFile) #>" company="<#= Context.GetGlobalProperty("CompanyName") #>">  
  11. //     Copyright (c) <#= Context.GetGlobalProperty("CompanyName") #>. All rights reserved.  
  12. // </copyright>  
  13. // <summary></summary>  
  14. // ***********************************************************************  


类注释:

[csharp]  view plain copy
  1. <#@ template language="C#" #>  
  2. <#  CodeElement codeElement = Context.CurrentCodeElement; #>  
  3. /// <summary>  
  4. ///<# GenerateSummaryText(); #>  
  5. /// </summary>  
  6. <#  if(codeElement.HasTypeParameters)   
  7.     {  
  8.         for(int i = 0; i < codeElement.TypeParameters.Length; i++)   
  9.         {   
  10.             TypeParameter typeParameter = codeElement.TypeParameters[i];   
  11. #>  
  12. /// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>  
  13. <#       }     
  14.     }   
  15. #>  
  16. <#= Context.GetNonGeneratedTags() #>  
  17. <# GenerateRemarksText(); #>  
  18.   
  19. <#+  
  20.     private void GenerateSummaryText()  
  21.     {  
  22.         if(Context.HasExistingTagText("summary"))  
  23.         {  
  24.             this.WriteLine(Context.GetExistingTagText("summary"));  
  25.         }  
  26.         else  
  27.         {  
  28.             this.WriteLine("Class " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));  
  29.         }  
  30.     }  
  31.       
  32.     private void GenerateTypeParamText(TypeParameter typeParameter, int index)  
  33.     {  
  34.         if(Context.HasExistingTagText("typeparam", index))   
  35.         {   
  36.             this.Write(Context.GetExistingTagText("typeparam", index));  
  37.         }   
  38.         else   
  39.         {  
  40.             string typeParameterName = typeParameter.Name;  
  41.             if(typeParameterName != null)  
  42.             {  
  43.                 if(typeParameterName.Length == 1)  
  44.                 {  
  45.                     this.Write("");  
  46.                 }  
  47.                 else  
  48.                 {  
  49.                     this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");  
  50.                 }              
  51.             }            
  52.         }   
  53.     }  
  54.       
  55.     private void GenerateRemarksText()  
  56.     {  
  57.         if(Context.HasExistingTagText("remarks"))  
  58.         { #>  
  59. /// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>  
  60. <#+      }  
  61.         else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))  
  62.         {   
  63.             // Should you require a default comment, set it in  
  64.             // Options -> Global Properties -> DefaultBlankRemarksText          
  65. #>  
  66. /// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>  
  67. <#+      }  
  68.     }     
  69. #>  


接口注释

[csharp]  view plain copy
  1. <#@ template language="C#" #>  
  2. <#  CodeElement codeElement = Context.CurrentCodeElement; #>  
  3. /// <summary>  
  4. ///<# GenerateSummaryText(); #>  
  5. /// </summary>  
  6. <#   if(codeElement.HasTypeParameters)   
  7.     {  
  8.         for(int i = 0; i < codeElement.TypeParameters.Length; i++)   
  9.         {   
  10.             TypeParameter typeParameter = codeElement.TypeParameters[i];   
  11. #>  
  12. /// <typeparam name="<#= typeParameter.Name #>"><# GenerateTypeParamText(typeParameter, i); #></typeparam>  
  13. <#       }     
  14.     }   
  15. #>  
  16. <#= Context.GetNonGeneratedTags() #>  
  17. <# GenerateRemarksText(); #>  
  18.   
  19. <#+  
  20.     private void GenerateSummaryText()  
  21.     {  
  22.         if(Context.HasExistingTagText("summary"))  
  23.         {  
  24.             this.WriteLine(Context.GetExistingTagText("summary"));  
  25.         }  
  26.         else  
  27.         {  
  28.             this.WriteLine("Interface " + Context.CurrentCodeElement.Name + Context.ExecMacro("$(End)"));  
  29.         }  
  30.     }  
  31.   
  32.     private void GenerateTypeParamText(TypeParameter typeParameter, int index)  
  33.     {  
  34.         if(Context.HasExistingTagText("typeparam", index))   
  35.         {   
  36.             this.Write(Context.GetExistingTagText("typeparam", index));  
  37.         }   
  38.         else   
  39.         {  
  40.             string typeParameterName = typeParameter.Name;  
  41.             if(typeParameterName != null)  
  42.             {  
  43.                 if(typeParameterName.Length == 1)  
  44.                 {  
  45.                     this.Write("");  
  46.                 }  
  47.                 else  
  48.                 {  
  49.                     this.Write("The type of " + Context.ExecMacro(typeParameterName, "$(TheAndAll)") + ".");  
  50.                 }              
  51.             }            
  52.         }   
  53.     }  
  54.           
  55.     private void GenerateRemarksText()  
  56.     {  
  57.         if(Context.HasExistingTagText("remarks"))  
  58.         { #>  
  59. /// <remarks><#= Context.GetExistingTagText("remarks") #></remarks>  
  60. <#+      }  
  61.         else if (!string.IsNullOrEmpty(Context.GetGlobalProperty("DefaultBlankRemarksText")))  
  62.         {   
  63.             // Should you require a default comment, set it in  
  64.             // Options -> Global Properties -> DefaultBlankRemarksText          
  65. #>  
  66. /// <remarks><#= Context.GetGlobalProperty("DefaultBlankRemarksText") #></remarks>  
  67. <#+      }  
  68.     }     
  69. #>  


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值