Exemple #1
0
        // =========================================================================
        // Comment code generation
        // -------------------------------------------------------------------------
        /// Generates a function comment block good for Doxygen.
        ///
        /// @param indent The white spaces to put at the beginning of each line.
        /// @return The formatted comment block.
        ///
        string GenerateFunctionComment(string indent)
        {
            var result = new StringBuilder(indent);

            result.Append(CodeBannerBottom);
            var splitDescription = SplitDescription(VSObject.Description);

            foreach (var d in splitDescription)
            {
                result.Append(indent);
                result.Append("/// ");
                result.Append(d);
                result.Append("\n");
            }
            var returnPort = GetReturnPort(VSObject);
            var showPorts  = myParameters.Length != 0 || returnPort != null;

            if (showPorts)
            {
                result.Append(indent);
                result.Append("///\n");
            }
            if (myParameters.Length != 0)
            {
                foreach (var p in myParameters)
                {
                    result.Append(indent);
                    result.Append("/// @param ");
                    var paramName = NameUtility.ToFunctionParameterName(p.VSObject.CodeName);
                    result.Append(paramName);
                    var description = p.VSObject.Description;
                    if (string.IsNullOrEmpty(description))
                    {
                        result.Append("\n");
                        continue;
                    }
                    result.Append(' ');
                    var splitParamDescription = SplitDescription(description);
                    if (splitParamDescription != null && splitParamDescription.Length > 0)
                    {
                        result.Append(splitParamDescription[0]);
                        result.Append("\n");
                        for (int i = 1; i < splitParamDescription.Length; ++i)
                        {
                            result.Append(indent);
                            result.Append("///        ");
                            result.Append(new String(' ', paramName.Length + 1));
                            result.Append(splitParamDescription[i]);
                            result.Append("\n");
                        }
                    }
                }
            }
            if (returnPort != null)
            {
                result.Append(indent);
                result.Append("/// @return ");
                result.Append(returnPort.Description);
                result.Append("\n");
            }
            if (showPorts)
            {
                result.Append(indent);
                result.Append("///\n");
            }
            return(result.ToString());
        }