Skip to content
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

Create jsonschema for configuration file #747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zidhuss
Copy link

@zidhuss zidhuss commented Jun 1, 2024

This PR adds a JSON Schema that describes the .swift-format configuration file.

When this schema is referenced, It serves as a form of documentation and provides auto-completion and validation for configuration options (in editors that support it).

SCR-20240601-rhbx

Ideally you'd want to generate this from the code as done in #615. However the documentation for the other configuration options isn't automated from the comments leading to out of date documentation (#455).

My aim is to get this schema in the schema store so that editors automatically associate .swift-format files with it.

Copy link
Contributor

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review @zidhuss. Adding a reference for the .swift-format file is great!

I assume you wrote the schema by hand, right? I think it would be great if we had a script to make sure it’s in sync with Configuration.md. Maybe we could even generate Configuraiton.md based on the JSON schema. Could you be interested in writing such as script (ideally in Swift but really any scripting language would be fine)?

@allevato
Copy link
Member

It would be great to generate this from the doc comments in the Configuration struct (and the other structs that it contains) like you mentioned was done for rules in #615, and also generate the Markdown from that (or alternatively, just abandon Configuration.md in favor of DocC comments). Otherwise, if we just check in a hand-written version of this file, it will go stale the same way the Markdown has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants