Phase 2 wiki template refactor
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
||||
DefaultTopDataWikiRenderer = "nodebb_tiptap_html"
|
||||
DefaultTopDataWikiLinkStrategy = "preserve_westgate_wiki_links"
|
||||
DefaultTopDataWikiNamespacesFile = "namespaces.yaml"
|
||||
DefaultTopDataWikiTablesFile = "tables.yaml"
|
||||
DefaultTopDataWikiTemplatesDir = "templates"
|
||||
DefaultTopDataWikiManualSectionsDir = "manual-sections"
|
||||
DefaultTopDataWikiStaleDefault = "report"
|
||||
@@ -244,6 +245,7 @@ func (p *Project) EffectiveConfig() EffectiveConfig {
|
||||
Renderer: defaultString(p.Config.TopData.Wiki.Renderer, DefaultTopDataWikiRenderer),
|
||||
LinkStrategy: defaultString(p.Config.TopData.Wiki.LinkStrategy, DefaultTopDataWikiLinkStrategy),
|
||||
NamespacesFile: defaultString(p.Config.TopData.Wiki.NamespacesFile, DefaultTopDataWikiNamespacesFile),
|
||||
TablesFile: defaultString(p.Config.TopData.Wiki.TablesFile, DefaultTopDataWikiTablesFile),
|
||||
TemplatesDir: defaultString(p.Config.TopData.Wiki.TemplatesDir, DefaultTopDataWikiTemplatesDir),
|
||||
ManualSectionsDir: defaultString(p.Config.TopData.Wiki.ManualSectionsDir, DefaultTopDataWikiManualSectionsDir),
|
||||
TitlePrefixMinLength: defaultInt(p.Config.TopData.Wiki.TitlePrefixMinLength, DefaultTopDataWikiTitlePrefixMinLength),
|
||||
@@ -479,6 +481,7 @@ func markMissingDefaults(provenance ConfigProvenance) {
|
||||
"topdata.wiki.renderer": DefaultTopDataWikiRenderer,
|
||||
"topdata.wiki.link_strategy": DefaultTopDataWikiLinkStrategy,
|
||||
"topdata.wiki.namespaces_file": DefaultTopDataWikiNamespacesFile,
|
||||
"topdata.wiki.tables_file": DefaultTopDataWikiTablesFile,
|
||||
"topdata.wiki.templates_dir": DefaultTopDataWikiTemplatesDir,
|
||||
"topdata.wiki.manual_sections_dir": DefaultTopDataWikiManualSectionsDir,
|
||||
"topdata.wiki.title_prefix_min_length": "3",
|
||||
|
||||
@@ -228,6 +228,7 @@ type TopDataWikiConfig struct {
|
||||
Renderer string `json:"renderer" yaml:"renderer"`
|
||||
LinkStrategy string `json:"link_strategy" yaml:"link_strategy"`
|
||||
NamespacesFile string `json:"namespaces_file" yaml:"namespaces_file"`
|
||||
TablesFile string `json:"tables_file" yaml:"tables_file"`
|
||||
TemplatesDir string `json:"templates_dir" yaml:"templates_dir"`
|
||||
ManualSectionsDir string `json:"manual_sections_dir" yaml:"manual_sections_dir"`
|
||||
TitlePrefixMinLength int `json:"title_prefix_min_length" yaml:"title_prefix_min_length"`
|
||||
@@ -514,6 +515,7 @@ func (p *Project) ValidateLayout() error {
|
||||
"topdata.wiki.state_file": p.Config.TopData.Wiki.StateFile,
|
||||
"topdata.wiki.deploy_manifest": p.Config.TopData.Wiki.DeployManifest,
|
||||
"topdata.wiki.deploy_edit_summary": p.Config.TopData.Wiki.DeployEditSummary,
|
||||
"topdata.wiki.tables_file": p.Config.TopData.Wiki.TablesFile,
|
||||
"extract.layout": p.Config.Extract.Layout,
|
||||
"extract.hak_discovery": p.Config.Extract.HAKDiscovery,
|
||||
"autogen.cache.root": p.Config.Autogen.Cache.Root,
|
||||
@@ -546,6 +548,7 @@ func (p *Project) ValidateLayout() error {
|
||||
failures = append(failures, validateRelativePath("topdata.wiki.deploy_manifest", effective.TopData.Wiki.DeployManifest)...)
|
||||
failures = append(failures, validateTreeRootPath("topdata.wiki.source", effective.TopData.Wiki.Source)...)
|
||||
failures = append(failures, validateRelativePath("topdata.wiki.namespaces_file", effective.TopData.Wiki.NamespacesFile)...)
|
||||
failures = append(failures, validateRelativePath("topdata.wiki.tables_file", effective.TopData.Wiki.TablesFile)...)
|
||||
failures = append(failures, validateTreeRootPath("topdata.wiki.templates_dir", effective.TopData.Wiki.TemplatesDir)...)
|
||||
failures = append(failures, validateTreeRootPath("topdata.wiki.manual_sections_dir", effective.TopData.Wiki.ManualSectionsDir)...)
|
||||
failures = append(failures, validateRelativePath("autogen.cache.root", effective.Autogen.Cache.Root)...)
|
||||
|
||||
@@ -262,6 +262,7 @@ topdata:
|
||||
renderer: nodebb_tiptap_html
|
||||
link_strategy: preserve_westgate_wiki_links
|
||||
namespaces_file: namespaces.yaml
|
||||
tables_file: custom-tables.yaml
|
||||
templates_dir: templates
|
||||
manual_sections_dir: manual-sections
|
||||
deploy_manifest: wiki-manifest.json
|
||||
@@ -319,6 +320,9 @@ autogen:
|
||||
if got, want := effective.TopData.Wiki.NamespacesFile, "namespaces.yaml"; got != want {
|
||||
t.Fatalf("expected wiki namespaces file %q, got %q", want, got)
|
||||
}
|
||||
if got, want := effective.TopData.Wiki.TablesFile, "custom-tables.yaml"; got != want {
|
||||
t.Fatalf("expected wiki tables file %q, got %q", want, got)
|
||||
}
|
||||
if got, want := effective.TopData.Wiki.TemplatesDir, "templates"; got != want {
|
||||
t.Fatalf("expected wiki templates dir %q, got %q", want, got)
|
||||
}
|
||||
@@ -758,6 +762,7 @@ func TestValidateLayoutRejectsInvalidTopDataWikiConfig(t *testing.T) {
|
||||
Renderer: "dokuwiki",
|
||||
LinkStrategy: "rewrite_links",
|
||||
NamespacesFile: "../namespaces.yaml",
|
||||
TablesFile: "../tables.yaml",
|
||||
TemplatesDir: ".",
|
||||
ManualSectionsDir: "../manual",
|
||||
StalePages: TopDataWikiStalePagesConfig{
|
||||
@@ -778,6 +783,7 @@ func TestValidateLayoutRejectsInvalidTopDataWikiConfig(t *testing.T) {
|
||||
"topdata.wiki.renderer",
|
||||
"topdata.wiki.link_strategy",
|
||||
"topdata.wiki.namespaces_file",
|
||||
"topdata.wiki.tables_file",
|
||||
"topdata.wiki.templates_dir",
|
||||
"topdata.wiki.manual_sections_dir",
|
||||
"topdata.wiki.stale_pages.default",
|
||||
|
||||
Reference in New Issue
Block a user