Skip to content

Latest commit

 

History

History
132 lines (80 loc) · 4.48 KB

CONTRIBUTING.md

File metadata and controls

132 lines (80 loc) · 4.48 KB

You want to make changes to the syntax highlighting and don't know where to start and how to see the impact of your changes? This document should get you started.

It's a bit clunky. I apologize. There isn't a whole lot of people who write their own syntax highlighting grammars.

Overview

Much like microsoft/TypeScript-TmLanguage, the .tmLanguage files are maintained in YAML to make them easier to consume and edit by humans.

The *.tmLanguage.json files are generated by our build and are not maintained manually.

Testing in Visual Studio Code

Setup

Visual Studio Code only lets you debug extensions, so we'll use theme-check-vscode for this. Since this repository is a git submodule of theme-check-vscode.

  1. Clone theme-check-vscode.
git clone --recurse-submodules https://github.com/Shopify/theme-check-vscode

NOTE: If you forgot the --recurse-submodules flag, you can fix it with the following command at the root of the theme-check-vscode directory:

git submodule update --init --recursive
  1. Install dependencies
cd theme-check-vscode
yarn install

Visual development

  1. In a terminal, at the root of theme-check-vscode, build the extension:

    cd path/to/theme-check-vscode
    npm run build
  2. Start the YAML->JSON syntax highlighting watcher:

    npm run dev:syntax
  3. In VS Code, at the root of theme-check-vscode, open src/extension.js.

  4. Press F5 (or Run > Start Debugging menu option).

  5. Select the VS Code Extension Development option.

vscode extension development

  1. In the [Extension Development Host] window, open the theme-check-vscode/syntaxes/test folder. Open any *.liquid file.

  2. In the other window, make modifications to any of the language grammar files (the YAML files).

  3. In the [Extension Development Host] window, hit ⌘+R to refresh.

    You should see the result of your changes.

  4. Repeat step 7-8 until satisfied.

It is highly recommended you setup VS Code's Scope inspector. This will greatly help you debug your changes.

Unit Testing

Turns out this is kind of hard to test. The folks at Microsoft have a text-based workflow that involves committing "baseline" outputs for a series of files. We're doing the same here.

  1. In a terminal, go into the theme-check-vscode/syntaxes folder.
cd path/to/theme-check-vscode
cd syntaxes
  1. Make changes to any of the YAML files.

  2. Generate new traces:

yarn test
  1. Inspect the result of the theme-check-vsode/syntaxes/test/generated/*.baseline.txt files.

  2. Look at the diff between your changes and the accepted baselines:

yarn test:diff
  1. Repeat step 2–5 until satisfied.

  2. Accept and commit the changes as the new baselines.

yarn test:accept
yarn add tests/baselines

Helpful Resources