public void NDocExecute() { string prjRootPath = TaskUtility.getProjectRootDirectory(true); string workingDir = Path.Combine(prjRootPath, @"Documentation"); NDoc task = new NDoc(); task.BuildEngine = new MockBuild(); task.ToolPath = Path.Combine(workingDir, "ndoc"); task.ProjectFilePath = Path.Combine(workingDir, @"MSBuild.Community.Tasks.ndoc"); task.WorkingDirectory = workingDir; task.Documenter = "XML"; Assert.IsTrue(task.Execute(), "Execute Failed"); }
/// <summary> /// Constructor for the solution settings form. Sets the property grid /// to the MSDN Documenter's configuration properties. /// </summary> /// <param name="project">an NDoc project for the currently loaded solution.</param> public SolutionSettingsForm(NDoc.Core.Project project) { // // Required for Windows Form Designer support // InitializeComponent(); ndocProject = project; msdnDocumenter = new MsdnDocumenter(); this.SetStyle(ControlStyles.DoubleBuffer, true); propertyGrid.SelectedObject = ndocProject.GetDocumenter(msdnDocumenter.Name).Config; }
/// <summary> /// Builds the documentation. /// </summary> public override void Build(NDoc.Core.Project project) { int buildStepProgress = 0; OnDocBuildingStep(buildStepProgress, "Initializing..."); _resourceDirectory = Path.Combine(Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData), "NDoc"), "NAnt"); // get assembly in which documenter is defined Assembly assembly = this.GetType().Module.Assembly; // write xslt files to resource directory EmbeddedResources.WriteEmbeddedResources(assembly, "Documenter.xslt", Path.Combine(_resourceDirectory, "xslt")); // create the html output directories try { LongPathDirectory.Create(OutputDirectory); LongPathDirectory.Create(Path.Combine(OutputDirectory, "elements")); LongPathDirectory.Create(Path.Combine(OutputDirectory, "functions")); LongPathDirectory.Create(Path.Combine(OutputDirectory, "types")); LongPathDirectory.Create(Path.Combine(OutputDirectory, "tasks")); LongPathDirectory.Create(Path.Combine(OutputDirectory, "enums")); LongPathDirectory.Create(Path.Combine(OutputDirectory, "filters")); } catch (Exception ex) { throw new DocumenterException("The output directories could not" + " be created.", ex); } buildStepProgress += 10; OnDocBuildingStep(buildStepProgress, "Merging XML documentation..."); // load the stylesheets that will convert the master xml into html pages MakeTransforms(); // will hold the file name containing the NDoc generated XML string tempFile = null; try { // determine temporary file name tempFile = Path.GetTempFileName(); // create the master XML document MakeXmlFile(project, tempFile); // create a xml document that will be transformed using xslt using (FileStream fs = new FileStream(tempFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { _xmlDocumentation = new XmlDocument(); _xmlDocumentation.Load(fs); } } finally { // ensure temporary file is removed if (tempFile != null) { LongPathFile.Delete(tempFile); } } // build the file mapping buildStepProgress += 15; OnDocBuildingStep(buildStepProgress, "Building mapping..."); // create arguments for nant index page transform XsltArgumentList indexArguments = CreateXsltArgumentList(); // add extension object for NAnt utilities NAntXsltUtilities indexUtilities = NAntXsltUtilities.CreateInstance( _xmlDocumentation, (NAntDocumenterConfig) Config); // add extension object to Xslt arguments indexArguments.AddExtensionObject("urn:NAntUtil", indexUtilities); buildStepProgress += 15; OnDocBuildingStep(buildStepProgress, "Creating Task Index Page..."); // transform nant task index page transform TransformAndWriteResult(_xsltTaskIndex, indexArguments, "tasks/index.html"); buildStepProgress += 10; OnDocBuildingStep(buildStepProgress, "Creating Type Index Page..."); // transform nant type index page transform TransformAndWriteResult(_xsltTypeIndex, indexArguments, "types/index.html"); buildStepProgress += 10; OnDocBuildingStep(buildStepProgress, "Creating Filter Index Page..."); // transform nant type index page transform TransformAndWriteResult(_xsltFilterIndex, indexArguments, "filters/index.html"); OnDocBuildingStep(buildStepProgress, "Creating Function Index Page..."); // transform nant function index page transform TransformAndWriteResult(_xsltFunctionIndex, indexArguments, "functions/index.html"); buildStepProgress += 10; OnDocBuildingStep(buildStepProgress, "Generating Task Documents..."); // generate a page for each marked task XmlNodeList typeNodes = _xmlDocumentation.SelectNodes("//class[starts-with(substring(@id, 3, string-length(@id) - 2), '" + NamespaceFilter + "')]"); foreach (XmlNode typeNode in typeNodes) { ElementDocType elementDocType = indexUtilities.GetElementDocType(typeNode); DocumentType(typeNode, elementDocType, indexUtilities); } OnDocBuildingStep(buildStepProgress, "Generating Function Documents..."); // generate a page for each function - TODO - change the XPath expression to select more functions XmlNodeList functionNodes = _xmlDocumentation.SelectNodes("//method[attribute/@name = 'NAnt.Core.Attributes.FunctionAttribute' and ancestor::class[starts-with(substring(@id, 3, string-length(@id) - 2), '" + NamespaceFilter + "')]]"); foreach (XmlElement function in functionNodes) { DocumentFunction(function, indexUtilities); } OnDocBuildingStep(100, "Complete"); }
public ProjectPlugin(NDoc.VisualStudio.ISolution solution, DTE2 _applicationObject, string uniqueName) { this._applicationObject = _applicationObject; this._uniqueName = uniqueName; this._solution = solution; }
/// <summary> /// Returns the documenter for the given project. /// </summary> /// <exception cref="BuildException"> /// Documenter <paramref name="documenterName" /> is not found. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="project" /> is <see langword="null" />. /// </exception> private IDocumenter CheckAndGetDocumenter(NDoc.Core.Project project, string documenterName) { IDocumenter documenter = null; if (project == null) { throw new ArgumentNullException("project"); } StringCollection documenters = new StringCollection(); foreach (IDocumenter d in project.Documenters) { documenters.Add(d.Name); // ignore case when comparing documenter names if (string.Compare(d.Name, documenterName, true, CultureInfo.InvariantCulture) == 0) { documenter = (IDocumenter) d; break; } } // throw an exception if the documenter could not be found. if (documenter == null) { if (documenters.Count == 0) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA2024"), documenterName), Location); } else { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA2025"), documenterName, StringUtils.Join(", ", documenters)), Location); } } return documenter; }
public void FromExternSolution(NDoc.VisualStudio.ISolution sol, string config){ string warningMessages = String.Empty; if ((config == null) || (config == "")) { using (SolutionForm sf = new SolutionForm()) { sf.Text = "Solution " + sol.Name; sf.ConfigList.Items.Clear(); foreach (string configkey in sol.GetConfigurationsNames()) sf.ConfigList.Items.Add(configkey); sf.ShowDialog(this); if (sf.ConfigList.SelectedIndex < 0) return; //clear current ndoc project settings Clear(); warningMessages = LoadFromSolution(sol, (string)sf.ConfigList.SelectedItem); EnableMenuItems(true); EnableAssemblyItems(); projectFilename = Path.Combine(sol.Directory, sol.Name + ".ndoc"); } } else { warningMessages = LoadFromSolution(sol, config); EnableMenuItems(true); EnableAssemblyItems(); projectFilename = Path.Combine(sol.Directory, sol.Name + ".ndoc"); } if (warningMessages.Length > 0) WarningForm.ShowWarning("VS Solution Import Warnings", warningMessages, this); }
private void SetDocumentationPathAndFilename(NDoc.Core.Project ndocProject) { MsdnDocumenter msdnDocumenter = new MsdnDocumenter(); MsdnDocumenter documenter; string configDocFilename; string configDocOutputDir; documenter = (MsdnDocumenter)ndocProject.GetDocumenter(msdnDocumenter.Name); configDocFilename = ((MsdnDocumenterConfig)(documenter.Config)).HtmlHelpName + ".chm"; configDocOutputDir = ((MsdnDocumenterConfig)(documenter.Config)).OutputDirectory; // Need to make the relative path go off of the solution and not the devenv.exe directory. if (configDocOutputDir.StartsWith(".") || (configDocOutputDir.StartsWith(@"\") && !(configDocOutputDir.StartsWith(@"\\")))) { documentationFullName = Path.Combine(solutionPath, configDocOutputDir); } else { documentationFullName = configDocOutputDir; } documentationFullName += configDocFilename; }
private void RemoveAssemblySlashDocs(NDoc.Core.Project ndocProject) { for (int i = ndocProject.AssemblySlashDocCount - 1; i >= 0; i--) { ndocProject.RemoveAssemblySlashDoc(i); } }
private void Build(MsdnDocumenter documenter, NDoc.Core.Project ndocProject) { BuildWorker buildWorker = new BuildWorker(documenter, ndocProject); buildThread = new System.Threading.Thread(new System.Threading.ThreadStart(buildWorker.ThreadProc)); buildThread.Name = "NDocBuild"; buildThread.IsBackground = true; buildThread.Priority = System.Threading.ThreadPriority.BelowNormal; try { buildThread.Start(); } finally { } // If no exception occurred during the build, then blow outta here Exception ex = buildWorker.Exception; if (ex == null) { return; } //check if thread has been aborted Exception iex = ex; do { if (iex is System.Threading.ThreadAbortException) { return; } iex = iex.InnerException; } while (iex != null); // Process exception buildPane.OutputString("An error occured while trying to build the documentation..."); if (ex is DocumenterException) { buildPane.OutputString("NDoc Documenter Error: " + ex.InnerException); } else { buildPane.OutputString("Unknown Error: " + ex.InnerException); } }