private IEnumerable <ITag> DocumentNutrient() { // Basic model description. yield return(new Paragraph(CodeDocumentation.GetSummary(GetType()))); // Document model structure. List <ITag> structureTags = new List <ITag>(); structureTags.Add(new DirectedGraphTag(DirectedGraphInfo)); structureTags.Add(new Paragraph(CodeDocumentation.GetCustomTag(GetType(), "structure"))); yield return(new Section("Soil Nutrient Model Structure", structureTags)); // Document nutrient pools. List <ITag> poolTags = new List <ITag>(); poolTags.Add(new Paragraph(CodeDocumentation.GetCustomTag(GetType(), "pools"))); poolTags.AddRange(DocumentChildren <NutrientPool>(true)); yield return(new Section("Pools", poolTags)); // Document solutes. List <ITag> soluteTags = new List <ITag>(); soluteTags.Add(new Paragraph(CodeDocumentation.GetCustomTag(GetType(), "solutes"))); soluteTags.AddRange(DocumentChildren <Solute>(true)); yield return(new Section("Solutes", soluteTags)); }
/// <summary>Document the specified model.</summary> /// <param name="typeToDocument">The type to document.</param> private IEnumerable <ITag> DocumentType(Type typeToDocument) { List <ITag> tags = new List <ITag>(); tags.Add(new Paragraph(CodeDocumentation.GetSummary(typeToDocument))); tags.Add(new Paragraph(CodeDocumentation.GetRemarks(typeToDocument))); IEnumerable <IVariable> outputs = GetOutputs(typeToDocument); if (outputs != null && outputs.Any()) { DataTable outputTable = PropertiesToTable(outputs); tags.AddRange(DocumentTable("**Properties (Outputs)**", outputTable)); } tags.AddRange(DocumentLinksEventsMethods(typeToDocument)); yield return(new Section(typeToDocument.GetFriendlyName(), tags)); }
/// <summary>Return a datatable of methods for the specified type.</summary> /// <param name="type">The type to document.</param> private DataTable GetMethods(Type type) { DataTable methods = new DataTable("Methods"); methods.Columns.Add("Name", typeof(string)); methods.Columns.Add("Description", typeof(string)); foreach (MethodInfo method in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly)) { if (!method.IsSpecialName) { DataRow row = methods.NewRow(); string parameters = null; foreach (ParameterInfo argument in method.GetParameters()) { if (parameters != null) { parameters += ", "; } parameters += GetTypeName(argument.ParameterType) + " " + argument.Name; } string description = CodeDocumentation.GetSummary(method); string remarks = CodeDocumentation.GetRemarks(method); if (!string.IsNullOrEmpty(remarks)) { description += Environment.NewLine + Environment.NewLine + remarks; } string methodName = method.Name; // Italicise the method description. if (!string.IsNullOrEmpty(description)) { description = $"*{description}*"; } StringBuilder st = new StringBuilder(); string returnType = GetTypeName(method.ReturnType); st.Append(returnType); st.Append(" "); st.Append(method.Name); st.Append("("); st.Append(parameters); st.AppendLine(")"); st.AppendLine(); st.Append(description); row["Name"] = method.Name; row["Description"] = st.ToString();//.Replace("\r\n", " "); methods.Rows.Add(row); } } if (methods.Rows.Count > 0) { return(methods); } else { return(null); } }
/// <summary> /// Get a description of the model from the summary and remarks /// xml documentation comments in the source code. /// </summary> /// <remarks> /// Note that the returned tags are not inside a section. /// </remarks> protected IEnumerable <ITag> GetModelDescription() { yield return(new Paragraph(CodeDocumentation.GetSummary(GetType()))); yield return(new Paragraph(CodeDocumentation.GetRemarks(GetType()))); }