Comparing version 0.1.0-rc.0 to 0.1.0-rc.1
@@ -8,4 +8,8 @@ # Changelog | ||
## [0.1.0-rc.1](https://github.com/IBM/carbon-icons-svelte/releases/tag/v0.1.0-rc.1) - 2020-11-17 | ||
- Enable CLI usage by wrapping Rollup plugin | ||
## [0.1.0-rc.0](https://github.com/IBM/carbon-icons-svelte/releases/tag/v0.1.0-rc.0) - 2020-11-16 | ||
- Initial release |
"use strict"; | ||
exports.__esModule = true; | ||
exports.getElementByTag = void 0; | ||
// Element tag map adapted TypeScript `lib.dom.d.ts` | ||
// Element tag map adapted from TypeScript (`lib.dom.d.ts`) | ||
// https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L19263 | ||
@@ -6,0 +6,0 @@ var tag_map = { |
export { default } from "./rollup-plugin"; | ||
export { default as ComponentParser } from "./ComponentParser"; | ||
export { cli } from "./cli"; |
@@ -10,3 +10,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.ComponentParser = exports["default"] = void 0; | ||
exports.cli = exports.ComponentParser = exports["default"] = void 0; | ||
var rollup_plugin_1 = require("./rollup-plugin"); | ||
@@ -16,1 +16,3 @@ __createBinding(exports, rollup_plugin_1, "default"); | ||
__createBinding(exports, ComponentParser_1, "default", "ComponentParser"); | ||
var cli_1 = require("./cli"); | ||
__createBinding(exports, cli_1, "cli"); |
@@ -6,3 +6,3 @@ import * as Rollup from "rollup"; | ||
import { ParsedComponent } from "./ComponentParser"; | ||
interface PluginSveldOptions { | ||
export interface PluginSveldOptions { | ||
types?: boolean; | ||
@@ -26,2 +26,21 @@ typesOptions?: WriteTsDefinitionsOptions; | ||
}; | ||
interface GenerateBundleResult { | ||
exports: string[]; | ||
rendered_exports: string[]; | ||
default_export: { | ||
moduleName: null | string; | ||
only: boolean; | ||
}; | ||
components: ComponentDocs; | ||
} | ||
export declare function generateBundle(bundle: Rollup.OutputBundle): Promise<{ | ||
exports: string[]; | ||
rendered_exports: string[]; | ||
default_export: { | ||
moduleName: null | string; | ||
only: boolean; | ||
}; | ||
components: ComponentDocs; | ||
}>; | ||
export declare function writeOutput(result: GenerateBundleResult, opts?: PluginSveldOptions): void; | ||
export {}; |
@@ -50,2 +50,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.writeOutput = exports.generateBundle = void 0; | ||
var fs = require("fs-extra"); | ||
@@ -58,10 +59,3 @@ var path = require("path"); | ||
function pluginSveld(opts) { | ||
var exports = []; | ||
var rendered_exports = []; | ||
var default_export = { | ||
moduleName: null, | ||
only: false | ||
}; | ||
var components = new Map(); | ||
var parser = new ComponentParser_1["default"](); | ||
var result; | ||
return { | ||
@@ -71,54 +65,8 @@ name: "plugin-sveld", | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _b, _c, _i, filename, chunkOrAsset, _d, _e, _f, filePath, parsed, moduleName, single_default_export, source; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
_b = []; | ||
for (_c in bundle) | ||
_b.push(_c); | ||
_i = 0; | ||
_g.label = 1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, generateBundle(bundle)]; | ||
case 1: | ||
if (!(_i < _b.length)) return [3 /*break*/, 6]; | ||
filename = _b[_i]; | ||
chunkOrAsset = bundle[filename]; | ||
if (!(chunkOrAsset.type !== "asset" && chunkOrAsset.isEntry)) return [3 /*break*/, 5]; | ||
exports = chunkOrAsset.exports; | ||
_d = []; | ||
for (_e in chunkOrAsset.modules) | ||
_d.push(_e); | ||
_f = 0; | ||
_g.label = 2; | ||
case 2: | ||
if (!(_f < _d.length)) return [3 /*break*/, 5]; | ||
filePath = _d[_f]; | ||
// options.input assumes the Rollup entry point is `index.js` | ||
if (filePath.endsWith("index.js")) { | ||
rendered_exports = chunkOrAsset.modules[filePath].renderedExports; | ||
} | ||
if (!!/node_modules/.test(filePath)) return [3 /*break*/, 4]; | ||
parsed = path.parse(filePath); | ||
moduleName = parsed.name; | ||
single_default_export = exports.length === 1 && exports[0] === "default"; | ||
if (exports.includes("default")) { | ||
default_export.moduleName = moduleName; | ||
default_export.only = single_default_export; | ||
} | ||
if (!(parsed.ext === ".svelte" && (exports.includes(moduleName) || single_default_export))) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, fs.readFile(filePath, "utf-8")]; | ||
case 3: | ||
source = _g.sent(); | ||
components.set(moduleName, __assign({ moduleName: moduleName, | ||
filePath: filePath }, parser.parseSvelteComponent(source, { | ||
moduleName: moduleName, | ||
filePath: filePath | ||
}))); | ||
_g.label = 4; | ||
case 4: | ||
_f++; | ||
return [3 /*break*/, 2]; | ||
case 5: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 6: return [2 /*return*/]; | ||
result = _b.sent(); | ||
return [2 /*return*/]; | ||
} | ||
@@ -129,13 +77,3 @@ }); | ||
writeBundle: function () { | ||
if ((opts === null || opts === void 0 ? void 0 : opts.types) !== false) { | ||
writer_ts_definitions_1["default"](components, __assign(__assign({ inputDir: "src", outDir: "types", preamble: "" }, opts === null || opts === void 0 ? void 0 : opts.typesOptions), { exports: exports, | ||
default_export: default_export, | ||
rendered_exports: rendered_exports })); | ||
} | ||
if (opts === null || opts === void 0 ? void 0 : opts.json) { | ||
writer_json_1["default"](components, __assign({ outFile: "COMPONENT_API.json" }, opts === null || opts === void 0 ? void 0 : opts.jsonOptions)); | ||
} | ||
if (opts === null || opts === void 0 ? void 0 : opts.markdown) { | ||
writer_markdown_1["default"](components, __assign({ outFile: "COMPONENT_INDEX.md" }, opts === null || opts === void 0 ? void 0 : opts.markdownOptions)); | ||
} | ||
writeOutput(result, opts); | ||
} | ||
@@ -145,1 +83,85 @@ }; | ||
exports["default"] = pluginSveld; | ||
function generateBundle(bundle) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var exports, rendered_exports, default_export, components, parser, _a, _b, _i, filename, chunkOrAsset, _c, _d, _e, filePath, parsed, moduleName, single_default_export, source; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
exports = []; | ||
rendered_exports = []; | ||
default_export = { | ||
moduleName: null, | ||
only: false | ||
}; | ||
components = new Map(); | ||
parser = new ComponentParser_1["default"](); | ||
_a = []; | ||
for (_b in bundle) | ||
_a.push(_b); | ||
_i = 0; | ||
_f.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 6]; | ||
filename = _a[_i]; | ||
chunkOrAsset = bundle[filename]; | ||
if (!(chunkOrAsset.type !== "asset" && chunkOrAsset.isEntry)) return [3 /*break*/, 5]; | ||
exports = chunkOrAsset.exports; | ||
_c = []; | ||
for (_d in chunkOrAsset.modules) | ||
_c.push(_d); | ||
_e = 0; | ||
_f.label = 2; | ||
case 2: | ||
if (!(_e < _c.length)) return [3 /*break*/, 5]; | ||
filePath = _c[_e]; | ||
// options.input assumes the Rollup entry point is `index.js` | ||
if (filePath.endsWith("index.js")) { | ||
rendered_exports = chunkOrAsset.modules[filePath].renderedExports; | ||
} | ||
if (!!/node_modules/.test(filePath)) return [3 /*break*/, 4]; | ||
parsed = path.parse(filePath); | ||
moduleName = parsed.name; | ||
single_default_export = exports.length === 1 && exports[0] === "default"; | ||
if (exports.includes("default")) { | ||
default_export.moduleName = moduleName; | ||
default_export.only = single_default_export; | ||
} | ||
if (!(parsed.ext === ".svelte" && (exports.includes(moduleName) || single_default_export))) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, fs.readFile(filePath, "utf-8")]; | ||
case 3: | ||
source = _f.sent(); | ||
components.set(moduleName, __assign({ moduleName: moduleName, | ||
filePath: filePath }, parser.parseSvelteComponent(source, { | ||
moduleName: moduleName, | ||
filePath: filePath | ||
}))); | ||
_f.label = 4; | ||
case 4: | ||
_e++; | ||
return [3 /*break*/, 2]; | ||
case 5: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 6: return [2 /*return*/, { | ||
exports: exports, | ||
rendered_exports: rendered_exports, | ||
default_export: default_export, | ||
components: components | ||
}]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.generateBundle = generateBundle; | ||
function writeOutput(result, opts) { | ||
if ((opts === null || opts === void 0 ? void 0 : opts.types) !== false) { | ||
writer_ts_definitions_1["default"](result.components, __assign(__assign({ inputDir: "src", outDir: "types", preamble: "" }, opts === null || opts === void 0 ? void 0 : opts.typesOptions), { exports: result.exports, default_export: result.default_export, rendered_exports: result.rendered_exports })); | ||
} | ||
if (opts === null || opts === void 0 ? void 0 : opts.json) { | ||
writer_json_1["default"](result.components, __assign({ outFile: "COMPONENT_API.json" }, opts === null || opts === void 0 ? void 0 : opts.jsonOptions)); | ||
} | ||
if (opts === null || opts === void 0 ? void 0 : opts.markdown) { | ||
writer_markdown_1["default"](result.components, __assign({ outFile: "COMPONENT_INDEX.md" }, opts === null || opts === void 0 ? void 0 : opts.markdownOptions)); | ||
} | ||
} | ||
exports.writeOutput = writeOutput; |
{ | ||
"name": "sveld", | ||
"version": "0.1.0-rc.0", | ||
"version": "0.1.0-rc.1", | ||
"license": "Apache-2.0", | ||
@@ -20,5 +20,7 @@ "description": "Documentation generator for Svelte component libraries.", | ||
"dependencies": { | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"comment-parser": "^0.7.6", | ||
"fs-extra": "^9.0.1", | ||
"prettier": "^2.1.2" | ||
"prettier": "^2.1.2", | ||
"rollup-plugin-svelte": "^6.1.1" | ||
}, | ||
@@ -41,2 +43,5 @@ "peerDependencies": { | ||
}, | ||
"bin": { | ||
"sveld": "./cli.js" | ||
}, | ||
"files": [ | ||
@@ -43,0 +48,0 @@ "lib" |
# sveld | ||
> Documentation generator for Svelte component libraries. | ||
[![NPM][npm]][npm-url] | ||
[![Build][build]][build-badge] | ||
`sveld` is a Rollup plugin that generates TypeScript definitions for Svelte component libraries. It can also generate component documentation in Markdown and JSON output formats. Component documentation (e.g. prop types, descriptions, slot signatures) can be augmented through JSDoc annotations, a markup language for JavaScript code. | ||
`sveld` is a documentation generator for Svelte component libraries. It uses the Svelte compiler to generate TypeScript definitions as well as component documentation in Markdown and JSON output formats. Component documentation (e.g. prop types, descriptions, slot signatures) can be augmented through JSDoc annotations, a markup language for JavaScript code. | ||
@@ -108,2 +109,3 @@ The purpose of this project is to enhance the end user experience of consuming third party Svelte components and libraries with minimal documentation effort required by the author. For example, TypeScript definitions may be used during development via intelligent code completion in Integrated Development Environments (IDE) like VSCode. | ||
- [Set-up with Rollup](#set-up-with-rollup) | ||
- [CLI](#cli) | ||
- [Publishing to NPM](#publishing-to-npm) | ||
@@ -169,2 +171,16 @@ - [Available Options](#available-options) | ||
### CLI | ||
The CLI wraps the Rollup plugin and expects the entry file to be `src/index.js`. By default, only TypeScript definitions are generated. | ||
```sh | ||
sveld | ||
``` | ||
Append `--json` or `--markdown` flags to generate documentation in JSON/Markdown formats, respectively. | ||
```sh | ||
sveld --json --markdown | ||
``` | ||
### Publishing to NPM | ||
@@ -258,1 +274,6 @@ | ||
[Apache-2.0](LICENSE) | ||
[npm]: https://img.shields.io/npm/v/sveld.svg | ||
[npm-url]: https://npmjs.com/package/sveld | ||
[build]: https://travis-ci.com/ibm/sveld.svg?branch=main | ||
[build-badge]: https://travis-ci.com/ibm/sveld |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95658
24
1663
277
6
+ Addedrollup-plugin-svelte@^6.1.1
+ Added@rollup/plugin-node-resolve@10.0.0(transitive)
+ Added@rollup/pluginutils@3.1.0(transitive)
+ Added@types/estree@0.0.39(transitive)
+ Added@types/node@22.9.3(transitive)
+ Added@types/resolve@1.17.1(transitive)
+ Addedbuiltin-modules@3.3.0(transitive)
+ Addeddeepmerge@4.3.1(transitive)
+ Addedestree-walker@0.6.11.0.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-module@1.0.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedrequire-relative@0.8.7(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedrollup@2.79.2(transitive)
+ Addedrollup-plugin-svelte@6.1.1(transitive)
+ Addedrollup-pluginutils@2.8.2(transitive)
+ Addedsourcemap-codec@1.4.8(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedundici-types@6.19.8(transitive)