Add configurable topdata wiki visibility policy (#4)

## Summary
- add YAML-backed generated wiki visibility policies for topdata datasets
- centralize page and reference eligibility through a visibility index
- cover eligibility helpers, metadata precedence, derived feat sets, and link suppression with toolkit tests

## Verification
- go test ./...
- module ./validate-topdata.sh with the feature toolkit binary
- module ./build-wiki.sh --force with the feature toolkit binary

Companion module branch: codex-wiki-visibility.

Reviewed-on: https://gitea.westgate.pw/ShadowsOverWestgate/sow-tools/pulls/4
Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit is contained in:
2026-05-21 13:45:06 +02:00
committed by archvillainette
parent 499d7773cd
commit 057ed19276
8 changed files with 779 additions and 6 deletions
+25 -1
View File
@@ -113,6 +113,8 @@ type wikiContext struct {
templateDir string
wikiTablesPath string
wikiTableDefinitions map[string]wikiTableDefinition
visibilityPolicy *wikiVisibilityDefinitions
visibleWikiKeys map[string]bool
}
func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progress func(string)) (wikiResult, error) {
@@ -152,6 +154,10 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
return wikiResult{}, err
}
ctx.wikiTableDefinitions = tableDefinitions
visibilityPath := filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.VisibilityFile))
if err := ctx.loadWikiVisibility(visibilityPath); err != nil {
return wikiResult{}, err
}
if err := os.RemoveAll(outputDir); err != nil {
return wikiResult{}, fmt.Errorf("clean wiki output: %w", err)
@@ -746,6 +752,9 @@ func (ctx *wikiContext) shouldGeneratePage(category, key string, row map[string]
if row == nil {
return false
}
if ctx.visibilityPolicy != nil {
return ctx.canReferenceWikiKey(key)
}
override := ctx.wikiGenerateOverride(row)
if override == "0" {
return false
@@ -790,6 +799,21 @@ func (ctx *wikiContext) shouldGeneratePage(category, key string, row map[string]
}
}
func (ctx *wikiContext) wikiRowCanRender(category string, row map[string]any) bool {
if row == nil {
return false
}
name := ctx.resolveRowName(category, row)
description := ctx.resolveRowDescription(category, row)
switch category {
case "classes", "spells":
if isToolLike(name, stringField(row, "Label"), stringField(row, "Constant")) {
return false
}
}
return name != "" && description != ""
}
func (ctx *wikiContext) renderPage(category, key string, row map[string]any, title string) (string, error) {
manualSections := ctx.manualSections
if len(manualSections) == 0 {
@@ -1000,7 +1024,7 @@ func (ctx *wikiContext) renderRaceFeatList(row map[string]any) string {
func (ctx *wikiContext) renderReference(value any, idToKey map[int]string, nameResolver func(string) string) string {
key := resolveReferenceKey(value, idToKey)
if key == "" {
if key == "" || !ctx.canReferenceWikiKey(key) {
return ""
}
name := nameResolver(key)