Phase 2 wiki template refactor
This commit is contained in:
@@ -89,27 +89,30 @@ type wikiTable struct {
|
||||
}
|
||||
|
||||
type wikiContext struct {
|
||||
dialog map[string]string
|
||||
rowsByKey map[string]map[string]any
|
||||
featRows map[string]map[string]any
|
||||
featIDToKey map[int]string
|
||||
skillRows map[string]map[string]any
|
||||
skillIDToKey map[int]string
|
||||
spellRows map[string]map[string]any
|
||||
baseitemRows map[string]map[string]any
|
||||
classRows map[string]map[string]any
|
||||
classIDToKey map[int]string
|
||||
raceRows map[string]map[string]any
|
||||
raceIDToKey map[int]string
|
||||
masterfeatRows map[string]map[string]any
|
||||
classFeatTables map[string]wikiTable
|
||||
classSkillTables map[string]wikiTable
|
||||
classBonusTables map[string]wikiTable
|
||||
raceFeatTables map[string]wikiTable
|
||||
statuses map[string]map[string]string
|
||||
implementedFeats map[string]struct{}
|
||||
manualSections []wikiManualSection
|
||||
templateDir string
|
||||
dialog map[string]string
|
||||
rowsByKey map[string]map[string]any
|
||||
featRows map[string]map[string]any
|
||||
featIDToKey map[int]string
|
||||
skillRows map[string]map[string]any
|
||||
skillIDToKey map[int]string
|
||||
spellRows map[string]map[string]any
|
||||
baseitemRows map[string]map[string]any
|
||||
classRows map[string]map[string]any
|
||||
classIDToKey map[int]string
|
||||
raceRows map[string]map[string]any
|
||||
raceIDToKey map[int]string
|
||||
masterfeatRows map[string]map[string]any
|
||||
classFeatTables map[string]wikiTable
|
||||
classSkillTables map[string]wikiTable
|
||||
classBonusTables map[string]wikiTable
|
||||
classSaveTables map[string]wikiTable
|
||||
raceFeatTables map[string]wikiTable
|
||||
statuses map[string]map[string]string
|
||||
implementedFeats map[string]struct{}
|
||||
manualSections []wikiManualSection
|
||||
templateDir string
|
||||
wikiTablesPath string
|
||||
wikiTableDefinitions map[string]wikiTableDefinition
|
||||
}
|
||||
|
||||
func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progress func(string)) (wikiResult, error) {
|
||||
@@ -143,6 +146,12 @@ func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progres
|
||||
manualSections := loadWikiManualSections(p)
|
||||
ctx.manualSections = manualSections
|
||||
ctx.templateDir = filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.TemplatesDir), "pages")
|
||||
ctx.wikiTablesPath = filepath.Join(p.TopDataWikiSourceDir(), filepath.FromSlash(p.EffectiveConfig().TopData.Wiki.TablesFile))
|
||||
tableDefinitions, err := loadWikiTableDefinitions(ctx.wikiTablesPath)
|
||||
if err != nil {
|
||||
return wikiResult{}, err
|
||||
}
|
||||
ctx.wikiTableDefinitions = tableDefinitions
|
||||
|
||||
if err := os.RemoveAll(outputDir); err != nil {
|
||||
return wikiResult{}, fmt.Errorf("clean wiki output: %w", err)
|
||||
@@ -535,6 +544,10 @@ func loadWikiContext(dataDir, sourceDir string) (*wikiContext, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classSaveTables, err := loadWikiTables(filepath.Join(dataDir, "classes", "savthr"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := &wikiContext{
|
||||
dialog: dialog,
|
||||
@@ -544,6 +557,7 @@ func loadWikiContext(dataDir, sourceDir string) (*wikiContext, error) {
|
||||
classFeatTables: classFeatTables,
|
||||
classSkillTables: classSkillTables,
|
||||
classBonusTables: classBonusTables,
|
||||
classSaveTables: classSaveTables,
|
||||
}
|
||||
if ok {
|
||||
ctx.featRows, ctx.featIDToKey = rowsByKeyAndID(featDataset.Rows)
|
||||
@@ -672,6 +686,9 @@ func loadWikiTables(root string) (map[string]wikiTable, error) {
|
||||
Rows: rows,
|
||||
}
|
||||
tables[table.OutputStem] = table
|
||||
if table.Key != "" {
|
||||
tables[table.Key] = table
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user