/* Function: Start * Attempts to start the engine instance. Returns whether it was successful, and if it wasn't, puts any errors that * prevented it on the list. If you wish to try to start it again, call <Dispose()> and <Create()> first. */ public bool Start(Errors.ErrorList errors, Config.ProjectConfig commandLineConfig) { if (config.Start(errors, commandLineConfig) == false) { return(false); } Path gracefulExitFilePath = config.WorkingDataFolder + "/GracefulExit.nd"; if (System.IO.File.Exists(gracefulExitFilePath)) { config.ReparseEverything = true; config.RebuildAllOutput = true; } else { BinaryFile gracefulExitFile = new BinaryFile(); gracefulExitFile.OpenForWriting(gracefulExitFilePath); gracefulExitFile.WriteByte(0); gracefulExitFile.Close(); } return( commentTypes.Start(errors) && languages.Start(errors) && comments.Start(errors) && links.Start(errors) && searchIndex.Start(errors) && output.Start(errors) && codeDB.Start(errors) && files.Start(errors) ); }
/* Function: Start * Attempts to start the engine instance. Returns whether it was successful, and if it wasn't, puts any errors that prevented * it on the list. If you wish to try to start it again, <Dispose()> of the instance object and create another one. */ public bool Start(Errors.ErrorList errors, Config.ProjectConfig commandLineConfig) { if (config.Start(errors, commandLineConfig) == false) { return(false); } Path gracefulExitFilePath = config.WorkingDataFolder + "/GracefulExit.nd"; if (System.IO.File.Exists(gracefulExitFilePath)) { startupIssues |= StartupIssues.NeedToStartFresh; } else { BinaryFile gracefulExitFile = new BinaryFile(); gracefulExitFile.OpenForWriting(gracefulExitFilePath); gracefulExitFile.WriteByte(0); gracefulExitFile.Close(); } return( commentTypes.Start(errors) && languages.Start(errors) && comments.Start(errors) && links.Start(errors) && styles.Start(errors) && output.Start(errors) && codeDB.Start(errors) && files.Start(errors) ); }
// Group: Saving Functions // __________________________________________________________________________ /* Function: Save * Saves the passed <ProjectConfig> into <Project.nd>. Throws an exception if unsuccessful. */ public void Save(Path filename, ProjectConfig projectConfig) { var output = new BinaryFile(); output.OpenForWriting(filename); try { // [Int32: Tab Width] // [Byte: Documented Only (0 or 1)] // [Byte: Auto Group (0 or 1)] // [Byte: Shrink Files (0 or 1)] output.WriteInt32(projectConfig.TabWidth); output.WriteByte((byte)((bool)projectConfig.DocumentedOnly == false ? 0 : 1)); output.WriteByte((byte)((bool)projectConfig.AutoGroup == false ? 0 : 1)); output.WriteByte((byte)((bool)projectConfig.ShrinkFiles == false ? 0 : 1)); // [String: Identifier] // [[Properties]] // ... // [String: null] foreach (var target in projectConfig.InputTargets) { if (target is Targets.SourceFolder) { SaveSourceFolder((Targets.SourceFolder)target, output); } else if (target is Targets.ImageFolder) { SaveImageFolder((Targets.ImageFolder)target, output); } else { throw new NotImplementedException(); } } // We don't save filter targets foreach (var target in projectConfig.OutputTargets) { if (target is Targets.HTMLOutputFolder) { SaveHTMLOutputFolder((Targets.HTMLOutputFolder)target, output); } else { throw new NotImplementedException(); } } output.WriteString(null); } finally { output.Close(); } }
// Group: Loading Functions // __________________________________________________________________________ /* Function: Load * Loads the information in <Project.nd>, returning whether it was successful. */ public bool Load(Path filename, out ProjectConfig projectConfig) { projectConfig = new ProjectConfig(PropertySource.PreviousRun); this.projectConfig = projectConfig; binaryFile = new BinaryFile(); bool result = true; try { // There were no file format changes between 2.0 and 2.0.2 but there were parsing changes and // bug fixes that require a full rebuild. if (binaryFile.OpenForReading(filename, "2.0.2") == false) { result = false; } else { // [Int32: Tab Width] // [Byte: Documented Only (0 or 1)] // [Byte: Auto Group (0 or 1)] // [Byte: Shrink Files (0 or 1)] projectConfig.TabWidth = binaryFile.ReadInt32(); projectConfig.TabWidthPropertyLocation = PropertySource.PreviousRun; projectConfig.DocumentedOnly = (binaryFile.ReadByte() == 1); projectConfig.DocumentedOnlyPropertyLocation = PropertySource.PreviousRun; projectConfig.AutoGroup = (binaryFile.ReadByte() == 1); projectConfig.AutoGroupPropertyLocation = PropertySource.PreviousRun; projectConfig.ShrinkFiles = (binaryFile.ReadByte() == 1); projectConfig.ShrinkFilesPropertyLocation = PropertySource.PreviousRun; // [String: Identifier] // [[Properties]] // ... // [String: null] string identifier = binaryFile.ReadString(); while (identifier != null) { LoadTarget(identifier); identifier = binaryFile.ReadString(); } } } catch { result = false; // Reset everything. projectConfig = new ProjectConfig(PropertySource.PreviousRun); } finally { binaryFile.Close(); } return(result); }
// Group: Loading Functions // __________________________________________________________________________ /* Function: Load * Attempts to parse <Project.txt> and return it as a <ProjectConfig>. Any syntax errors found will be added to the * <ErrorList>. The <ProjectConfig> object will always exist, even if all its properties are empty. */ public bool Load(Path path, out ProjectConfig projectConfig, ErrorList errorList) { projectConfig = new ProjectConfig(Source.ProjectFile); this.errorList = errorList; this.projectConfig = projectConfig; int originalErrorCount = errorList.Count; using (var configFile = new ConfigFile()) { // We don't condense value whitespace because some things like title, subtitle, and copyright may want multiple spaces. bool openResult = configFile.Open(path, ConfigFile.FileFormatFlags.CondenseIdentifierWhitespace | ConfigFile.FileFormatFlags.MakeIdentifiersLowercase, errorList); if (openResult == false) { return(false); } string lcIdentifier, value; Targets.Base currentTarget = null; ProjectInfo currentProjectInfo = projectConfig.ProjectInfo; while (configFile.Get(out lcIdentifier, out value)) { var propertyLocation = new PropertyLocation(Source.ProjectFile, configFile.FileName, configFile.LineNumber); Targets.Base target = null; if (GetGlobalProperty(lcIdentifier, value, propertyLocation)) { currentTarget = null; currentProjectInfo = projectConfig.ProjectInfo; } else if (GetTargetHeader(lcIdentifier, value, propertyLocation, out target)) { currentTarget = target; if (target is Targets.OutputBase) { currentProjectInfo = (target as Targets.OutputBase).ProjectInfo; } else { currentProjectInfo = projectConfig.ProjectInfo; } } else if (GetProjectInfoProperty(lcIdentifier, value, propertyLocation, currentProjectInfo)) { } else if (currentTarget != null && GetTargetProperty(lcIdentifier, value, propertyLocation, currentTarget)) { } else { errorList.Add( message: Locale.Get("NaturalDocs.Engine", "ConfigFile.NotAValidIdentifier(identifier)", lcIdentifier), propertyLocation: propertyLocation ); } } configFile.Close(); } return(errorList.Count == originalErrorCount); }
// Group: Loading Functions // __________________________________________________________________________ /* Function: Load * Loads the information in <Project.nd>, returning whether it was successful. */ public bool Load(Path filename, out ProjectConfig projectConfig) { projectConfig = new ProjectConfig(Source.PreviousRun); this.projectConfig = projectConfig; binaryFile = new BinaryFile(); bool result = true; try { if (binaryFile.OpenForReading(filename, "2.0") == false) { result = false; } else { // [Int32: Tab Width] // [Byte: Documented Only (0 or 1)] // [Byte: Auto Group (0 or 1)] // [Byte: Shrink Files (0 or 1)] projectConfig.TabWidth = binaryFile.ReadInt32(); projectConfig.TabWidthPropertyLocation = Source.PreviousRun; projectConfig.DocumentedOnly = (binaryFile.ReadByte() == 1); projectConfig.DocumentedOnlyPropertyLocation = Source.PreviousRun; projectConfig.AutoGroup = (binaryFile.ReadByte() == 1); projectConfig.AutoGroupPropertyLocation = Source.PreviousRun; projectConfig.ShrinkFiles = (binaryFile.ReadByte() == 1); projectConfig.ShrinkFilesPropertyLocation = Source.PreviousRun; // [String: Identifier] // [[Properties]] // ... // [String: null] string identifier = binaryFile.ReadString(); while (identifier != null) { LoadTarget(identifier); identifier = binaryFile.ReadString(); } } } catch { result = false; // Reset everything. projectConfig = new ProjectConfig(Source.PreviousRun); } finally { binaryFile.Close(); } return(result); }