Skip to content

Development hints

Matouš Borák edited this page Feb 27, 2024 · 9 revisions

YAML compilation

The grammar itself is defined in YAML files. They need to be converted to JSON before VS Code can work with them. First, install the conversion tool as a dev dependency:

npm install js-yaml --save-dev

Then:

npx js-yaml syntaxes/slim.tmLanguage.yaml > syntaxes/slim.tmLanguage.json
npx js-yaml syntaxes/interpolated-ruby.yaml > syntaxes/interpolated-ruby.json

Tests

Unit tests are in tests/unit_tests.slim.

Install the vscode-tmgrammar-test tool.

Run tests and inspect the results.txt file:

npx vscode-tmgrammar-test \
    -g syntaxes/slim.tmLanguage.json \
    -g tests/support_grammars/html.tmLanguage.json \
    -g tests/support_grammars/ruby.cson.json \
    -g tests/support_grammars/coffeescript.tmLanguage.json \
    -g tests/support_grammars/css.tmLanguage.json \
    -g tests/support_grammars/less.tmLanguage.json \
    -g tests/support_grammars/erb.cson.json \
    -g tests/support_grammars/JavaScript.tmLanguage.json \
    -g tests/support_grammars/markdown.tmLanguage.json \
    -g tests/support_grammars/scss.tmLanguage.json \
    -g tests/support_grammars/sass.tmLanguage.json \
    -g tests/support_grammars/html-derivative.tmLanguage.json \
    tests/unit_tests.slim > results.txt

The support grammars for Ruby and ERB were taken from the vscode-ruby-lsp project. The other ones from various other sources.

There is also the tests/test_suite.slim file that can be opened and inspected visually. It has been extracted from the Literate tests in the Slim repository.

Slim output test

Useful to find out whether some syntax is supported by Slim itself.

echo "markdown:
  <br aa=\"#{bb}\">" | slimrb -s -l '{ bb: "something" }'

Pack extension

npx vsce package

Changelog tips

See Keep a Changelog for recommendations on how to structure this file.

Clone this wiki locally