static void OutputDocument() { // Razor templates string typeTemplate = @".\RazorTemplates\TypeTemplate.txt"; string namespaceTemplate = @".\RazorTemplates\NamespaceTemplate.txt"; // Loading assemblies string[] dlls = new[] { @".\LoadAssemblies\mxProject.Tools.ClassDoc.dll", @".\LoadAssemblies\mxProject.Tools.ClassDoc.Razor.NetCore.dll", @".\LoadAssemblies\SampleLibrary1.dll", @".\LoadAssemblies\SampleLibrary2.dll" }; // Setup a context and a formatter. ClassDocContext context = new ClassDocContext() { // note: These values are the same as those set in the initial value of ClassDocContext. ConstructorFilter = ConstructorInfoExtensions.IsRecommendOutputToDocument, TypeFilter = TypeExtenstions.IsRecommendOutputToDocument, PropertyFilter = PropertyInfoExtensions.IsRecommendOutputToDocument, FieldFilter = FieldInfoExtensions.IsRecommendOutputToDocument, MethodFilter = MethodInfoExtensions.IsRecommendOutputToDocument, EventFilter = EventInfoExtensions.IsRecommendOutputToDocument, }; MarkdownFormatter formatter = new MarkdownFormatter(context) { // note: These values are the same as those set in the initial value of MarkdownFormatter. ConstructorAnchorDefaultFormat = "{0} Constructor", PropertyAnchorDefaultFormat = "{0} Property", FieldAnchorDefaultFormat = "{0} Field", MethodAnchorDefaultFormat = "{0} Method", EventAnchorDefaultFormat = "{0} Event", ParameterNameDefaultFormat = "`{0}`", }; // Setup a writer. string namespaceDocumentTemplate = File.ReadAllText(namespaceTemplate, Encoding.UTF8); string typeDocumentTemplate = File.ReadAllText(typeTemplate, Encoding.UTF8); RazorDocumentWriterSettings settings = RazorDocumentWriterSettings.CreateDefaultSettings( Encoding.UTF8, @".\Documents\", formatter, namespaceDocumentTemplate, typeDocumentTemplate ); settings.NamespaceDodumentSettings.FileNameFormatter = x => "@namespace.md"; using RazorDocumentWriter writer = new RazorDocumentWriter(settings); // Load type information. IReadOnlyList <TypeWithComment> types = TypeLoader.LoadTypes(dlls, context, null); // Group by namespace. foreach (var group in types.GroupBy(type => type.Namespace).OrderBy(group => group.Key)) { NamespaceInfo nameSpace = new NamespaceInfo(group.First()?.Namespace, group); // Output the document for the namespace. writer.WriteNamespaceDocument(nameSpace); // Output the document for the type. foreach (var type in group.OrderBy(type => type.Name)) { writer.WriteTypeDocument(type); } } }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="context">The context that manages the state of the output process for class documents.</param> public MarkdownFormatter(ClassDocContext context) { Context = context; }