Esempio n. 1
0
        private void GenerateFromMod(Mod mod)
        {
            foreach (var def in mod.Content.AllDefs)
            {
                if (!(def is ThingDef thingDef))
                {
                    continue;
                }

                bool shouldAdd = AutogenPageFilter(thingDef);
                if (!shouldAdd)
                {
                    continue;
                }

                WikiPage page = null;
                try
                {
                    page = WikiPage.CreateFromThingDef(thingDef);
                }
                catch (Exception e)
                {
                    Log.Error($"Failed to generate wiki page for {mod.Content?.Name ?? "<no-name-mod>"}'s ThingDef '{thingDef.LabelCap}': {e}");
                }
                this.Pages.Add(page);
            }

            string dir = Path.Combine(mod.Content.RootDir, "Wiki");

            PageParser.AddAllFromDirectory(this, dir);
        }
Esempio n. 2
0
        private void GenerateFromMod(Mod mod)
        {
            var toExclude = GetExcludedDefs(mod);

            foreach (var def in mod.Content.AllDefs)
            {
                if (!(def is ThingDef thingDef))
                {
                    continue;
                }

                if (toExclude.Contains(def.defName))
                {
                    toExclude.Remove(def.defName);
                    continue;
                }

                bool shouldAdd = AutogenPageFilter(thingDef);
                if (!shouldAdd)
                {
                    continue;
                }

                WikiPage page = null;
                try
                {
                    page = WikiPage.CreateFromThingDef(this, thingDef);
                }
                catch (Exception e)
                {
                    Log.Error($"Failed to generate wiki page for {mod.Content?.Name ?? "<no-name-mod>"}'s ThingDef '{thingDef.LabelCap}': {e}");
                }
                this.Pages.Add(page);
            }

            string dir = Path.Combine(mod.Content.RootDir, "Wiki");

            PageParser.AddAllFromDirectory(this, dir);

            if (toExclude.Count != 0)
            {
                Log.Error($"{mod.Content?.Name ?? "<no-name-mod>"}'s Exclude.txt file includes names of defs that do not exist:");
                foreach (var name in toExclude)
                {
                    Log.Error($"  -{name}");
                }
            }
        }