为Unity项目生成文档(一)

VS生成chm帮助文档

VS代码中使用Xml注释,并通过Sandcastle生成chm文档的文章,这几篇值得分享:

VS的XML注释语法:

微软的建议

建议的文档注释标记(C# 编程指南)

标记

image

注释示例

请重点看下面方法的xml注释:

/// <summary>
        ///     根据用户Id得到用户名.
        ///     <para>
        ///         此处添加第二段Summary信息,在MSDN中很少使用.所以不推荐使用.
        ///     </para>  
        /// </summary>
        /// <remarks>
        ///     如果没有找到用户则返回null.<br/>
        ///     <paramref name="userId"/> 参数为正整数.<br/>
        ///     用户Id模型属性定义参见<see cref="UserInfo.UserId"/><br/>
        ///     相关方法:<seealso cref="UserBL.GetUserId"/>
        /// </remarks>
        /// <param name="userId">用户Id</param>
        /// <returns>用户真实姓名</returns>
        /// <example>
        ///     返回用户id为100的用户真实姓名:
        ///     <code>
        ///         private string userName = string.Empty;
        ///         userName = UserBL.GetUserName(100);
        ///     </code>
        ///     返回的用户名可能为null,使用时要先判断:<br/>
        ///     <c>if(userName!=null){...}</c>
        /// </example>
        /// <exception cref="System.ApplicationException">
        ///     如果用户Id小于0则抛出此异常
        /// </exception>
        public static string GetUserName(long userId)
        {
            string result = string.Empty;
            if (userId < 0)
            {
                throw new System.ApplicationException();
            }
            else if (userId == 0)
            {
                result = null;
            }
            else
            {
                result = "Robert";
            }
            return result;
        }

生成chm文档后的截图

image

文档摘要

image

文档详细信息

image

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值