예제 #1
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        public SelectAssemblyDlg()
        {
            InitializeComponent();

            docAsm = new DocumentAssembly();
            pgProps.SelectedObject = docAsm;
        }
예제 #2
0
        /// <summary>
        /// This is called to add multiple assemblies and/or comments files to
        /// a project for documenting.
        /// </summary>
        /// <param name="wildcard">The wildcard to add.</param>
        /// <param name="project">The project to which they are added.</param>
        /// <param name="commentsOnly">True if adding comments only, false if
        /// adding assembly/comments file pairs.</param>
        private static void AddAssemblyWildCard(string wildcard,
                                                SandcastleProject project, bool commentsOnly)
        {
            DocumentAssembly newItem;
            string           dirName, fileSpec;

            string[] files;
            int      idx;

            idx = wildcard.LastIndexOf('\\');
            if (idx == -1)
            {
                dirName  = Directory.GetCurrentDirectory();
                fileSpec = wildcard;
            }
            else
            {
                dirName  = Path.GetFullPath(wildcard.Substring(0, idx));
                fileSpec = wildcard.Substring(idx + 1);
            }

            files = Directory.GetFiles(dirName, fileSpec);

            foreach (string file in files)
            {
                newItem = new DocumentAssembly();

                if (file.ToLower(CultureInfo.InvariantCulture).EndsWith(".xml"))
                {
                    newItem.XmlCommentsPath = new FilePath(file);
                    if (newItem.AssemblyPath.Path.Length == 0)
                    {
                        if (commentsOnly)
                        {
                            newItem.CommentsOnly = true;
                        }
                        else
                        {
                            newItem.AssemblyPath = new FilePath("Unknown.dll");
                        }
                    }
                }
                else
                {
                    newItem.AssemblyPath = new FilePath(file);
                    if (newItem.XmlCommentsPath.Path.Length == 0)
                    {
                        newItem.XmlCommentsPath = new FilePath("Unknown.xml");
                    }
                }

                if (!project.Assemblies.Contains(newItem))
                {
                    project.Assemblies.Add(newItem);
                }
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: Kybs0/Diversos
        /// <summary>
        /// Add one or more documentation assemblies
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        /// <remarks>This will assume that the matching file (assembly or
        /// comments file) has the same name as the selected file.  If a
        /// match is not found, the missing file's name is set to "Unknown"
        /// and the Edit option can be used to fix it.</remarks>
        private void btnAddAssembly_Click(object sender, EventArgs e)
        {
            DocumentAssembly newItem;

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Multiselect = true;
                dlg.Title       = "Select the file(s) to document";
                dlg.Filter      = "Library, Executable, and Comment Files " +
                                  "(*.dll, *.exe, *.xml)|*.dll;*.exe;*.xml|" +
                                  "Library Files (*.dll)|*.dll|" +
                                  "Executable Files (*.exe)|*.exe|" +
                                  "XML Comment Files (*.xml)|*.xml|" +
                                  "All Files (*.*)|*.*";
                dlg.InitialDirectory = Directory.GetCurrentDirectory();

                // If selected, add the new file(s)
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    foreach (string file in dlg.FileNames)
                    {
                        newItem = new DocumentAssembly();

                        if (file.ToLower(
                                CultureInfo.InvariantCulture).EndsWith(".xml"))
                        {
                            newItem.XmlCommentsPath = new FilePath(file);
                            if (newItem.AssemblyPath.Path.Length == 0)
                            {
                                newItem.AssemblyPath = new FilePath(
                                    "Unknown.dll");
                            }
                        }
                        else
                        {
                            newItem.AssemblyPath = new FilePath(file);
                            if (newItem.XmlCommentsPath.Path.Length == 0)
                            {
                                newItem.XmlCommentsPath = new FilePath(
                                    "Unknown.xml");
                            }
                        }

                        if (!project.Assemblies.Contains(newItem))
                        {
                            project.Assemblies.Add(newItem);
                        }
                    }
                }
            }
        }
예제 #4
0
        //=====================================================================
        // Methods

        /// <summary>
        /// Main program entry point
        /// </summary>
        /// <param name="args">The command line arguments.  This should be a
        /// list of projects to build and an optional "/v" option to provide
        /// verbose output.</param>
        /// <returns>Zero on success, non-zero on failure</returns>
        static int Main(string[] args)
        {
            DocumentAssembly docAsm;
            ContentItem      ci;
            DependencyItem   di;
            OptionInfo       lastOption = null;

            SandcastleProject        newProject = new SandcastleProject();
            List <OptionInfo>        options    = new List <OptionInfo>();
            List <SandcastleProject> projects   = new List <SandcastleProject>();
            bool success = false;

            char[] wildcards     = new char[] { '*', '?' };
            string currentFolder = Directory.GetCurrentDirectory();

            Assembly asm = Assembly.GetEntryAssembly();

            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);

            Console.WriteLine("{0}, version {1}\r\n{2}\r\nE-Mail: " +
                              "[email protected]\r\n", fvi.ProductName, fvi.ProductVersion,
                              fvi.LegalCopyright);

            try
            {
                // Get a list of options and expand any response files
                foreach (string option in args)
                {
                    if (option[0] == '@')
                    {
                        LoadResponseFile(option.Substring(1), options);
                    }
                    else
                    {
                        options.Add(new OptionInfo(option));
                    }
                }

                if (options.Count == 0)
                {
                    ShowHelp();
                    return(1);
                }

                // Build a list of projects and apply any properties to them
                // as needed.
                foreach (OptionInfo option in options)
                {
                    lastOption = option;

                    switch (option.Name)
                    {
                    case "help":
                    case "?":
                        ShowHelp();
                        break;

                    case "verbose":
                    case "v":
                        verbose = true;
                        break;

                    case "new":
                    case "project":
                        if (newProject.IsDirty || newProject.Filename !=
                            SandcastleProject.DefaultName)
                        {
                            projects.Add(newProject);
                        }

                        newProject = new SandcastleProject();

                        if (option.Name == "project")
                        {
                            newProject.LoadProject(option.Value);
                        }
                        break;

                    case "assembly":
                        if (option.Value.IndexOfAny(wildcards) == -1)
                        {
                            // Single assembly
                            docAsm = new DocumentAssembly();
                            docAsm.AssemblyPath = new FilePath(option.Value);

                            if (!String.IsNullOrEmpty(option.SecondValue))
                            {
                                docAsm.XmlCommentsPath =
                                    new FilePath(option.SecondValue);
                            }

                            newProject.Assemblies.Add(docAsm);
                        }
                        else
                        {
                            AddAssemblyWildCard(option.Value, newProject,
                                                false);
                        }
                        break;

                    case "comments":
                        if (option.Value.IndexOfAny(wildcards) == -1)
                        {
                            docAsm = new DocumentAssembly();
                            docAsm.XmlCommentsPath = new FilePath(option.Value);
                            docAsm.CommentsOnly    = true;

                            newProject.Assemblies.Add(docAsm);
                        }
                        else
                        {
                            AddAssemblyWildCard(option.Value, newProject,
                                                true);
                        }
                        break;

                    case "addcontent":
                        ci            = new ContentItem();
                        ci.SourcePath = new FilePath(option.Value);

                        if (!String.IsNullOrEmpty(option.SecondValue))
                        {
                            ci.DestinationPath = option.SecondValue;
                        }

                        newProject.AdditionalContent.Add(ci);

                        if (!String.IsNullOrEmpty(option.ThirdValue))
                        {
                            ci.ExcludeItems = Convert.ToBoolean(
                                option.ThirdValue, CultureInfo.InvariantCulture);
                        }
                        break;

                    case "dependency":
                        di = new DependencyItem();
                        di.DependencyPath = new FileFolderGacPath(
                            option.Value);

                        newProject.Dependencies.Add(di);
                        break;

                    case "component":
                        newProject.ComponentConfigurations.Add(
                            option.Value, option.SecondValue);
                        break;

                    default:
                        // Set a simple project property
                        newProject.SetProperty(option.Name, option.Value);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                if (lastOption != null)
                {
                    Console.WriteLine("Fatal error applying command line " +
                                      "option '{0}' in project '{1}': {2}",
                                      lastOption.OptionText, newProject.Filename,
                                      ex.ToString());
                }
                else
                {
                    Console.WriteLine("Unexpected error while parsing " +
                                      "command line options: {0}", ex.ToString());
                }

                return(2);
            }

            // Add the final project if necessary
            if (newProject.IsDirty || newProject.Filename !=
                SandcastleProject.DefaultName)
            {
                projects.Add(newProject);
            }

            // Build each of the projects
            foreach (SandcastleProject project in projects)
            {
                success = BuildProject(project);

                if (!success)
                {
                    break;
                }

                // Switch back to the original folder in case we are
                // building a default project next.
                Directory.SetCurrentDirectory(currentFolder);
            }

            return((success) ? 0 : 3);
        }
예제 #5
0
        /// <summary>
        /// This is called to import settings from an NDoc project into
        /// a new Sandcastle Help File Builder project.
        /// </summary>
        /// <param name="ndocProject">The NDoc project file from which to
        /// import the settings.</param>
        private void ImportFromNDoc(string ndocProject)
        {
            StreamReader         sr         = null;
            XmlDocument          sourceFile = new XmlDocument();
            XmlNodeList          elements;
            XmlNode              node;
            DocumentAssembly     da;
            ContentItem          ci, rootPage = null;
            DependencyItem       di;
            NamespaceSummaryItem nsi;
            string folderName;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                sr = new StreamReader(ndocProject);
                sourceFile.Load(sr);

                // Add the assemblies
                elements = sourceFile.SelectNodes("//assemblies/*");

                foreach (XmlNode assembly in elements)
                {
                    da = new DocumentAssembly();
                    da.AssemblyPath = new FilePath(
                        assembly.Attributes["location"].Value);
                    da.XmlCommentsPath = new FilePath(
                        assembly.Attributes["documentation"].Value);
                    project.Assemblies.Add(da);
                }

                // Add the namespace summaries
                elements = sourceFile.SelectNodes("//namespaces/*");

                foreach (XmlNode ns in elements)
                {
                    nsi         = new NamespaceSummaryItem(ns.Attributes["name"].Value);
                    nsi.Summary = ns.InnerXml;
                    project.NamespaceSummaries.Add(nsi);
                }

                // Add one for the global namespace if it isn't there
                if (!project.NamespaceSummaries.Contains(String.Empty))
                {
                    project.NamespaceSummaries.Add(new NamespaceSummaryItem());
                }

                project.NamespaceSummaries.Sort();

                // Add reference paths
                elements = sourceFile.SelectNodes("//referencePaths/*");

                foreach (XmlNode reference in elements)
                {
                    di = new DependencyItem();

                    di.DependencyPath = new FileFolderGacPath(
                        reference.Attributes["path"].Value + "\\*.dll");

                    project.Dependencies.Add(di);
                }

                // Add options from the MSDN documenter
                node = sourceFile.SelectSingleNode("//documenters/documenter" +
                                                   "[@name=\"MSDN\" or @name=\"MSDN-CHM\"]");

                if (node != null)
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        switch (child.Attributes["name"].Value)
                        {
                        case "AdditionalContentResourceDirectory":
                            ci            = new ContentItem();
                            ci.SourcePath = new FilePath(
                                child.Attributes["value"].Value);
                            folderName         = Path.GetDirectoryName(ci.SourcePath);
                            ci.DestinationPath = folderName.Substring(
                                folderName.LastIndexOf('\\') + 1);
                            project.AdditionalContent.Add(ci);
                            break;

                        case "CopyrightHref":
                            project.CopyrightHref =
                                child.Attributes["value"].Value;
                            break;

                        case "CopyrightText":
                            project.CopyrightText =
                                child.Attributes["value"].Value;
                            break;

                        case "DocumentAttributes":
                            project.DocumentAttributes = Convert.ToBoolean(
                                child.Attributes["value"].Value,
                                CultureInfo.InvariantCulture);
                            break;

                        case "DocumentExplicitInterfaceImplementations":
                            project.DocumentExplicitInterfaceImplementations =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "DocumentInheritedMembers":
                            project.DocumentInheritedMembers =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "DocumentInheritedFrameworkMembers":
                            project.DocumentInheritedFrameworkMembers =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "DocumentInternals":
                            project.DocumentInternals = Convert.ToBoolean(
                                child.Attributes["value"].Value,
                                CultureInfo.InvariantCulture);
                            break;

                        case "DocumentPrivates":
                            project.DocumentPrivates = Convert.ToBoolean(
                                child.Attributes["value"].Value,
                                CultureInfo.InvariantCulture);
                            break;

                        case "DocumentProtected":
                            project.DocumentProtected = Convert.ToBoolean(
                                child.Attributes["value"].Value,
                                CultureInfo.InvariantCulture);
                            break;

                        case "DocumentProtectedInternalAsProtected":
                            project.DocumentProtectedInternalAsProtected =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "DocumentSealedProtected":
                            project.DocumentSealedProtected =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "FeedbackEmailAddress":
                            project.FeedbackEMailAddress =
                                child.Attributes["value"].Value;
                            break;

                        case "HtmlHelpName":
                            project.HtmlHelpName =
                                child.Attributes["value"].Value;
                            break;

                        case "OutputDirectory":
                            project.OutputPath = new FolderPath(
                                child.Attributes["value"].Value);
                            break;

                        case "Title":
                            project.HelpTitle =
                                child.Attributes["value"].Value;
                            break;

                        case "RootPageContainsNamespaces":
                            project.RootNamespaceContainer =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "RootPageFileName":
                            if (rootPage == null)
                            {
                                rootPage            = new ContentItem();
                                rootPage.SourcePath = new FilePath(
                                    child.Attributes["value"].Value);
                                project.AdditionalContent.Insert(0, rootPage);
                            }
                            else
                            {
                                rootPage.SourcePath = new FilePath(
                                    child.Attributes["value"].Value);
                            }
                            break;

                        case "RootPageTOCName":
                            if (rootPage == null)
                            {
                                rootPage            = new ContentItem();
                                rootPage.SourcePath = new FilePath(
                                    @".\Unknown");
                                project.AdditionalContent.Insert(0, rootPage);
                            }
                            break;

                        case "FilesToInclude":
                            foreach (string filename in child.Attributes[
                                         "value"].Value.Split(new char[] { '|' }))
                            {
                                ci            = new ContentItem();
                                ci.SourcePath = new FilePath(filename);
                                project.AdditionalContent.Add(ci);
                            }
                            break;

                        case "AutoDocumentConstructors":
                            project.AutoDocumentConstructors =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "ShowMissingSummaries":
                            project.ShowMissingSummaries =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "ShowMissingRemarks":
                            project.ShowMissingRemarks =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "ShowMissingParams":
                            project.ShowMissingParams =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "ShowMissingReturns":
                            project.ShowMissingReturns =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        case "ShowMissingValues":
                            project.ShowMissingValues =
                                Convert.ToBoolean(
                                    child.Attributes["value"].Value,
                                    CultureInfo.InvariantCulture);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
                MessageBox.Show(ex.Message, Constants.AppName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                this.Cursor = Cursors.Default;
            }
        }
예제 #6
0
        /// <summary>
        /// This is called to import settings from a Visual Studio solution or
        /// project file into a new Sandcastle Help File Builder project.
        /// </summary>
        /// <param name="visualStudioFile">The Visual Studio solution or
        /// project file from which to import the assemblies.</param>
        private void ImportFromVisualStudio(string visualStudioFile)
        {
            List <string>            projectFiles   = new List <string>();
            List <ProjectConfigItem> projectConfigs = new List <ProjectConfigItem>();
            DocumentAssembly         da;
            string solutionContent, folder;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                folder      = Path.GetDirectoryName(visualStudioFile) + "\\";

                // Get a list of projects from a solution file?
                if (visualStudioFile.EndsWith(".sln"))
                {
                    using (StreamReader sr = new StreamReader(visualStudioFile))
                    {
                        solutionContent = sr.ReadToEnd();
                        sr.Close();
                    }

                    // Only add projects that are likely to contain assemblies
                    MatchCollection projects = Regex.Matches(solutionContent,
                                                             "^Project\\(\"\\{(" +
                                                             "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC|" + // C#
                                                             "F184B08F-C81C-45F6-A57F-5ABD9991F28F|" + // VB.NET
                                                             "E6FDF86B-F3D1-11D4-8576-0002A516ECE8" +  // J#
                                                             ")\\}\"\\) = \".*?\", \"(?!http)" +
                                                             "(?<Path>.*?proj)\", \".*?\"", RegexOptions.Multiline);

                    foreach (Match m in projects)
                    {
                        projectFiles.Add(folder + m.Groups["Path"].Value);
                    }
                }
                else
                if (visualStudioFile.EndsWith("proj"))
                {
                    projectFiles.Add(visualStudioFile);
                }

                foreach (string project in projectFiles)
                {
                    this.ImportFromVSProject(project, projectConfigs);
                }

                if (projectConfigs.Count != 0)
                {
                    using (SelectConfigDlg dlg = new SelectConfigDlg(projectConfigs))
                    {
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            foreach (ProjectConfigItem cfg in projectConfigs)
                            {
                                if (cfg.ConfigurationName == dlg.ConfigurationName)
                                {
                                    da = new DocumentAssembly();
                                    da.AssemblyPath = new FilePath(
                                        cfg.AssemblyFile);
                                    da.XmlCommentsPath = new FilePath(
                                        cfg.XmlCommentsFile);
                                    project.Assemblies.Add(da);
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(visualStudioFile + " does not " +
                                    "appear to contain any projects that can be imported.",
                                    Constants.AppName, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
                MessageBox.Show(ex.Message, Constants.AppName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }