/// <summary> /// Initializes a new instance of class MsdnXsltUtilities /// </summary> /// <param name="namespaceMapper">The namespace mapper used to look up XLink help namespace for foreign types</param> /// <param name="fileMapper">The mapper used to look up local filenames</param> public MsdnXsltUtilities(NamespaceMapper namespaceMapper, FileNameMapper fileMapper) { if (namespaceMapper == null) { throw new ArgumentNullException("namespaceMapper"); } if (fileMapper == null) { throw new ArgumentNullException("fileMapper"); } ResetDescriptions(); nsMapper = namespaceMapper; _fileMapper = fileMapper; aIndexCache = new Hashtable(); }
/// <summary> /// Constructs a new instance of HtmlFactory /// </summary> /// <param name="tempFileName">NDoc generated temp xml file</param> /// <param name="outputDirectory">The directory to write the Html files to</param> /// <param name="htmlProvider">Object the provides additional Html content</param> /// <param name="config"></param> public HtmlFactory( string tempFileName, string outputDirectory, ExternalHtmlProvider htmlProvider, NativeHtmlHelp2Config config ) { Debug.WriteLine("mem before doc load " + GC.GetTotalMemory(true).ToString()); // Load the XML documentation. xmlDocumentation = new XmlDocument(); Stream tempFile=null; try { tempFile=File.Open(tempFileName,FileMode.Open,FileAccess.Read); FilteringXmlTextReader fxtr = new FilteringXmlTextReader(tempFile); xmlDocumentation.Load(fxtr); tempFile.Seek(0,SeekOrigin.Begin); XmlTextReader reader = new XmlTextReader(tempFile); xPathDocumentation = new XPathDocument(reader,XmlSpace.Preserve); } finally { if (tempFile!=null) tempFile.Close(); if (File.Exists(tempFileName)) File.Delete(tempFileName); } //check if there is anything to document 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..."); if ( !Directory.Exists( outputDirectory ) ) throw new Exception( string.Format( "The output directory {0}, does not exist", outputDirectory ) ); _outputDirectory = outputDirectory; documentedNamespaces = new ArrayList(); string NSName=""; string FrameworkVersion=""; if ( config.SdkDocVersion == SdkVersion.SDK_v1_0 ) { NSName = "ms-help://MS.NETFrameworkSDK"; FrameworkVersion="1.0"; } else if ( config.SdkDocVersion == SdkVersion.SDK_v1_1 ) { NSName = "ms-help://MS.NETFrameworkSDKv1.1"; FrameworkVersion="1.1"; } else if (config.SdkDocVersion == SdkVersion.SDK_v2_0) { NSName = "ms-help://MS.NETFrameworkSDKv2.0"; FrameworkVersion = "2.0"; } else Debug.Assert( false ); // remind ourselves to update this list when new framework versions are supported string DocLangCode = Enum.GetName(typeof(SdkLanguage),config.SdkDocLanguage).Replace("_","-"); if (DocLangCode != "en") NSName = NSName + "." + DocLangCode; nsMapper = new NamespaceMapper( Path.Combine( Directory.GetParent( _outputDirectory ).ToString(), "NamespaceMap.xml" ) ); nsMapper.SetSystemNamespace(NSName); fileNameMapper = new FileNameMapper(xmlDocumentation); _htmlProvider = htmlProvider; _utilities = new MsdnXsltUtilities( this.nsMapper, this.fileNameMapper ); this.Arguments = new XsltArgumentList(); this.Arguments.AddExtensionObject( "urn:ndoc-sourceforge-net:documenters.NativeHtmlHelp2.xsltUtilities", _utilities ); this.Arguments.AddExtensionObject( "urn:NDocExternalHtml", _htmlProvider ); // add properties passed to the stylesheets this.Arguments.AddParam( "ndoc-title", "", config.Title ); this.Arguments.AddParam( "ndoc-document-attributes", "", config.DocumentAttributes ); this.Arguments.AddParam( "ndoc-net-framework-version", "", FrameworkVersion ); this.Arguments.AddParam( "ndoc-version", "", config.Version ); XPathDocument DocumenterSpecificXml = GetDocumenterSpecificXmlData(config); XPathNodeIterator it = DocumenterSpecificXml.CreateNavigator().Select("*"); this.Arguments.AddParam( "documenter-specific-xml", "", it ); }