public static void DocumentMethods(MarkdownDocument document, Type type, XElement documentation) { var methods = type.IsInterface ? type.GetMethods() : type.GetMethods(BindingFlags.Public); methods = methods.Where(x => !x.Name.StartsWith("get_") && !x.Name.StartsWith("set_")).ToArray(); if (methods.Length < 1) { return; } document.Heading(2, "Methods"); foreach (var method in methods) { var selector = GetSelectorName(type, method); StringBuilder pars = new StringBuilder(); var parameters = method.GetParameters(); int i = 0; foreach (var parameter in parameters) { string callmode = ""; if (parameter.IsOut) { callmode = "out "; } else if (parameter.ParameterType.IsByRef) { callmode = "ref "; } if (parameter.HasDefaultValue) { pars.AppendFormat("{0} {1} {2} = {3}", callmode, Helpers.GetTypeName(parameter.ParameterType), parameter.Name, parameter.DefaultValue); } else { pars.AppendFormat("{0} {1} {2}", callmode, parameter.ParameterType, parameter.Name); } if (i < parameters.Length - 1) { pars.Append(", "); } ++i; } document.WriteLine("* `{0} {1}({2});`", method.ReturnType.Name, method.Name, pars); document.WriteLine(" {0}", DocumentSelectors.GetMethodSummary(documentation, selector)); foreach ((string name, string description)paramDesc in DocumentSelectors.GetMethodParamDescriptions(documentation, selector)) { document.WriteLine(" * `{0}`: {1}", paramDesc.name, paramDesc.description); } } }
internal static void DocumentEnum(MarkdownDocument document, Type type, XElement documentation) { document.Heading(2, "Items"); foreach (var item in type.GetEnumNames()) { var selector = $"{type.FullName}.{item}"; document.WriteLine("* `{0}`", item); document.WriteLine(" {0}", DocumentSelectors.GetPropertyOrTypeSummary(documentation, selector)); document.WriteLine(""); } }
internal static void DocumentPropertes(MarkdownDocument document, Type type, XElement documentation) { var properties = type.IsInterface ? type.GetProperties() : type.GetProperties(BindingFlags.Public); if (properties.Length < 1) { return; } document.Heading(2, "Properties"); foreach (var property in properties) { var selector = $"{type.FullName}.{property.Name}"; document.WriteLine("* `{0} {1} {2}`", Helpers.GetTypeName(property.PropertyType), property.Name, GetSet(property)); document.WriteLine(" {0}", DocumentSelectors.GetPropertyOrTypeSummary(documentation, selector)); document.WriteLine(""); } }