Exemple #1
0
        private void GenerateNodeDoc()
        {
            const string docPath = UIHelper.NodeDocumentationPath;

            if (Directory.Exists(docPath))
            {
                foreach (var enumerateFile in Directory.EnumerateFiles(docPath, "*.md", SearchOption.AllDirectories))
                {
                    File.Delete(enumerateFile);
                }
            }
            Directory.CreateDirectory(docPath);

            var gam = GraphAssetModel.Create("Doc", null, typeof(VSGraphAssetModel), false);
            var stateCurrentGraphModel = gam.CreateGraph <VSGraphModel>("Doc", typeof(DotsStencil), false);
            var stencil    = stateCurrentGraphModel.Stencil;
            var dbProvider = stencil.GetSearcherDatabaseProvider();
            var dbs        = dbProvider.GetGraphElementsSearcherDatabases();

            HashSet <string> fileNames = new HashSet <string>();

            foreach (var searcherItem in dbs[0].ItemList.OfType <GraphNodeModelSearcherItem>())
            {
                var graphElementModels = GraphNodeSearcherAdapter.CreateGraphElementModels(stateCurrentGraphModel, searcherItem);
                if (graphElementModels.Count() != 1)
                {
                    continue;
                }

                var model = graphElementModels.Single();

                if (model is INodeModel nodeModel)
                {
                    string fileName;
                    if (string.IsNullOrWhiteSpace(searcherItem.Path))
                    {
                        fileName = nodeModel.GetType().Name;
                    }
                    else
                    {
                        fileName = MakePath(searcherItem, Path.DirectorySeparatorChar);
                    }
                    // fileName = fileName.Replace('/', Path.DirectorySeparatorChar);
                    Assert.IsTrue(fileNames.Add(fileName), "Duplicate filename: " + fileName);

                    var formatter = new MarkdownNodeDocumentationFormatter();
                    formatter.DocumentNode(searcherItem, nodeModel);

                    var filePath = Path.Combine(docPath, $"{fileName}.md");
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                    var contents = formatter.ToString();
                    if (!File.Exists(filePath) || File.ReadAllText(filePath) != contents)
                    {
                        File.WriteAllText(filePath, contents);
                    }
                }
            }

            GenerateToc();
        }
        private void GenerateNodeDoc()
        {
            const string docPath = UIHelper.NodeDocumentationPath;

            if (Directory.Exists(docPath))
            {
                Directory.Delete(docPath, true);
            }
            Directory.CreateDirectory(docPath);

            var gam = GraphAssetModel.Create("Doc", null, typeof(VSGraphAssetModel), false);
            var stateCurrentGraphModel = gam.CreateGraph <VSGraphModel>("Doc", typeof(DotsStencil), false);
            var stencil    = stateCurrentGraphModel.Stencil;
            var dbProvider = stencil.GetSearcherDatabaseProvider();
            var dbs        = dbProvider.GetGraphElementsSearcherDatabases();

            HashSet <string> fileNames = new HashSet <string>();

            foreach (var searcherItem in dbs[0].ItemList.OfType <GraphNodeModelSearcherItem>())
            {
                var graphElementModels = GraphNodeSearcherAdapter.CreateGraphElementModels(stateCurrentGraphModel, searcherItem);
                if (graphElementModels.Count() != 1)
                {
                    continue;
                }

                var model = graphElementModels.Single();
                if (model is IDotsNodeModel dotsNodeModel)
                {
                    var formatter = new MarkdownNodeDocumentationFormatter();

                    formatter.DocumentNode(searcherItem, dotsNodeModel);
                    var fileName = string.IsNullOrWhiteSpace(dotsNodeModel.Title) ? dotsNodeModel.GetType().Name : dotsNodeModel.Title;
                    Assert.IsTrue(fileNames.Add(fileName), "Duplicate filename: " + fileName);
                    var filePath = Path.Combine(docPath, $"{fileName}.md");
                    var contents = formatter.ToString();
                    if (!File.Exists(filePath) || File.ReadAllText(filePath) != contents)
                    {
                        File.WriteAllText(filePath, contents);
                    }
                }
            }
        }