Skip to content

Commit 2bf7da8

Browse files
committed
doc: Update generator documentation inside the repo
1 parent 6f35098 commit 2bf7da8

File tree

9 files changed

+120
-54
lines changed

9 files changed

+120
-54
lines changed

packages/generator-langium/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export class LangiumGenerator extends Generator {
184184
'.eslintrc.json',
185185
'tsconfig.json',
186186
'tsconfig.build.json',
187+
'README.md',
187188
'.vscode'
188189
];
189190
for (const path of baseFiles) {
@@ -200,7 +201,7 @@ export class LangiumGenerator extends Generator {
200201
const languageFiles = [
201202
'package.json',
202203
'langium-config.json',
203-
'langium-quickstart.md',
204+
'README.md',
204205
'tsconfig.json',
205206
'tsconfig.src.json',
206207
'vitest.config.ts',
@@ -241,6 +242,7 @@ export class LangiumGenerator extends Generator {
241242
const cliFiles = [
242243
'package.json',
243244
'tsconfig.json',
245+
'README.md',
244246
'bin',
245247
'src'
246248
];
@@ -260,6 +262,7 @@ export class LangiumGenerator extends Generator {
260262
const webFiles = [
261263
'package.json',
262264
'language-configuration.json',
265+
'README.md',
263266
'tsconfig.json',
264267
'index.html',
265268
'vite.config.ts',
@@ -282,6 +285,7 @@ export class LangiumGenerator extends Generator {
282285
const extensionFiles = [
283286
'.vscodeignore',
284287
'esbuild.mjs',
288+
'langium-quickstart.md',
285289
'language-configuration.json',
286290
'package.json',
287291
'tsconfig.json',
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Workspace overview
2+
3+
Depending on the selection during the project generation you will have one or more packages contained in the packages directory. Check the :
4+
5+
- [packages/language](./packages/language/README.md) is always available and contains the language definition.
6+
- [packages/cli](./packages/cli/README.md) *Optional* Is only available if you chose to use the command-line interface.
7+
- [packages/extension](./packages/extension/langium-quickstart.md) *Optional* Contains the VSCode extension if you chose to create it.
8+
- [packages/web](./packages/web/README.md) *Optional* if selected contains the language server running in a web browser and a monaco-editor with language support similar to the onm from VSCode.
9+
10+
## What's in the folder?
11+
12+
- [.eslintrc.json](.eslintrc.json) - Configuration file for eslint
13+
- [.gitignore](.gitignore) - Files ignored by git
14+
- [package.json](./package.json) - The manifest file the main workspace package
15+
- [tsconfig.json](./tsconfig.json) - The base TypeScript compiler configuration
16+
- [tsconfig.build.json](./package.json) - Configuration used to build the complete source code.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Command-line interface (CLI)
2+
3+
Check [this part](https://langium.org/docs/learn/minilogo/customizing_cli/) of the Langium Minilogo Tutorial as a useful guide to the CLI.
4+
5+
## What's in the folder?
6+
7+
- [package.json](./package.json) - The manifest file of your cli package.
8+
- [tsconfig.src.json](./tsconfig.src.json) - The package specific TypeScript compiler configuration extending the [base config](../../tsconfig.json)
9+
- [tsconfig.json](./tsconfig.json) - TypeScript compiler configuration options required for proper functionality of VSCode.
10+
- [src/cli/main.ts](src/cli/main.ts) - the entry point of the command line interface (CLI) of your language.
11+
- [src/cli/generator.ts](src/cli/generator.ts) - the code generator used by the CLI to write output files from DSL documents.
12+
- [src/cli/util.ts](src/cli/util.ts) - utility code for the CLI.
13+
14+
If you selected the test option as well, then you have the following for file as well:
15+
16+
- [tsconfig.test.json](./tsconfig.test.json) - The package specific TypeScript compiler configuration for the unit tests extending the [tsconfig.src.config](tsconfig.src.json)
17+
- [test/linking.test.ts](test/linking.test.ts) - Unit tests checking linking.
18+
- [test/parsing.test.ts](test/parsing.test.ts) - Unit tests regarding parsing.
19+
- [test/validating.test.ts](test/validating.test.ts) - Unit tests regarding validation.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Langium VS Code Extension
2+
3+
Welcome to your Langium VSCode extension. This folder contains all necessary files for your language extension.
4+
5+
## What's in the folder?
6+
7+
- [package.json](./package.json) - the manifest file in which you declare your language support.
8+
- [tsconfig.json](./tsconfig.json) - The packages specific TypeScript compiler configuration extending the [base config](../../tsconfig.json)
9+
- [esbuid.mjs](esbuild.mjs) - Configuration file for esbuild that is used to create the VSCode extension bundle.
10+
- [language-configuration.json](language-configuration.json) - the language configuration used in the VS Code editor, defining the tokens that are used for comments and brackets.
11+
- [src/language/main.ts](src/language/main.ts) - the entry point of the language server process.
12+
- [src/extension/main.ts](src/extension/main.ts) - the main code of the extension, which is responsible for launching a language server and client.
13+
14+
## Get up and running straight away
15+
16+
- Run `npm run langium:generate` to generate TypeScript code from the grammar definition.
17+
- Run `npm run build` to compile all TypeScript code.
18+
- Press `F5` to open a new window with your extension loaded.
19+
- Create a new file with a file name suffix matching your language.
20+
- Verify that syntax highlighting, validation, completion etc. are working as expected.
21+
- Run `node ./bin/cli` to see options for the CLI; `node ./bin/cli generate <file>` generates code for a given DSL file.
22+
23+
## Make changes
24+
25+
- Run `npm run watch` to have the TypeScript compiler run automatically after every change of the source files.
26+
- Run `npm run langium:watch` to have the Langium generator run automatically after every change of the grammar declaration.
27+
- You can relaunch the extension from the debug toolbar after making changes to the files listed above.
28+
- You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
29+
30+
## Install your extension
31+
32+
- To start using your extension with VS Code, copy it into the `<user home>/.vscode/extensions` folder and restart Code.
33+
- To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension.
34+
35+
## To Go Further
36+
37+
Documentation about the Langium framework is available at <https://langium.org>

packages/generator-langium/templates/packages/language/.vscode-extensions.json

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The mandatory language package
2+
3+
As a good entry point to our documentation, please use to this [guide](https://langium.org/docs/learn/workflow/write_grammar/).
4+
5+
## What's in the folder?
6+
7+
- [package.json](./package.json) - The manifest file of your language package.
8+
- [tsconfig.json](./tsconfig.json) - The packages specific TypeScript compiler configuration extending the [base config](../../tsconfig.json)
9+
- [src/<%= language-id %>.langium](src/<%= language-id %>.langium) - the grammar definition of your language
10+
- [src/<%= language-id %>-module.ts](src/<%= language-id %>-module.ts) - the dependency injection module of your language implementation. Use this to register overridden and added services.
11+
- [src/<%= language-id %>-validator.ts](src/<%= language-id %>-validator.ts) - an example validator. You should change it to reflect the semantics of your language
12+
- [src/generated/ast.ts](src/generated/ast.ts) - Generated AST
13+
- [src/generated/grammar.ts](src/generated/grammar.ts) - Generated Grammar
14+
- [src/generated/module.ts](src/generated/module.ts) - Generated Module
15+
- [src/syntaxes/<%= language-id %>.monarch.ts](src/syntaxes/<%= language-id %>.monarch.ts) - Monarch based syntax highlighting instructions
16+
- [syntaxes/<%= language-id %>.tmLanguage.json](syntaxes/<%= language-id %>.tmLanguage.json) - Textmate based syntax highlighting instructions
17+
- [src/index.ts](src/index.ts) Defines what is exported to other packages.

packages/generator-langium/templates/packages/language/langium-quickstart.md

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Web-based editor and language server
2+
3+
How the web based editor works is well defined [here](https://langium.org/docs/learn/minilogo/langium_and_monaco).
4+
5+
## What's in the folder?
6+
7+
- [index.html](index.html) - Entry page that let's you decide which web editor version is used.
8+
- [language-configuration.json](language-configuration.json) - the language configuration used in the web editor, defining the tokens that are used for comments and brackets.
9+
- [package.json](./package.json) - The manifest file of your web editor package.
10+
- [src/main-browser.ts](src/main-browser.ts) - The the language server running in a web worker.
11+
- [src/setupClassic.ts](src/setupClassic.ts) - Create monaco-editor with classic configuration (monarch sytax highlighting)
12+
- [src/setupCommon.ts](src/setupCommon.ts) - Common settings for monaco-editor
13+
- [src/setupExtended.ts](src/setupExtended.ts) - Create monaco-editor with extended configuration (textmate sytax highlighting)
14+
- [static/monacoClassic.html](static/monacoClassic.html) - Page for classic monaco-editor
15+
- [static/monacoExtended.html](static/monacoExtended.html) - Page for extended monaco-editor
16+
- [static/styles.css](static/styles.css) - Stylesheets used by the HTML pages
17+
- [tsconfig.json](./tsconfig.json) - The packages specific TypeScript compiler configuration extending the [base config](../../tsconfig.json)
18+
- [vite.config.ts](vite.config.ts) - Vite/rollup production build instructions

packages/generator-langium/test/yeoman-generator.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@ describe('Check yeoman generator works', () => {
3333
targetRoot + '/tsconfig.build.json',
3434
targetRoot + '/tsconfig.json',
3535
targetRoot + '/package.json',
36+
targetRoot + '/README.md',
3637
targetRoot + '/.vscode/extensions.json',
3738
targetRoot + '/.vscode/launch.json',
3839
targetRoot + '/.vscode/tasks.json',
40+
targetRoot + '/packages/language/README.md',
3941
targetRoot + '/packages/language/src/hello-world-module.ts',
4042
targetRoot + '/packages/language/src/hello-world-validator.ts',
4143
targetRoot + '/packages/language/src/hello-world.langium',
4244
targetRoot + '/packages/language/src/syntaxes/hello-world.monarch.ts',
4345
targetRoot + '/packages/language/src/generated/ast.ts',
4446
targetRoot + '/packages/language/src/generated/grammar.ts',
45-
targetRoot + '/packages/language/src/generated/module.ts'
47+
targetRoot + '/packages/language/src/generated/module.ts',
48+
targetRoot + '/packages/language/syntaxes/hello-world.tmLanguage.json'
4649
];
4750

4851
const filesTest = (targetRoot: string) => [
@@ -57,6 +60,7 @@ describe('Check yeoman generator works', () => {
5760
targetRoot + '/packages/cli/src/util.ts',
5861
targetRoot + '/packages/cli/src/generator.ts',
5962
targetRoot + '/packages/cli/src/main.ts',
63+
targetRoot + '/packages/cli/README.md',
6064
targetRoot + '/packages/cli/package.json',
6165
targetRoot + '/packages/cli/tsconfig.json'
6266
];
@@ -73,14 +77,16 @@ describe('Check yeoman generator works', () => {
7377
targetRoot + '/packages/web/language-configuration.json',
7478
targetRoot + '/packages/web/package.json',
7579
targetRoot + '/packages/web/tsconfig.json',
76-
targetRoot + '/packages/web/vite.config.ts'
80+
targetRoot + '/packages/web/vite.config.ts',
81+
targetRoot + '/packages/web/README.md',
7782
];
7883

7984
const filesExtension = (targetRoot: string) => [
8085
targetRoot + '/packages/extension/src/extension/main.ts',
8186
targetRoot + '/packages/extension/src/language/main.ts',
8287
targetRoot + '/packages/extension/.vscodeignore',
8388
targetRoot + '/packages/extension/esbuild.mjs',
89+
targetRoot + '/packages/extension/langium-quickstart.md',
8490
targetRoot + '/packages/extension/language-configuration.json',
8591
targetRoot + '/packages/extension/package.json',
8692
targetRoot + '/packages/extension/tsconfig.json'

0 commit comments

Comments
 (0)