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

Add validation schema for configuration file #12

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

fruzitent
Copy link
Contributor

@fruzitent fruzitent commented Dec 20, 2023

Things to consider:

  • Generate schema from Python dataclass definition using pydantic or similar package.

@BlankSpruce
Copy link
Owner

I'll take a look at this PR on the weekend. Could you give me a hint how to use such schema? What does it solve?

@fruzitent
Copy link
Contributor Author

fruzitent commented Dec 20, 2023

I'll take a look at this PR on the weekend. Could you give me a hint how to use such schema? What does it solve?

  • IDE integration;
  • Validation of properties in user config file.

Header on the first line, tells LSP which schema to use.

  • json

    { "$schema": "https://" }
  • toml

    #:schema https://
  • yml

    # yaml-language-server: $schema=https://

Quite a few examples of these can be found at https://schemastore.org.

@BlankSpruce BlankSpruce force-pushed the dev branch 3 times, most recently from 196013b to d7100de Compare December 22, 2023 15:46
Co-Authored-By: Blank Spruce <32396809+BlankSpruce@users.noreply.github.com>
@BlankSpruce
Copy link
Owner

BlankSpruce commented Dec 22, 2023

Although I don't use this tooling myself and I don't expect to change .gersemirc per project too often I rather like the idea of making configuration more user-friendly. I've reimplemented most of this change (description below) but I've still made you the main author of this change.

Significant changes to your original version:

  • I used metadata achievable with dataclasses.field and I implemented something similar for Enum
  • As per your recommendation I used pydantic to implement the test that will warn me about deviation to schema and example file whenever I touch something around there. While it wasn't very helpful with enumeration (it wasn't as detailed as your original schema) it made a difference for definitions argument (format part):
    "definitions": {
      "default": [],
      "description": "Files or directories containing custom command definitions (functions or macros). If only - is provided custom definitions, if there are any, are taken from stdin instead. Commands from not deprecated CMake native modules don't have to be provided. See: https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html",
      "items": { "format": "path", "type": "string" },
      "title": "Definitions",
      "type": "array"
    },
  • I added yaml header to default configuration produced by --default-config.
  • I squashed your changes into one commit. I'm glad though you took the approach of splitting the work into meaningful commits. :)

Once I solve the issue #13 I hope to release new version with your changes. Thank you for your contribution.

@BlankSpruce BlankSpruce merged commit de8a381 into BlankSpruce:master Dec 22, 2023
8 checks passed
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.

2 participants