/// <summary>See <see cref="IDocumenter"/>.</summary> public override void Build(Project project) { this.workspace = new JavaDocWorkspace( this.WorkingPath ); workspace.Clean(); workspace.Prepare(); workspace.AddResourceDirectory( "xslt" ); workspace.AddResourceDirectory( "css" ); // Define this when you want to edit the stylesheets // without having to shutdown the application to rebuild. #if NO_RESOURCES // copy all of the xslt source files into the workspace DirectoryInfo xsltSource = new DirectoryInfo( Path.GetFullPath(Path.Combine( System.Windows.Forms.Application.StartupPath, @"..\..\..\Documenter\JavaDoc\xslt") ) ); foreach ( FileInfo f in xsltSource.GetFiles( "*.xslt" ) ) { string fname = Path.Combine( Path.Combine( workspace.ResourceDirectory, "xslt" ), f.Name ); f.CopyTo( fname, true ); File.SetAttributes( fname, FileAttributes.Normal ); } DirectoryInfo cssSource = new DirectoryInfo( Path.GetFullPath(Path.Combine( System.Windows.Forms.Application.StartupPath, @"..\..\..\Documenter\JavaDoc\css") ) ); foreach ( FileInfo f in cssSource.GetFiles( "*.css" ) ) { string cssname = Path.Combine( Path.Combine( workspace.ResourceDirectory, "css" ), f.Name ); f.CopyTo( cssname, true ); File.SetAttributes( cssname, FileAttributes.Normal ); } #else EmbeddedResources.WriteEmbeddedResources( this.GetType().Module.Assembly, "NDoc.Documenter.JavaDoc.css", Path.Combine( this.workspace.ResourceDirectory, "css" ) ); EmbeddedResources.WriteEmbeddedResources( this.GetType().Module.Assembly, "NDoc.Documenter.JavaDoc.xslt", Path.Combine( this.workspace.ResourceDirectory, "xslt") ); #endif string outcss = Path.Combine(MyConfig.OutputDirectory, "JavaDoc.css"); File.Copy(Path.Combine(workspace.ResourceDirectory, @"css\JavaDoc.css"), outcss, true); File.SetAttributes(outcss, FileAttributes.Archive); try { // determine temp file name tempFileName = Path.GetTempFileName(); // Let the Documenter base class do it's thing. MakeXmlFile(project, tempFileName); WriteOverviewSummary(); WriteNamespaceSummaries(); } finally { if (tempFileName != null && File.Exists(tempFileName)) { File.Delete(tempFileName); } workspace.RemoveResourceDirectory(); } }
/// <summary>See <see cref="IDocumenter"/>.</summary> public override void Build(Project project) { try { OnDocBuildingStep(0, "Initializing..."); this.workspace = new LinearHtmlWorkspace( this.WorkingPath ); workspace.Clean(); workspace.Prepare(); workspace.AddResourceDirectory( "xslt" ); // Define this when you want to edit the stylesheets // without having to shutdown the application to rebuild. #if NO_RESOURCES // copy all of the xslt source files into the workspace DirectoryInfo xsltSource = new DirectoryInfo( Path.GetFullPath(Path.Combine( System.Windows.Forms.Application.StartupPath, @"..\..\..\Documenter\LinearHtml\xslt") ) ); foreach ( FileInfo f in xsltSource.GetFiles( "*.xslt" ) ) { string destPath = Path.Combine( Path.Combine( workspace.ResourceDirectory, "xslt" ), f.Name ); // change to allow overwrite if clean-up failed last time if (File.Exists(destPath)) File.SetAttributes( destPath, FileAttributes.Normal ); f.CopyTo( destPath, true ); // set attributes to allow delete later File.SetAttributes( destPath, FileAttributes.Normal ); } #else EmbeddedResources.WriteEmbeddedResources(this.GetType().Module.Assembly, "NDoc.Documenter.LinearHtml.xslt", Path.Combine(workspace.ResourceDirectory, "xslt")); #endif // Create the html output directory if it doesn't exist. if (!Directory.Exists(MyConfig.OutputDirectory)) { Directory.CreateDirectory(MyConfig.OutputDirectory); } // Write the embedded css files to the html output directory EmbeddedResources.WriteEmbeddedResources(this.GetType().Module.Assembly, "NDoc.Documenter.LinearHtml.css", MyConfig.OutputDirectory); // Write the external files (FilesToInclude) to the html output directory foreach( string srcFile in MyConfig.FilesToInclude.Split( '|' ) ) { if ((srcFile == null) || (srcFile.Length == 0)) continue; string dstFile = Path.Combine(MyConfig.OutputDirectory, Path.GetFileName(srcFile)); File.Copy(srcFile, dstFile, true); File.SetAttributes(dstFile, FileAttributes.Archive); } OnDocBuildingStep(10, "Merging XML documentation..."); // Will hold the name of the file name containing the XML doc string tempFileName = null; // Will hold the DOM representation of the XML doc XmlDocument xmlDocumentation = null; try { // determine temp file name tempFileName = Path.GetTempFileName(); // Let the Documenter base class do it's thing. MakeXmlFile(project, tempFileName); // Load the XML into DOM xmlDocumentation = new XmlDocument(); xmlDocumentation.Load(tempFileName); } finally { if (tempFileName != null && File.Exists(tempFileName)) { File.Delete(tempFileName); } } #if USE_XML_DOCUMENT xPathNavigator = xmlDocumentation.CreateNavigator(); #else XmlTextWriter tmpWriter = new XmlTextWriter(new MemoryStream(), Encoding.UTF8); xmlDocumentation.WriteTo(tmpWriter); tmpWriter.Flush(); tmpWriter.BaseStream.Position = 0; this.Load(tmpWriter.BaseStream); #endif // check for documentable types XmlNodeList typeNodes = xmlDocumentation.SelectNodes("/ndoc/assembly/module/namespace/*[name()!='documentation']"); if (typeNodes.Count == 0) { throw new DocumenterException("There are no documentable types in this project.\n\nAny types that exist in the assemblies you are documenting have been excluded by the current visibility settings.\nFor example, you are attempting to document an internal class, but the 'DocumentInternals' visibility setting is set to False.\n\nNote: C# defaults to 'internal' if no accessibilty is specified, which is often the case for Console apps created in VS.NET..."); } // create and write the html OnDocBuildingStep(50, "Generating HTML page..."); MakeHtml(this.MainOutputFile); OnDocBuildingStep(100, "Done."); workspace.Clean(); } catch(Exception ex) { throw new DocumenterException(ex.Message, ex); } }