-
Notifications
You must be signed in to change notification settings - Fork 304
Generate JSON Schema and Markdown doc for .sourcekit-lsp/config.json
#1849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c778056
to
80e9e9b
Compare
@swift-ci test |
Providing a JSON schema for the configuration file should improve the developer experience thanks to better auto-completion and diagnostics support provided by some editors. Additionally, we have been manually maintaining the configuration file format documentation in `Documentation/Configuration File.md`, but it's easy for the documentation to get out of sync with the actual schema. This change introduces a new tool, `ConfigSchemaGen`, that generates a JSON schema and a Markdown document for the configuration file based on the Swift type definitions in the `SKOptions` module by using swift-syntax.
80e9e9b
to
9b07134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Yuta. I look forward to Configuration File.md
not getting out of sync anymore.
Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/OptionSchema.swift
Outdated
Show resolved
Hide resolved
Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/OptionSchema.swift
Outdated
Show resolved
Hide resolved
Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/OptionSchema.swift
Outdated
Show resolved
Hide resolved
Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/OptionSchema.swift
Outdated
Show resolved
Hide resolved
Utilities/ConfigSchemaGen/Sources/ConfigSchemaGen/OptionSchema.swift
Outdated
Show resolved
Hide resolved
@swift-ci test |
… instead of a string
The `markdownEnumDescriptions` field in JSON Schema is supposed to be an array of descriptions but was incorrectly encoded as a dictionary.
b39ea17
to
185438c
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for migrating this to the SourceKitLSPDevUtils
package. I have a few comments around access levels, otherwise looks great.
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/ConfigSchemaGen/OptionDocument.swift
Outdated
Show resolved
Hide resolved
SourceKitLSPDevUtils/Sources/SourceKitLSPDevUtils/Commands/VerifyConfigSchema.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@swift-ci Please test |
@swift-ci Please test Windows |
Heh, thanks @kateinoigakukun! I noticed the discrepancy in docs in my PR but only fixed it manually - generating much better 🙇♂️! |
Providing a JSON schema for the configuration file should improve the developer experience thanks to better auto-completion and diagnostics support provided by some editors.
Additionally, we have been manually maintaining the configuration file format documentation in
Documentation/Configuration File.md
, but it's easy for the documentation to get out of sync with the actual schema.This change introduces a new tool,
ConfigSchemaGen
, that generates a JSON schema and a Markdown document for the configuration file based on the Swift type definitions in theSKOptions
module by using swift-syntax.Plan for vscode-swift integration
VSCode exposes a way to feed a JSON Schema definition for an opening file based on file name:
https://code.visualstudio.com/api/references/contribution-points#contributes.jsonValidation
Since the schema URL can be a local path and the configuration field can be modified dynamically by extension, we can specify a schema file shipped in the selected Swift toolchain. Or to simplify packaging flow, we can embed the schema file within the sourcekit-lsp binary and provide a CLI interface to print it, then vscode-swift can write it out in its extension storage and feed the file to VSCode.