private static void WriteDescription(Type type, bool synopsis, bool addCopyright)
        {
            _writer.WriteStartElement("maml", "description", null);
            CmdletDescriptionAttribute da = GetAttribute <CmdletDescriptionAttribute>(type);
            string desc = string.Empty;

            if (synopsis)
            {
                if (da != null && !string.IsNullOrEmpty(da.Synopsis))
                {
                    desc = da.Synopsis;
                }
            }
            else
            {
                if (da != null && !string.IsNullOrEmpty(da.Description))
                {
                    desc = da.Description;
                }
            }

            WritePara(desc);
            if (addCopyright)
            {
                WritePara(null);
                WritePara(_copyright);
            }

            _writer.WriteEndElement(); //maml:description
        }
Example #2
0
        /// <summary>
        ///     Extract the synopsis for a Cmdlet.
        /// </summary>
        /// <param name="cmdletType">
        ///     The CLR type that implements the Cmdlet.
        /// </param>
        /// <returns>
        ///     The description, or <c>null</c> if no description could be extracted by this extractor.
        ///
        ///     An empty string means a description was extracted, but the description is empty (this is legal).
        /// </returns>
        public string GetCmdletDescription(TypeInfo cmdletType)
        {
            if (cmdletType == null)
            {
                throw new ArgumentNullException(nameof(cmdletType));
            }

            CmdletDescriptionAttribute descriptionAttribute = cmdletType.GetCustomAttribute <CmdletDescriptionAttribute>();

            if (descriptionAttribute == null)
            {
                return(null);
            }

            return(descriptionAttribute.Description?.Trim());
        }