Example #1
0
		/// <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();
		}
Example #2
0
		/// <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 );
			
		}
Example #3
0
		/// <summary>
		/// Merges the specified map into this map
		/// </summary>
		/// <param name="mapper">The map to merge into this one</param>
		public void MergeMaps( NamespaceMapper mapper )
		{
			XmlNodeList helpNamespaces = mapper.map.SelectNodes( "//map:helpNamespace", nsmgr );

			// for each help namespace in the new map, merge it into this map
			foreach ( XmlNode node in helpNamespaces )			
				MergeHelpNamespace( node );
		}
		/// <summary>See <see cref="IDocumenter"/>.</summary>
		public override string CanBuild( Project project, bool checkInputOnly )
		{
			string result = base.CanBuild(project, checkInputOnly); 
			if (result != null)
				return result;

			if ( !HxObject.HxCompIsInstalled )
				return "Could not find Html Help 2 compiler. Please make sure VSHIK 2003 is properly installed";

			if ( MyConfig.OutputDirectory == null )
				return "The output directory must be set";

			// validate the namespace map
			string NamespaceMappingFilePath=MyConfig.UseHelpNamespaceMappingFile;
			if ( NamespaceMappingFilePath.Length != 0 )
			{
				if ( !File.Exists( NamespaceMappingFilePath ) )
					return string.Format( "Could not find the namespace mapping file: {0}", NamespaceMappingFilePath );

				try
				{
					NamespaceMapper mapper = new NamespaceMapper( NamespaceMappingFilePath );
				}
				catch ( Exception e )
				{
					StringBuilder sb = new StringBuilder();
					sb.AppendFormat( "The namespace mapping file {0} failed to validate.\n", NamespaceMappingFilePath );
					sb.Append( "Make sure that it conforms to the NamespaceMap.xsd schema that can be found in the NDoc installation directory.\n" );
					sb.AppendFormat( "Parse error={0}", e.Message );
					return sb.ToString();
				}
			}

			// validate that all of the additional content resources are present
			string IntroductionPage = MyConfig.IntroductionPage;
			if ( IntroductionPage.Length != 0 && !File.Exists( IntroductionPage ) )
				return string.Format( "The IntroductionPage file {0} could not be found", IntroductionPage );

			string AboutPageIconPage = MyConfig.AboutPageIconPage;
			if ( AboutPageIconPage.Length != 0 && !File.Exists( AboutPageIconPage ) )
				return string.Format( "The AboutPageIconPage file {0} could not be found", AboutPageIconPage );

			string AboutPageInfo = MyConfig.AboutPageInfo;
			if ( AboutPageInfo.Length != 0 && !File.Exists( AboutPageInfo ) )
				return string.Format( "The AboutPageInfo file {0} could not be found", AboutPageInfo );

			string NavFailPage = MyConfig.NavFailPage;
			if ( NavFailPage.Length != 0 && !File.Exists( NavFailPage ) )
				return string.Format( "The NavFailPage file {0} could not be found", NavFailPage );

			string EmptyIndexTermPage = MyConfig.EmptyIndexTermPage;
			if ( EmptyIndexTermPage.Length != 0 && !File.Exists( EmptyIndexTermPage ) )
				return string.Format( "The EmptyIndexTermPage file {0} could not be found", EmptyIndexTermPage );

			string ExtensibilityStylesheet = MyConfig.ExtensibilityStylesheet;
			if ( ExtensibilityStylesheet.Length != 0 && !File.Exists( ExtensibilityStylesheet ) )
				return string.Format( "The Extensibility Stylesheet file {0} could not be found", ExtensibilityStylesheet );

			string AdditionalContentResourceDirectory = MyConfig.AdditionalContentResourceDirectory;
			if ( AdditionalContentResourceDirectory.Length != 0 && !Directory.Exists( AdditionalContentResourceDirectory ) )
				return string.Format( "The Additional Content Resource Directory {0} could not be found", AdditionalContentResourceDirectory );

			// make sure we have a collection namespace
			if ( ( MyConfig.GenerateCollectionFiles || MyConfig.RegisterTitleWithNamespace ) && MyConfig.CollectionNamespace.Length == 0 )
				return "If GenerateCollectionFiles or RegisterTitleWithNamespace is true, a valid CollectionNamespace is required";

			// test if we can write to the output file
			if ( !checkInputOnly ) 
			{
				string temp = Path.Combine( MyConfig.OutputDirectory, "~HxS.tmp" );

				try
				{

					if ( File.Exists( MainOutputFile ) )
					{
						//if we can move the file, then it is not open...
						File.Move( MainOutputFile, temp );
						File.Move( temp, MainOutputFile );
					}
				}
				catch ( Exception )
				{
					result = "The compiled HTML Help file is probably open.\nPlease close it and try again.";
				}
			}

			return result;
		}