Esempio n. 1
0
        public void Export(SDProject sdProject, string outputPath)
        {
            _docCount = sdProject.DocumentationLanguages.Count;
            _docIndex = 0;

            foreach (var targetFx in sdProject.GetAllAvailableTargetFxs())
            {
                if (ApiEmpty(sdProject, targetFx))
                {
                    continue;
                }

                foreach (var docLanguage in sdProject.DocumentationLanguages)
                {
                    StepInput.InitStepinput(sdProject, targetFx, Path.Combine(outputPath, docLanguage), docLanguage, _localController.GetLocalStringsOrDefault <ChmStrings>(docLanguage), _chmStrings, _chmConfig);

                    var steps = new List <StepBase>();
                    steps.Add(new CopyStep(0, 10));
                    steps.Add(new TemplateStep(10, 50));
                    steps.Add(new CompileStep(50, 90));
                    steps.Add(new SaveAndCleanStep(90, 100));

                    foreach (var step in steps)
                    {
                        ExecuteOnStepProgress(step.StepRange.ProgressStart);

                        step.OnStepMessage  += ExecuteOnStepMessage;
                        step.OnStepProgress += ExecuteOnStepProgress;
                        step.RunStep();
                    }

                    _docIndex++;
                }
            }
        }
Esempio n. 2
0
        internal static SDProject ParseProject()
        {
            var testProjectPath =
                Path.Combine(
                    Path.GetDirectoryName(Assembly.GetAssembly(typeof(Regression1)).Location),
                    "..", "..", "..", "SharpDox.TestProject", "SharpDox.TestProject.csproj");

            var coreConfig = Mock.Of <ICoreConfigSection>(
                c => c.InputFile == testProjectPath &&
                c.ProjectName == "TestProject" &&
                c.DocLanguage == "en" &&
                c.ExcludedIdentifiers == new ObservableCollection <string>());

            var configController = Mock.Of <IConfigController>(
                c => c.GetConfigSection <ICoreConfigSection>() == coreConfig);

            var stepInput = new StepInput(configController, new NRefactoryParser(Mock.Of <ParserStrings>()), new SDBuildStrings(), null);

            var config      = new List <StepBase>();
            var checkConfig = new CheckConfigStep(stepInput, 0, 15);

            config.Add(new ParseProjectStep(stepInput, 0, 50));
            config.Add(new ParseCodeStep(stepInput, 50, 100));

            var sdProject = new SDProject();

            foreach (var step in config)
            {
                sdProject = step.RunStep(sdProject);
            }

            return(sdProject);
        }
        private void ParseCompleted(SDProject sdProject)
        {
            Application.Current.Dispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new Action(() => {
                TreeView = new VisibilityItemList(_sharpDoxConfig);

                if (sdProject != null)
                {
                    foreach (var sdSolution in sdProject.Solutions.Values)
                    {
                        foreach (var sdRepository in sdSolution.Repositories)
                        {
                            foreach (var sdNamespace in sdRepository.GetAllNamespaces())
                            {
                                TreeView.Add(new NamespaceViewModel(sdNamespace, _sharpDoxConfig));
                                TreeLoaded = true;
                            }
                        }
                    }
                }

                IsTreeRefreshing = false;
            }));
        }
        public override SDProject RunStep(SDProject sdProject)
        {
            if (string.IsNullOrEmpty(_stepInput.CoreConfigSection.DocLanguage))
            {
                throw new SDBuildException(_stepInput.SDBuildStrings.NoDocLanguage);
            }

            if (_stepInput.CoreConfigSection.OutputPath == null)
            {
                throw new SDBuildException(_stepInput.SDBuildStrings.NoOutputPathGiven);
            }

            if (!Directory.Exists(_stepInput.CoreConfigSection.OutputPath))
            {
                Directory.CreateDirectory(_stepInput.CoreConfigSection.OutputPath);
            }

            foreach (var exporter in _stepInput.AllExporters)
            {
                if (_stepInput.CoreConfigSection.ActivatedExporters.Contains(exporter.ExporterName))
                {
                    exporter.OnRequirementsWarning += (m) => ExecuteOnBuildMessage(m);
                    if (!exporter.CheckRequirements())
                    {
                        throw new SDBuildException(_stepInput.SDBuildStrings.RequirementError);
                    }
                }
            }

            return(_checkConfigStep.RunStep(sdProject));
        }
Esempio n. 5
0
        public void Export(SDProject sdProject, string outputPath)
        {
            _sdProject  = sdProject;
            _outputPath = outputPath;
            _docCount   = sdProject.DocumentationLanguages.Count;
            _docIndex   = 0;

            foreach (var docLanguage in sdProject.DocumentationLanguages)
            {
                var currentOutputPath = Path.Combine(outputPath, docLanguage);
                _currentDocLanguage = docLanguage;

                ExecuteOnStepMessage(_wordStrings.LoadingTemplate);
                ExecuteOnStepProgress(10);
                var docBuilder = new DocBuilder(_sdProject, _localController.GetLocalStringsOrDefault <WordStrings>(_currentDocLanguage), _currentDocLanguage, currentOutputPath);

                ExecuteOnStepProgress(20);
                ExecuteOnStepMessage(_wordStrings.CreatingDocument);
                docBuilder.BuildDocument();

                ExecuteOnStepProgress(80);
                ExecuteOnStepMessage(_wordStrings.SavingDocument);
                docBuilder.SaveToOutputFolder();

                ExecuteOnStepProgress(90);
                ExecuteOnStepMessage(_wordStrings.DeleteTmp);
                Directory.Delete(Path.Combine(_outputPath, _currentDocLanguage, "tmp"), true);

                _docIndex++;
            }
        }
Esempio n. 6
0
 public BaseApiBuilder(WordTemplater wordTemplater, SDProject sdProject, WordStrings wordStrings, string docLanguage)
 {
     _wordTemplater = wordTemplater;
     _sdProject     = sdProject;
     _wordStrings   = wordStrings;
     _docLanguage   = docLanguage;
 }
        public void Export(SDProject sdProject, string outputPath)
        {
            _docCount = sdProject.DocumentationLanguages.Count;
            _docIndex = 0;
            foreach (var docLanguage in sdProject.DocumentationLanguages)
            {
                StepInput.InitStepinput(sdProject, Path.Combine(outputPath, docLanguage), docLanguage, _localController.GetLocalStringsOrDefault <HtmlStrings>(docLanguage), _htmlStrings, _htmlConfig);

                var steps = new List <StepBase>();
                steps.Add(new PreStep(0, 5));
                steps.Add(new CopyThemeStep(5, 25));
                steps.Add(new CreateDataStep(25, 100));

                foreach (var step in steps)
                {
                    ExecuteOnStepProgress(step.StepRange.ProgressStart);

                    step.OnStepMessage  += ExecuteOnStepMessage;
                    step.OnStepProgress += ExecuteOnStepProgress;
                    step.RunStep();

                    ExecuteOnStepProgress(step.StepRange.ProgressEnd);
                }

                _docIndex++;
            }
        }
Esempio n. 8
0
 internal void ExecuteOnBuildCompleted(SDProject sdProject)
 {
     if (OnBuildCompleted != null)
     {
         OnBuildCompleted(sdProject);
     }
     ExecuteOnStepMessage("");
 }
Esempio n. 9
0
 public static void InitStepinput(SDProject sdProject, string outputPath, string currentLanguage, HtmlStrings docStrings, HtmlStrings htmlStrings, HtmlConfig htmlConfig)
 {
     SDProject       = sdProject;
     OutputPath      = outputPath;
     CurrentLanguage = currentLanguage;
     DocStrings      = docStrings;
     HtmlStrings     = htmlStrings;
     HtmlConfig      = htmlConfig;
 }
Esempio n. 10
0
        public virtual void StartBuild()
        {
            try
            {
                _buildMessenger.ExecuteOnBuildProgress(0);
                _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.StartingBuild);

                var sdProject = new SDProject();
                foreach (var step in _buildSteps)
                {
                    _buildMessenger.ExecuteOnBuildMessage(string.Format(_sdBuildStrings.StartingStep, step.StepName));
                    _buildMessenger.ExecuteOnBuildProgress(step.StepRange.ProgressStart);
                    _buildMessenger.ExecuteOnStepProgress(0);

                    step.OnBuildProgress += _buildMessenger.ExecuteOnBuildProgress;
                    step.OnBuildMessage  += _buildMessenger.ExecuteOnBuildMessage;
                    step.OnStepMessage   += _buildMessenger.ExecuteOnStepMessage;
                    step.OnStepProgress  += _buildMessenger.ExecuteOnStepProgress;

                    sdProject = step.RunStep(sdProject);

                    _buildMessenger.ExecuteOnStepProgress(100);
                }

                _buildMessenger.ExecuteOnBuildProgress(100);
                _buildMessenger.ExecuteOnStepMessage(string.Empty);
                _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.BuildSuccess);
                _buildMessenger.ExecuteOnBuildCompleted(sdProject);
            }
            catch (Exception ex)
            {
                if (ex is ThreadAbortException)
                {
                    _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.BuildStopped);
                    _buildMessenger.ExecuteOnStepProgress(0);
                    _buildMessenger.ExecuteOnBuildProgress(0);

                    _buildMessenger.ExecuteOnBuildStopped();
                }
                else
                {
                    Trace.TraceError(ex.ToString());

                    if (ex is SDBuildException)
                    {
                        _buildMessenger.ExecuteOnBuildMessage(ex.Message);
                    }

                    _buildMessenger.ExecuteOnBuildMessage(_sdBuildStrings.CouldNotEndBuild);
                    _buildMessenger.ExecuteOnStepProgress(100);
                    _buildMessenger.ExecuteOnBuildProgress(100);

                    _buildMessenger.ExecuteOnBuildFailed();
                }
            }
        }
Esempio n. 11
0
 public static void InitStepinput(SDProject sdProject, SDTargetFx targetFx, string outputPath, string currentLanguage, ChmStrings docStrings, ChmStrings chmStrings, ChmConfig chmConfig)
 {
     SDProject       = sdProject;
     CurrentTargetFx = targetFx;
     OutputPath      = outputPath;
     TmpPath         = Path.Combine(outputPath, "tmp-" + currentLanguage);
     CurrentLanguage = currentLanguage;
     DocStrings      = docStrings;
     ChmStrings      = chmStrings;
     ChmConfig       = chmConfig;
 }
Esempio n. 12
0
        private void ParseNavigationFiles()
        {
            ExecuteOnStepMessage(_stepInput.SDBuildStrings.ParsingNav);
            ExecuteOnStepProgress(50);

            var navFileParser = new SDNavParser(_stepInput.CoreConfigSection.InputFile);
            var navFiles      = Directory.EnumerateFiles(Path.GetDirectoryName(_stepInput.CoreConfigSection.InputFile), "*.sdnav", SearchOption.AllDirectories);

            foreach (var navFile in navFiles)
            {
                _sdProject = navFileParser.ParseNavFile(navFile, _sdProject);
            }
        }
Esempio n. 13
0
        public override SDProject RunStep(SDProject sdProject)
        {
            _stepInput.CodeParser.OnStepMessage  += ExecuteOnStepMessage;
            _stepInput.CodeParser.OnStepProgress += ExecuteOnStepProgress;

            var solutionList = new List <string>(sdProject.Solutions.Keys);

            foreach (var solution in solutionList)
            {
                sdProject.Solutions[solution] = _stepInput.CodeParser.GetParsedSolution(solution, _stepInput.CoreConfigSection, sdProject.Tokens, false);
            }

            return(sdProject);
        }
Esempio n. 14
0
        public DocBuilder(SDProject sdProject, WordStrings wordStrings, string docLanguage, string outputPath)
        {
            _sdProject   = sdProject;
            _wordStrings = wordStrings;
            _docLanguage = docLanguage;
            _outputPath  = outputPath;

            _templatePath = Helper.EnsureCopy(
                Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "templates", "sharpDox.docx"),
                Path.Combine(outputPath, "tmp"));
            _wordTemplater = new WordTemplater(_templatePath);

            _apiBuilder     = new ApiBuilder(_wordTemplater, _sdProject, _wordStrings, _docLanguage, outputPath);
            _articleBuilder = new ArticleBuilder(_wordTemplater, _sdProject, _apiBuilder);
        }
Esempio n. 15
0
        public override SDProject RunStep(SDProject sdProject)
        {
            _stepInput.CodeParser.OnDocLanguageFound += sdProject.AddDocumentationLanguage;
            _stepInput.CodeParser.OnStepMessage      += ExecuteOnStepMessage;
            _stepInput.CodeParser.OnStepProgress     += ExecuteOnStepProgress;

            var solutionList = new List <string>(sdProject.Solutions.Keys);

            foreach (var solution in solutionList)
            {
                sdProject.Solutions[solution] = _stepInput.CodeParser.GetFullParsedSolution(solution, _stepInput.CoreConfigSection, sdProject.Tokens);
            }

            return(sdProject);
        }
Esempio n. 16
0
        private bool ApiEmpty(SDProject sdProject, SDTargetFx targetFx)
        {
            var empty = true;

            foreach (var solution in sdProject.Solutions.Values)
            {
                var sdRepository = solution.Repositories.SingleOrDefault(r => r.TargetFx.Identifier == targetFx.Identifier);
                if (sdRepository != null && sdRepository.GetAllNamespaces().Count > 0)
                {
                    empty = false;
                    break;
                }
            }
            return(empty);
        }
Esempio n. 17
0
        public SDProject ParseNavFile(string navFile, SDProject sdProject)
        {
            var navFileLanguage = Path.GetFileNameWithoutExtension(navFile);

            sdProject.AddDocumentationLanguage(navFileLanguage);

            var articles   = new List <SDArticle>();
            var levelNodes = new List <SDArticle>();

            if (navFile != null)
            {
                foreach (var line in File.ReadAllLines(navFile))
                {
                    var article = GetArticle(line, sdProject.Tokens);
                    if (article is SDDocPlaceholder)
                    {
                        var solutionFile = ((SDDocPlaceholder)article).SolutionFile;
                        sdProject.AddSolution(solutionFile);
                    }

                    var navLevel = GetNavLevel(line);

                    if (levelNodes.Count < navLevel)
                    {
                        levelNodes.Add(article);
                    }
                    else
                    {
                        levelNodes[navLevel - 1] = article;
                    }

                    if (navLevel == 1)
                    {
                        articles.Add(article);
                    }
                    else
                    {
                        article.Parent = levelNodes[navLevel - 2];
                        levelNodes[navLevel - 2].Children.Add(article);
                    }
                }
            }

            sdProject.Articles.Add(navFileLanguage, articles);
            return(sdProject);
        }
Esempio n. 18
0
        private void RunAllExporters(SDProject sdProject)
        {
            var i = 0d;

            foreach (var exporter in _stepInput.AllExporters)
            {
                if (_stepInput.CoreConfigSection.ActivatedExporters.Contains(exporter.ExporterName))
                {
                    var outputPath = GetOutputPath(_stepInput.CoreConfigSection.OutputPath, exporter.ExporterName);

                    ExecuteOnStepMessage(string.Format(_stepInput.SDBuildStrings.RunningExporter, exporter.ExporterName));
                    exporter.OnStepMessage  += (m) => ExecuteOnStepMessage(string.Format("[{0}] {1}", exporter.ExporterName, m));
                    exporter.OnStepProgress += (p) => ExecuteOnStepProgress((int)(((double)p / _stepInput.CoreConfigSection.ActivatedExporters.Count) + (i / _stepInput.CoreConfigSection.ActivatedExporters.Count * 100)));
                    exporter.Export(sdProject, outputPath);
                    i++;
                }
            }
        }
Esempio n. 19
0
        // The export function gets the parsed solution and the output path.
        public void Export(SDProject sdProject, string outputPath)
        {
            var csv = string.Empty;

            foreach (var solution in sdProject.Solutions.Values)
            {
                // Get all types in the current solution.
                // Grouped by type identifiers and repositories (targetfx)
                var types = solution.GetAllSolutionTypes();
                foreach (var groupedTypes in types.Values)
                {
                    var type = groupedTypes.First().Value;
                    ExecuteOnStepMessage("Creating entry for " + type.Fullname);
                    csv += string.Format("{1}{0}{2}{0}{3}", _csvConfig.Divider, type.Fullname, type.Name, type.Namespace) + Environment.NewLine;
                }
            }
            File.WriteAllText(Path.Combine(outputPath, "types.csv"), csv);
        }
Esempio n. 20
0
        public override SDProject RunStep(SDProject sdProject)
        {
            if (string.IsNullOrEmpty(_stepInput.CoreConfigSection.ProjectName))
            {
                throw new SDBuildException(_stepInput.SDBuildStrings.NoProjectNameGiven);
            }

            if (_stepInput.CoreConfigSection.InputFile == null)
            {
                throw new SDBuildException(_stepInput.SDBuildStrings.NoProjectGiven);
            }

            if (!File.Exists(_stepInput.CoreConfigSection.InputFile.ResolvePath(Environment.CurrentDirectory)))
            {
                throw new SDBuildException(_stepInput.SDBuildStrings.ProjectNotFound);
            }

            return(sdProject);
        }
Esempio n. 21
0
        public override SDProject RunStep(SDProject sdProject)
        {
            _sdProject = sdProject;
            SetProjectInfos();
            GetImages();
            ParseTokens();
            ParseDescriptions();

            if (Path.GetExtension(_stepInput.CoreConfigSection.InputFile) == ".sdnav")
            {
                ParseNavigationFiles();
            }
            else
            {
                _sdProject.Solutions.Add(_stepInput.CoreConfigSection.InputFile, new SDSolution(_stepInput.CoreConfigSection.InputFile));
            }

            return(_sdProject);
        }
Esempio n. 22
0
 public Helper(SDProject sdProject)
 {
     _sdProject = sdProject;
 }
Esempio n. 23
0
        public override SDProject RunStep(SDProject sdProject)
        {
            RunAllExporters(sdProject);

            return(sdProject);
        }
 public TypeBuilder(WordTemplater wordTemplater, SDProject sdProject, WordStrings wordStrings, string docLanguage, string outputPath)
     : base(wordTemplater, sdProject, wordStrings, docLanguage)
 {
     _outputPath = outputPath;
 }
 public ApiBuilder(WordTemplater wordTemplater, SDProject sdProject, WordStrings wordStrings, string docLanguage, string outputPath)
     : base(wordTemplater, sdProject, wordStrings, docLanguage)
 {
     _namespaceBuilder = new NamespaceBuilder(wordTemplater, sdProject, wordStrings, docLanguage, outputPath);
 }
Esempio n. 26
0
 public abstract SDProject RunStep(SDProject sdProject);
Esempio n. 27
0
 public ArticleBuilder(WordTemplater wordTemplater, SDProject sdProject, ApiBuilder apiBuilder)
 {
     _wordTemplater = wordTemplater;
     _sdProject     = sdProject;
     _apiBuilder    = apiBuilder;
 }