public bool CopyProjectAssets(DocProject project)
        {
            try
            {
                string folder = project.ProjectDirectory;
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                string wwwFolder = Path.Combine(folder, "_kavadocs");
                if (!Directory.Exists(wwwFolder))
                {
                    Directory.CreateDirectory(wwwFolder);
                }

                KavaUtils.CopyDirectory(Path.Combine(InstallFolder, "ProjectTemplates"), wwwFolder);
            }
            catch (Exception ex)
            {
                SetError("Failed to copy project assets: " + ex.GetBaseException().Message);
                return(false);
            }

            return(true);
        }
예제 #2
0
 public DocProjectSettings(DocProject project)
 {
     _project = project;
     if (TopicTypes == null)
     {
         TopicTypes = new Dictionary <string, string>
         {
             { "index", "Top level topic for the documentation." },
             { "header", "Header topic for sub-topics" },
             { "topic", "Generic topic" },
             { "whatsnew", "What's new" },
             { "weblink", "External link" },
             { "classheader", "Class Header" },
             { "interface", "Interface" },
             { "namespace", "Namespace" },
             { "classmethod", "Class method" },
             { "classproperty", "Class property" },
             { "classfield", "Class field" },
             { "classevent", "Class event" },
             { "classconstructor", "Class constructor" },
             { "enum", "Enumeration" },
             { "delegate", "Delegate" },
             { "webservice", "Web Service" },
             { "database", "Database" },
             { "datacolumn", "Data columns" },
             { "datafunction", "Data function" },
             { "datastoredproc", "Data stored procedure" },
             { "datatable", "Data table" },
             { "dataview", "Data view" },
             { "vstsworkitem", "VSTS work item" },
             { "vstsworkitemquery", "VSTS work item query" }
         };
     }
 }
        /// <summary>
        /// Creates a new project structure in the ProjectFolder
        /// specified.
        /// </summary>
        /// <returns></returns>
        public DocProject CreateProject()
        {
            if (string.IsNullOrEmpty(ProjectFolder))
            {
                SetError("Please provide a Project Folder.");
                return(null);
            }

            if (string.IsNullOrEmpty(Title))
            {
                SetError("Please provide a Title for the new project.");
                return(null);
            }

            if (!IsTargetFolderMissingOrEmpty(ProjectFolder))
            {
                SetError("Couldn't create new project: Project exists already - please use another folder.");
                return(null);
            }

            string filename = "_toc.json";

            if (string.IsNullOrEmpty(filename))
            {
                filename = Path.Combine(ProjectFolder, "_toc.json");
            }
            else
            {
                filename = Path.Combine(ProjectFolder, filename);
            }

            var project = new DocProject()
            {
                Title    = Title,
                Filename = filename,
                Owner    = Owner
            };

            if (!CopyProjectAssets(project))
            {
                return(null);
            }


            string body  = @"## Welcome to your new Documentation Project

Here are a few tips to get started:

* Press **ctrl-n** to create a new Topic
* Enter text into the main text area using [Markdown formatting](https://documentationmonster.west-wind.com)
* Use the Topic Editor on the right to enter topic data
* Use drag and drop in the Topic tree to move topics around
* Use the Image toolbar icon to select images from disk
* Paste images from from the clipboard into your text

Time to get going!
";
            var    topic = new DocTopic(project)
            {
                Title       = Title,
                Body        = body,
                DisplayType = "index"
            };

            project.Topics.Add(topic);
            project.SaveProject();

            return(project);
        }