private void InitializeDocSignaturesIfNone(MemDocModel memDocModel) { // If member can only have one signature and it doesn't have it, add it based on asm signature if (memDocModel.SignatureCount == 0 && memDocModel.SubSections.Count <= 1) { List <SignatureEntry> sigEntries = Signatures.Where(e => e.InAsm).OrderBy(e => e.Asm.ReturnType).ToList(); if (sigEntries.Any()) { string prevReturnType = sigEntries[0].Asm.ReturnType ?? ""; int section = 0; foreach (SignatureEntry sigEntry in sigEntries) { string returnType = sigEntry.Asm.ReturnType ?? ""; if (returnType != prevReturnType) { prevReturnType = returnType; section++; } if (memDocModel.SubSections.Count <= section) { memDocModel.SubSections.Add(new MemberSubSection()); } memDocModel.SubSections[section].SignatureList.Add(sigEntry.Name); memDocModel.SubSections[section].SignatureEntryList.Add(sigEntry); } } } }
public void SaveDoc(bool translated = false) { MemDocModel doc = translated ? DocModelTranslated : DocModel; var writer = new StreamWriter(GetFileName(doc.Language)); writer.Write(doc.ToString()); writer.Close(); }
public void DeleteDoc(bool translated = false) { MemDocModel doc = translated ? DocModelTranslated : DocModel; string fileName = GetFileName(doc.Language); if (File.Exists(fileName)) { File.Delete(fileName); } }
private void WriteSummaryAndTextBlocksFor(TextWriter tw, MemDocModel memdoc) { tw.Write(@" <p>{0}</p> ", ReplaceSpecialSyntaxWithProperTags(InjectLinksToApiReferences(memdoc.Summary))); foreach (var block in memdoc.TextBlocks) { var descriptionBlock = block as DescriptionBlock; if (descriptionBlock != null) { tw.Write("<p>{0}</P>", ReplaceSpecialSyntaxWithProperTags(InjectLinksToApiReferences(descriptionBlock.Text))); } var exampleblock = block as ExampleBlock; if (exampleblock != null) { tw.Write(ExampleHtmlGenerator.ExamleHtmlFor(exampleblock.Text)); } } }
public MemDocModel LoadDoc(string memFileContent, ELanguage language = ELanguage.English, bool updateMemberSignaturesAndFlags = true, bool assignDocToMemberItem = true) { bool translated = language != ELanguage.English; // Create new MemDocModel MemDocModel memDocModel = new MemDocModel(memFileContent) { Language = language, AssemblyKind = ItemType }; InitializeDocSignaturesIfNone(memDocModel); if (assignDocToMemberItem) { if (translated) { DocModelTranslated = memDocModel; } else { DocModel = memDocModel; } } if (updateMemberSignaturesAndFlags) { // Remove old (possibly outdated) doc info from member signature list for (int i = m_SignatureList.Count - 1; i >= 0; i--) { if (translated) { m_SignatureList[i].InDocTranslated = false; } else { m_SignatureList[i].InDoc = false; } if (!m_SignatureList[i].InAsm && !m_SignatureList[i].InDoc && !m_SignatureList[i].InDocTranslated) { m_SignatureList.RemoveAt(i); } } // Populate member signature list with signatures from (updated) doc foreach (string signature in memDocModel.SignatureListFromAllBlocks) { if (!m_SignatureList.Any(e => (e.Name == signature))) { m_SignatureList.Add(new SignatureEntry(signature)); } SignatureEntry signatureEntry = m_SignatureList.First(e => e.Name == signature); var subSection = memDocModel.SubSectionOfSignature(signature); if (subSection != null) { subSection.SignatureEntryList.Add(signatureEntry); } if (translated) { signatureEntry.InDocTranslated = true; } else { signatureEntry.InDoc = true; } //if (signatureEntry.InAsm && signatureEntry.Asm.Private) // System.Console.WriteLine ("Private documented signature "+signature+" in member "+ItemName); } UpdateFlags(); } // Add assembly information to MemberDocModel memDocModel.ProcessAsm(this); return(memDocModel); }