private void Run() { try { if (OutputPath != null) { if (!Directory.Exists(OutputPath)) { Directory.CreateDirectory(OutputPath); } } using (var assembly = new AssemblyReflector(AssemblyFileName, _logger)) { var publicApiReferenceFileName = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".html"; var publicApiSlashdocFileName = Path.GetFileNameWithoutExtension(AssemblyFileName) + ".xml"; if (OutputPath != null) { publicApiReferenceFileName = Path.Combine(OutputPath, publicApiReferenceFileName); publicApiSlashdocFileName = Path.Combine(OutputPath, publicApiSlashdocFileName); } var slashdocFileName = Path.ChangeExtension(AssemblyFileName, ".xml"); var slashdoc = new SlashdocDictionary(); if (File.Exists(slashdocFileName)) { using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read)) { SlashdocProcessor.WritePublicApiSlashdoc(assembly, slashdocStream, publicApiSlashdocFileName); } using (var slashdocStream = new FileStream(slashdocFileName, FileMode.Open, FileAccess.Read)) { slashdoc = SlashdocReader.Parse(slashdocStream); } } else { _logger.LogWarning(string.Format(CultureInfo.InvariantCulture, "Could not open slashdoc file '{0}'.", slashdocFileName)); } var language = new CSharpSignatureProvider(); var title = string.Format(CultureInfo.InvariantCulture, "{0} public API reference", assembly.SimpleName); using (var apiReferenceWriter = new ApiReferenceHtmlWriter(publicApiReferenceFileName, title, slashdoc, language, _logger)) { apiReferenceWriter.EnableMissingSummaryWarnings = EnableMissingSummaryWarnings; apiReferenceWriter.DescribeAssembly(assembly); } } } catch (Exception ex) { _logger.LogError(ex.Message); } }
public static SlashdocDictionary Parse(Stream stream) { var slashdoc = new SlashdocDictionary(); var instance = new SlashdocReader(stream); instance.FoundAssemblyName += (x) => slashdoc.AssemblyName = x; instance.FoundMember += (x) => slashdoc.SetXmlDescription(x.Key, x.Value); instance.Parse(); return slashdoc; }
public static SlashdocDictionary Parse(Stream stream) { var slashdoc = new SlashdocDictionary(); var instance = new SlashdocReader(stream); instance.FoundAssemblyName += (x) => slashdoc.AssemblyName = x; instance.FoundMember += (x) => slashdoc.SetXmlDescription(x.Key, x.Value); instance.Parse(); return(slashdoc); }
/// <summary> /// Write a filtered slashdoc file with the public API only, for use with IntelliSense. /// </summary> public static void WritePublicApiSlashdoc(IAssemblyReflector assemblyReflector, Stream slashdocStream, string fileName) { var publicSlashdocIds = GetSlashdocIdsForAllVisibleTypesAndMembers(assemblyReflector); using (var reader = new SlashdocReader(slashdocStream)) using (var writer = XmlWriter.Create(fileName)) { writer.WriteStartElement("doc"); reader.FoundAssemblyName += (x) => { writer.WriteStartElement("assembly"); writer.WriteStartElement("name"); writer.WriteString(x); writer.WriteEndElement(); // name writer.WriteEndElement(); // assembly }; int memberCount = 0; reader.FoundMember += (x) => { if (publicSlashdocIds.Contains(x.Key)) { if (memberCount == 0) { writer.WriteStartElement("members"); } memberCount++; writer.WriteStartElement("member"); writer.WriteAttributeString("name", x.Key); writer.WriteRaw(x.Value); writer.WriteEndElement(); // member } }; reader.Parse(); } }