示例#1
0
        /* Function: SetHomePage
         */
        public void SetHomePage(Path file, Config.PropertyLocation propertyLocation)
        {
                        #if DEBUG
            if (file.IsRelative)
            {
                throw new Exception("Paths passed to SetHomePage() must be absolute.");
            }
                        #endif

            homePage.File             = file;
            homePage.PropertyLocation = propertyLocation;
        }
示例#2
0
        /* Function: AddOnLoad
         */
        public void AddOnLoad(string onLoadString, Config.PropertyLocation propertyLocation, PageType type = PageType.All)
        {
            if (onLoad == null)
            {
                onLoad = new List <StyleOnLoadStatement>();
            }

            StyleOnLoadStatement entry = new StyleOnLoadStatement();

            entry.Type             = type;
            entry.Statement        = onLoadString;
            entry.PropertyLocation = propertyLocation;

            onLoad.Add(entry);
        }
示例#3
0
        /* Function: AddInheritedStyle
         */
        public void AddInheritedStyle(string name, Config.PropertyLocation propertyLocation, Style styleObject = null)
        {
            if (inherits == null)
            {
                inherits = new List <StyleInheritStatement>();
            }

            StyleInheritStatement entry = new StyleInheritStatement();

            entry.Name             = name;
            entry.Style            = styleObject;
            entry.PropertyLocation = propertyLocation;

            inherits.Add(entry);
        }
示例#4
0
        /* Function: AddLinkedFile
         */
        public void AddLinkedFile(Path file, Config.PropertyLocation propertyLocation, PageType type = PageType.All)
        {
                        #if DEBUG
            if (file.IsRelative)
            {
                throw new Exception("Paths passed to AddLinkedFile() must be absolute.");
            }
                        #endif

            if (links == null)
            {
                links = new List <StyleFileLink>();
            }

            StyleFileLink entry = new StyleFileLink();
            entry.Type             = type;
            entry.File             = file;
            entry.PropertyLocation = propertyLocation;

            links.Add(entry);
        }
示例#5
0
        /* Function: LoadStyle
         *
         * Attempts to load a <Style> with the passed name, returning it if successful.  It will also load any inherited styles.
         * If it couldn't find the style or there were errors in its configuration files it will add them to the error list and return
         * null.  Pass a <Config.PropertyLocation> so it will be able to attach where it was specified to the error message.
         *
         * All loaded styles will be tracked by the <Styles.FileSource> automatically.  However, if you're adding a new style to
         * an output target you should set <ReparseStyleFiles> so the new target will see all its files.  Otherwise if the style
         * was previously used by a different output target it will be already loaded and the new one won't see them.
         */
        public Style LoadStyle(string name, Errors.ErrorList errorList, Config.PropertyLocation propertyLocation)
        {
            // We have to locate the style on disk before checking the loaded styles.  This is so if there's two styles with the
            // same name it will always resolve to the correct location.

            Style style = LocateStyleOnDisk(name);

            if (style == null)
            {
                errorList.Add(Locale.Get("NaturalDocs.Engine", "Style.txt.CantFindStyle(name)", name), propertyLocation);
                return(null);
            }


            // See if it's already loaded.

            Style loadedStyle = FindMatchingLoadedStyle(style);

            if (loadedStyle != null)
            {
                return(loadedStyle);
            }


            // Load or generate the style's properties.

            int previousErrorCount = errorList.Count;

            if (style is Styles.CSSOnly)
            {
                style.AddInheritedStyle("Default", Config.PropertySource.SystemDefault);
                style.AddLinkedFile((style as Styles.CSSOnly).CSSFile, Config.PropertySource.SystemDefault);
            }
            else if (style is Styles.Advanced)
            {
                Style_txt styleParser = new Style_txt();
                style = styleParser.Load((style as Styles.Advanced).ConfigFile, errorList);

                if (style == null)
                {
                    return(null);
                }
            }
            else
            {
                throw new NotImplementedException();
            }


            // Add it to the loaded styles list before processing inherited styles so circular dependencies don't create an
            // infinite loop.

            loadedStyles.Add(style);


            // Now load any inherited styles as needed.

            if (style.Inherits != null)
            {
                for (int i = 0; i < style.Inherits.Count; i++)
                {
                    var inheritStatement = style.Inherits[i];

                    if (inheritStatement.Style == null)
                    {
                        Style inheritedStyle = LocateStyleOnDisk(inheritStatement.Name);

                        if (inheritedStyle == null)
                        {
                            errorList.Add(Locale.Get("NaturalDocs.Engine", "Style.txt.CantFindInheritedStyle(name)", inheritedStyle.Name),
                                          inheritStatement.PropertyLocation);
                        }
                        else
                        {
                            // Have to do it this way because it's a struct.  You can't just modify style.Inherits[i].Style.
                            inheritStatement.Style = LoadStyle(inheritStatement.Name, errorList, inheritStatement.PropertyLocation);
                            style.Inherits[i]      = inheritStatement;
                        }
                    }
                }
            }

            if (errorList.Count == previousErrorCount)
            {
                return(style);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
 /* Function: Add
  * Adds an error occurring in a particular file to the list.
  */
 public void Add(string message, Config.PropertyLocation propertyLocation, string property = null)
 {
     Add(message, propertyLocation.FileName, propertyLocation.LineNumber, propertyLocation.Source, property);
 }
示例#7
0
 /* Function: Matches
  * Whether the error occurs in the passed location.
  */
 public bool Matches(Config.PropertyLocation propertyLocation, string property = null)
 {
     return(Matches(propertyLocation.FileName, propertyLocation.LineNumber, propertyLocation.Source, property));
 }
示例#8
0
 /* Constructor: Error
  * A constructor for an error that occurs in a specific file.
  */
 public Error(string message, Config.PropertyLocation propertyLocation, string property = null)
     : this(message, propertyLocation.FileName, propertyLocation.LineNumber, propertyLocation.Source, property)
 {
 }