From 325e120317a1344947981f373970a48becd06dfc Mon Sep 17 00:00:00 2001 From: Auguste Rame <19855629+SuperAuguste@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:53:19 -0400 Subject: [PATCH] site-config: Make symbols not required in syntaxHighlighting (#57276) * site-config: Make symbols not required in syntaxHighlighting * add nil checks --- cmd/symbols/parser/config.go | 2 +- internal/ctags_config/ctags_config.go | 2 +- schema/README.md | 2 +- schema/schema.go | 2 +- schema/site.schema.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/symbols/parser/config.go b/cmd/symbols/parser/config.go index e3fab366566..5e4c2ed2ae6 100644 --- a/cmd/symbols/parser/config.go +++ b/cmd/symbols/parser/config.go @@ -27,7 +27,7 @@ func init() { // Validation only: Do NOT set any values in the configuration in this function. conf.ContributeValidator(func(c conftypes.SiteConfigQuerier) (problems conf.Problems) { configuration := c.SiteConfig().SyntaxHighlighting - if configuration == nil { + if configuration == nil || configuration.Symbols == nil { return nil } diff --git a/internal/ctags_config/ctags_config.go b/internal/ctags_config/ctags_config.go index 55be879d2cd..a18491fe211 100644 --- a/internal/ctags_config/ctags_config.go +++ b/internal/ctags_config/ctags_config.go @@ -104,7 +104,7 @@ func CreateEngineMap(siteConfig schema.SiteConfiguration) map[string]ParserType // Set any relevant overrides configuration := siteConfig.SyntaxHighlighting - if configuration != nil { + if configuration != nil && configuration.Symbols != nil { for lang, engine := range configuration.Symbols.Engine { lang = languages.NormalizeLanguage(lang) diff --git a/schema/README.md b/schema/README.md index dd0741bb133..f89c24949e7 100644 --- a/schema/README.md +++ b/schema/README.md @@ -11,7 +11,7 @@ Sourcegraph uses the following JSON Schemas: # Modifying a schema 1. Edit the `*.schema.json` file in this directory. -1. Run `bazel run :write_generated_schema`. +1. Run `bazel run //schema:write_generated_schema`. 1. Commit the changes to both files. 1. Run `sg start` to automatically update TypeScript schema files. diff --git a/schema/schema.go b/schema/schema.go index c5e61fd8e54..24c45e36516 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -2978,7 +2978,7 @@ type SyntaxHighlighting struct { Engine SyntaxHighlightingEngine `json:"engine"` Languages SyntaxHighlightingLanguage `json:"languages"` // Symbols description: Configure symbol generation - Symbols SymbolConfiguration `json:"symbols"` + Symbols *SymbolConfiguration `json:"symbols,omitempty"` } type SyntaxHighlightingEngine struct { // Default description: The default syntax highlighting engine to use diff --git a/schema/site.schema.json b/schema/site.schema.json index 2ddc2d11524..a1b8ccd4bf7 100644 --- a/schema/site.schema.json +++ b/schema/site.schema.json @@ -877,7 +877,7 @@ "title": "SyntaxHighlighting", "description": "Syntax highlighting configuration", "type": "object", - "required": ["engine", "languages", "symbols"], + "required": ["engine", "languages"], "properties": { "engine": { "title": "SyntaxHighlightingEngine",