From 0b11225c4fc75ef620efcd61481873bd381659e2 Mon Sep 17 00:00:00 2001 From: Burton Smith Date: Sat, 12 Aug 2023 12:45:23 -0400 Subject: [PATCH] update documentation --- .gitignore | 1 + custom-elements-manifest.config.js | 1 - docs/pages/getting-started/usage.md | 6 +++ package.json | 18 ++------ scripts/build.js | 5 +-- scripts/make-web-types.js | 68 ----------------------------- 6 files changed, 12 insertions(+), 87 deletions(-) delete mode 100644 scripts/make-web-types.js diff --git a/.gitignore b/.gitignore index 24a14172fc..0a2fc3d4da 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ docs/assets/images/sprite.svg node_modules src/react cdn +web-types.json \ No newline at end of file diff --git a/custom-elements-manifest.config.js b/custom-elements-manifest.config.js index f496819861..e5912cd06c 100644 --- a/custom-elements-manifest.config.js +++ b/custom-elements-manifest.config.js @@ -203,7 +203,6 @@ export default { ] }), customElementJetBrainsPlugin({ - outdir, excludeCss: true, referencesTemplate: (_, tag) => { return { diff --git a/docs/pages/getting-started/usage.md b/docs/pages/getting-started/usage.md index f8195e929f..8debfbb586 100644 --- a/docs/pages/getting-started/usage.md +++ b/docs/pages/getting-started/usage.md @@ -210,6 +210,12 @@ Shoelace ships with a file called `vscode.html-custom-data.json` that can be use If `settings.json` already exists, simply add the above line to the root of the object. Note that you may need to restart VS Code for the changes to take affect. +## JetBrains IDEs + +If you are using a [JetBrains IDE](https://www.jetbrains.com/) and you are installing Shoelace from NPM, the editor will automatically detect the `web-types.json` file from the package and you should immediately see component information in your editor. + +If you are installing from the CDN, you can [download a local copy](https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace/cdn/web-types.json) and add it to the root of your project. + ### Other Editors Most popular editors support custom code completion with a bit of configuration. Please [submit a feature request](https://github.com/shoelace-style/shoelace/issues/new/choose) for your editor of choice. PRs are also welcome! diff --git a/package.json b/package.json index bbd13a689f..b03b45edfa 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "Cory LaViska", "license": "MIT", "customElements": "dist/custom-elements.json", - "web-types": "dist/web-types.json", + "web-types": "./web-types.json", "type": "module", "types": "dist/shoelace.d.ts", "jsdelivr": "./cdn/shoelace-autoloader.js", @@ -25,15 +25,8 @@ "./dist/react/*": "./dist/react/*", "./dist/translations/*": "./dist/translations/*" }, - "files": [ - "dist", - "cdn" - ], - "keywords": [ - "web components", - "custom elements", - "components" - ], + "files": ["dist", "cdn"], + "keywords": ["web components", "custom elements", "components"], "repository": { "type": "git", "url": "git+https://github.com/shoelace-style/shoelace.git" @@ -141,9 +134,6 @@ "user-agent-data-types": "^0.3.0" }, "lint-staged": { - "*.{ts,js}": [ - "eslint --max-warnings 0 --cache --fix", - "prettier --write" - ] + "*.{ts,js}": ["eslint --max-warnings 0 --cache --fix", "prettier --write"] } } diff --git a/scripts/build.js b/scripts/build.js index 08b686e924..d27793b590 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -188,10 +188,6 @@ await nextTask('Wrapping components for React', () => { return execPromise(`node scripts/make-react.js --outdir "${outdir}"`, { stdio: 'inherit' }); }); -await nextTask('Generating Web Types', () => { - return execPromise(`node scripts/make-web-types.js --outdir "${outdir}"`, { stdio: 'inherit' }); -}); - await nextTask('Generating themes', () => { return execPromise(`node scripts/make-themes.js --outdir "${outdir}"`, { stdio: 'inherit' }); }); @@ -207,6 +203,7 @@ await nextTask('Running the TypeScript compiler', () => { // Copy the above steps to the CDN directory directly so we don't need to twice the work for nothing. await nextTask(`Copying Web Types, Themes, Icons, and TS Types to "${cdndir}"`, async () => { await deleteAsync(cdndir); + await copy('./web-types.json', `${outdir}/web-types.json`); await copy(outdir, cdndir); }); diff --git a/scripts/make-web-types.js b/scripts/make-web-types.js deleted file mode 100644 index 156ff2ba21..0000000000 --- a/scripts/make-web-types.js +++ /dev/null @@ -1,68 +0,0 @@ -// -// This script generates a web-types.json file from custom-elements.json for use with WebStorm/PHPStorm -// -// Docs: https://github.com/JetBrains/web-types -// -import commandLineArgs from 'command-line-args'; -import jsonata from 'jsonata'; -import fs from 'fs'; -import path from 'path'; - -const { outdir } = commandLineArgs({ name: 'outdir', type: String }); -const metadata = JSON.parse(fs.readFileSync(path.join(outdir, 'custom-elements.json'), 'utf8')); - -const jsonataExprString = `{ - "$schema": "http://json.schemastore.org/web-types", - "name": package.name, - "version": package.version, - "description-markup": "markdown", - "framework-config": { - "enable-when": { - "node-packages": [ - package.name - ] - } - }, - "contributions": { - "html": { - "elements": [ - modules.declarations.{ - "name": tagName, - "description": description, - "doc-url": $join(["https://shoelace.style/components/", $substringAfter(tagName, 'sl-')]), - "js": { - "properties": [ - members.{ - "name": name, - "description": description, - "value": { - "type": type.text - } - } - ], - "events": [ - events.{ - "name": name, - "description": description - } - ] - }, - "attributes": [ - attributes.{ - "name": name, - "description": description, - "value": { - "type": type.text - } - } - ] - } - ] - } - } -}`; - -const expression = jsonata(jsonataExprString); -const result = await expression.evaluate(metadata); - -fs.writeFileSync(path.join(outdir, 'web-types.json'), JSON.stringify(result, null, 2), 'utf8');