private void Approve(CommandDocumentation model, CommandLineHelpConfiguration?configuration = null) { var pathProvider = new DefaultCommandLineHelpPathProvider(); var documentSet = new DocumentSet <IDocument>(); configuration ??= new ConfigurationProvider().GetDefaultCommandLineHelpConfiguration(); var commandPage = new CommandPage(documentSet, pathProvider, model, configuration); // add dummy application page and command page itself to document set // because command page will create a link to the application page // which would fail otherwise documentSet.Add(pathProvider.GetPath(model.Application), new TextDocument()); documentSet.Add(pathProvider.GetPath(model), commandPage); var doc = commandPage.GetDocument(); Assert.NotNull(doc); var markdown = doc.ToString(); var writer = new ApprovalTextWriter(markdown); Approvals.Verify(writer, new ApprovalNamer(relativeOutputDirectory: "../../../_referenceResults"), Approvals.GetReporter()); }
private void btnSave_Click(object sender, EventArgs e) { DocumentSet ds = new DocumentSet(); if (string.IsNullOrEmpty(txtDocumentSetUID.Text)) { ds.IsVoid = 'N'; ds.Name = txtDocumentSetName.Text; ds.TemplateType = txtDocumentSetName.Text; ds.TemplateFolder = ""; ds.UID = 0; ds.Add(); } else { ds.IsVoid = 'N'; ds.TemplateType = txtDocumentSetName.Text; ds.UID = documentSet.UID; ds.Update(); } // Reload document set list // cbxDocumentSet.Items.Clear(); dsl.ListInComboBox(cbxDocumentSet); cbxDocumentSet.SelectedIndex = 0; SelectIndexChanged(); }
private void RegisterApplicationPage(ApplicationDocumentation model) { if (model is MultiCommandApplicationDocumentation multiCommandApplication) { m_DocumentSet.Add( m_PathProvider.GetPath(multiCommandApplication), new MultiCommandApplicationPage(m_DocumentSet, m_PathProvider, multiCommandApplication, m_Configuration)); } else if (model is SingleCommandApplicationDocumentation singleCommandApplication) { m_DocumentSet.Add( m_PathProvider.GetPath(singleCommandApplication), new SingleCommandApplicationPage(m_DocumentSet, m_PathProvider, singleCommandApplication, m_Configuration)); } else { throw new NotImplementedException($"Unexpected model type '{model.GetType().FullName}'"); } }
public void AddTest() { var docSet1 = new DocumentSet(new HashSet <Document> { new Document("doc") }); docSet1.Add(new Document("doc2")); Assert.True(docSet1.Has(new Document("doc2"))); }
public void Indexer_returns_expected_document() { var path = "some/path/doc.md"; var set = new DocumentSet <TestDocument>(); var document = new TestDocument(); set.Add(path, document); Assert.Same(document, set[path]); }
private void Approve(MultiCommandApplicationDocumentation model, CommandLineHelpConfiguration?configuration = null) { var pathProvider = new DefaultCommandLineHelpPathProvider(); var documentSet = new DocumentSet <IDocument>(); // add dummy pages for all commands foreach (var command in model.Commands) { documentSet.Add(pathProvider.GetPath(command), new TextDocument()); } configuration ??= new ConfigurationProvider().GetDefaultCommandLineHelpConfiguration(); var applicationPage = new MultiCommandApplicationPage(documentSet, pathProvider, model, configuration); documentSet.Add(pathProvider.GetPath(model), applicationPage); var doc = applicationPage.GetDocument(); Assert.NotNull(doc); var writer = new ApprovalTextWriter(doc.ToString()); Approvals.Verify(writer, new ApprovalNamer(relativeOutputDirectory: "../../../_referenceResults"), Approvals.GetReporter()); }
private void LoadPages() { var linkProvider = new CompositeLinkProvider(new InternalLinkProvider(m_Model, this, m_DocumentSet)); m_Logger.LogInformation("Loading pages"); foreach (var @namespace in m_Model.Namespaces) { var page = new NamespacePage(linkProvider, m_Configuration, @namespace, m_Logger); m_PagesByModel.Add(@namespace, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } foreach (var assembly in m_Model.Assemblies) { foreach (var type in assembly.Types) { var typePage = new TypePage(linkProvider, m_Configuration, type, m_Logger); m_PagesByModel.Add(type, typePage); m_DocumentSet.Add(m_PathProvider.GetPath(typePage), typePage); foreach (var property in type.Properties) { var page = new PropertyPage(linkProvider, m_Configuration, property, m_Logger); m_PagesByModel.Add(property, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } foreach (var indexer in type.Indexers) { var page = new IndexerPage(linkProvider, m_Configuration, indexer, m_Logger); m_PagesByModel.Add(indexer, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } if (type.Constructors != null) { var page = new ConstructorsPage(linkProvider, m_Configuration, type.Constructors, m_Logger); m_PagesByModel.Add(type.Constructors, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } foreach (var method in type.Methods) { var page = new MethodPage(linkProvider, m_Configuration, method, m_Logger); m_PagesByModel.Add(method, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } if (type.Kind != TypeKind.Enum) { foreach (var field in type.Fields) { var page = new FieldPage(linkProvider, m_Configuration, field, m_Logger); m_PagesByModel.Add(field, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } } foreach (var ev in type.Events) { var page = new EventPage(linkProvider, m_Configuration, ev, m_Logger); m_PagesByModel.Add(ev, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } foreach (var op in type.Operators) { var page = new OperatorPage(linkProvider, m_Configuration, op, m_Logger); m_PagesByModel.Add(op, page); m_DocumentSet.Add(m_PathProvider.GetPath(page), page); } } } }