@ui5/webcomponents-tools 0.0.0-ef27ca1aa → 0.0.0-f24ff9019

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +752 -0
  2. package/README.md +6 -6
  3. package/assets-meta.js +23 -3
  4. package/bin/dev.js +12 -1
  5. package/components-package/eslint.js +34 -0
  6. package/components-package/nps.js +112 -44
  7. package/components-package/postcss.components.js +18 -15
  8. package/components-package/postcss.themes.js +23 -16
  9. package/components-package/vite.config.js +13 -0
  10. package/components-package/wdio.js +405 -297
  11. package/components-package/wdio.sync.js +368 -0
  12. package/icons-collection/nps.js +52 -11
  13. package/lib/copy-and-watch/index.js +145 -0
  14. package/lib/copy-list/index.js +28 -0
  15. package/lib/create-icons/index.js +124 -54
  16. package/lib/create-illustrations/index.js +175 -0
  17. package/lib/create-new-component/index.js +72 -93
  18. package/lib/create-new-component/jsFileContentTemplate.js +73 -0
  19. package/lib/create-new-component/tsFileContentTemplate.js +80 -0
  20. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  21. package/lib/dev-server/dev-server.js +66 -0
  22. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  23. package/lib/esm-abs-to-rel/index.js +58 -0
  24. package/lib/generate-custom-elements-manifest/index.js +327 -0
  25. package/lib/generate-js-imports/illustrations.js +83 -0
  26. package/lib/generate-json-imports/i18n.js +98 -47
  27. package/lib/generate-json-imports/themes.js +67 -17
  28. package/lib/hbs2lit/index.js +2 -4
  29. package/lib/hbs2lit/src/compiler.js +30 -9
  30. package/lib/hbs2lit/src/includesReplacer.js +23 -17
  31. package/lib/hbs2lit/src/litVisitor2.js +125 -26
  32. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  33. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +35 -7
  34. package/lib/hbs2ui5/index.js +69 -30
  35. package/lib/i18n/defaults.js +66 -54
  36. package/lib/i18n/toJSON.js +13 -10
  37. package/lib/jsdoc/config.json +1 -1
  38. package/lib/jsdoc/configTypescript.json +29 -0
  39. package/lib/jsdoc/plugin.js +65 -4
  40. package/lib/jsdoc/preprocess.js +146 -0
  41. package/lib/jsdoc/template/publish.js +32 -4
  42. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  43. package/lib/postcss-css-to-esm/index.js +64 -16
  44. package/lib/postcss-css-to-json/index.js +31 -11
  45. package/lib/postcss-new-files/index.js +36 -0
  46. package/lib/postcss-p/postcss-p.mjs +14 -0
  47. package/lib/postcss-scope-vars/index.js +24 -0
  48. package/lib/replace-global-core/index.js +25 -0
  49. package/lib/scoping/get-all-tags.js +37 -0
  50. package/lib/scoping/lint-src.js +31 -0
  51. package/lib/scoping/missing-dependencies.js +65 -0
  52. package/lib/scoping/report-tags-usage.js +28 -0
  53. package/lib/scoping/scope-test-pages.js +40 -0
  54. package/lib/test-runner/test-runner.js +71 -0
  55. package/package.json +54 -54
  56. package/bin/init-ui5-package.js +0 -3
  57. package/components-package/rollup.js +0 -134
  58. package/components-package/serve.json +0 -3
  59. package/lib/documentation/index.js +0 -143
  60. package/lib/documentation/templates/api-component-since.js +0 -3
  61. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  62. package/lib/documentation/templates/api-events-section.js +0 -35
  63. package/lib/documentation/templates/api-methods-section.js +0 -26
  64. package/lib/documentation/templates/api-properties-section.js +0 -40
  65. package/lib/documentation/templates/api-slots-section.js +0 -28
  66. package/lib/documentation/templates/template.js +0 -38
  67. package/lib/init-package/index.js +0 -119
  68. package/lib/init-package/resources/.eslintignore +0 -3
  69. package/lib/init-package/resources/bundle.es5.js +0 -25
  70. package/lib/init-package/resources/bundle.esm.js +0 -34
  71. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  72. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  73. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  74. package/lib/init-package/resources/config/rollup.config.js +0 -1
  75. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  76. package/lib/init-package/resources/package-scripts.js +0 -11
  77. package/lib/init-package/resources/src/Assets.js +0 -5
  78. package/lib/init-package/resources/src/Demo.hbs +0 -1
  79. package/lib/init-package/resources/src/Demo.js +0 -56
  80. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  81. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  82. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  83. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  84. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  85. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  86. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  87. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  88. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  89. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  90. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  91. package/lib/init-package/resources/test/pages/index.html +0 -51
  92. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -0,0 +1,40 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const glob = require("glob");
4
+ const getAllTags = require("./get-all-tags.js");
5
+
6
+ const root = process.argv[2];
7
+ const suffix = process.argv[3];
8
+
9
+ const tags = getAllTags(process.cwd());
10
+
11
+ // Replaces tags in HTML content, f.e. <ui5-button> with <ui5-button-ver> or </ui5-button> with </ui5-button-ver>
12
+ const replaceTagsHTML = content => {
13
+ tags.forEach(tag => {
14
+ content = content.replace(new RegExp(`(<\/?)(${tag})(\/?[> \t\n])`, "g"), `$1$2-${suffix}$3`);
15
+ });
16
+ return content;
17
+ };
18
+
19
+ // Replace tags in any content
20
+ const replaceTagsAny = content => {
21
+ tags.forEach(tag => {
22
+ content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
23
+ });
24
+ return content;
25
+ };
26
+
27
+ // Replace bundle names and HTML tag names in test pages
28
+ glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
+ let content = String(fs.readFileSync(file));
30
+ content = content.replace(/bundle\.(.*?)\.js/g, `../bundle.scoped.$1.js`);
31
+ content = replaceTagsHTML(content);
32
+ fs.writeFileSync(file, content);
33
+ });
34
+
35
+ // Replace tag names everywhere
36
+ glob.sync(path.join(root, "/**/*.{html,css,js}")).forEach(file => {
37
+ let content = String(fs.readFileSync(file));
38
+ content = replaceTagsAny(content);
39
+ fs.writeFileSync(file, content);
40
+ });
@@ -0,0 +1,71 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ // search for dev-server port
7
+ // start in current folder
8
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
9
+ let devServerFolder = process.cwd();
10
+ let devServerPort;
11
+ while (true) {
12
+ try {
13
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
14
+ break; // found
15
+ } catch (e) {
16
+ // file not found
17
+ if (devServerFolder === path.dirname(devServerFolder)) {
18
+ break; // reached root folder "/"
19
+ }
20
+ devServerFolder = path.dirname(devServerFolder);
21
+ }
22
+ }
23
+
24
+ // check if we are in a monorepo and extract path from package.json
25
+ let packageRepositoryPath = "";
26
+ const pkg = require(path.join(process.cwd(), "package.json"));
27
+ packageRepositoryPath = pkg.repository ? pkg.repository.directory : "";
28
+
29
+ // construct base url
30
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
31
+ // if a dev server is running in the root of a mono repo, append tha package path like this
32
+ // http://localhost:${devServerPort}/packages/main/
33
+ let baseUrl = "";
34
+ if (devServerPort) {
35
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
36
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
37
+ if (devServerInRoot) {
38
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
39
+ } else {
40
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
41
+ }
42
+ }
43
+
44
+ if (!baseUrl) {
45
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
46
+ }
47
+
48
+ // add single spec parameter if passed
49
+ let spec = "";
50
+ if (process.argv.length === 3) {
51
+ const specFile = process.argv[2];
52
+ spec = `--spec ${specFile}`;
53
+ }
54
+
55
+ // more parameters - pass them to wdio
56
+ let restParams = "";
57
+ if (process.argv.length > 3) {
58
+ restParams = process.argv.slice(2).join(" ");
59
+ }
60
+
61
+ let wdioConfig = "";
62
+ if (fs.existsSync("config/wdio.conf.cjs")) {
63
+ wdioConfig = "config/wdio.conf.cjs";
64
+ } else if (fs.existsSync("config/wdio.conf.js")) {
65
+ wdioConfig = "config/wdio.conf.js";
66
+ }
67
+
68
+ // run wdio with calculated parameters
69
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio ${wdioConfig} ${spec} ${baseUrl} ${restParams}`;
70
+ console.log(`executing: ${cmd}`);
71
+ child_process.execSync(cmd, {stdio: 'inherit'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-ef27ca1aa",
3
+ "version": "0.0.0-f24ff9019",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -13,8 +13,7 @@
13
13
  "scripts": {},
14
14
  "bin": {
15
15
  "wc-dev": "bin/dev.js",
16
- "wc-create-ui5-element": "bin/create-ui5-element.js",
17
- "wc-init-ui5-package": "bin/init-ui5-package.js"
16
+ "wc-create-ui5-element": "bin/create-ui5-element.js"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -22,60 +21,61 @@
22
21
  "directory": "packages/tools"
23
22
  },
24
23
  "dependencies": {
25
- "@babel/cli": "^7.1.2",
26
- "@babel/core": "^7.1.2",
27
- "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
28
- "@babel/preset-env": "^7.1.0",
29
- "@wdio/cli": "^5.12.1",
30
- "@wdio/dot-reporter": "^5.12.1",
31
- "@wdio/local-runner": "^5.12.1",
32
- "@wdio/mocha-framework": "^5.12.1",
33
- "@wdio/spec-reporter": "^5.12.1",
34
- "@wdio/sync": "^5.12.1",
35
- "@webcomponents/webcomponentsjs": "^2.4.0",
36
- "chai": "^4.2.0",
37
- "chokidar-cli": "^2.0.0",
38
- "chromedriver": "^80.0.0",
39
- "clean-css": "^4.2.1",
24
+ "@typescript-eslint/eslint-plugin": "^5.42.1",
25
+ "@typescript-eslint/parser": "^5.42.1",
26
+ "@wdio/cli": "^7.19.7",
27
+ "@wdio/dot-reporter": "^7.19.7",
28
+ "@wdio/local-runner": "^7.19.7",
29
+ "@wdio/mocha-framework": "^7.19.7",
30
+ "@wdio/spec-reporter": "^7.19.7",
31
+ "@wdio/static-server-service": "^7.19.5",
32
+ "chai": "^4.3.4",
33
+ "child_process": "^1.0.2",
34
+ "chokidar": "^3.5.1",
35
+ "chokidar-cli": "^3.0.0",
40
36
  "command-line-args": "^5.1.1",
41
- "concurrently": "^5.0.0",
42
- "copy-and-watch": "^0.1.4",
43
- "cross-env": "^5.2.0",
44
- "cssnano": "^4.1.10",
45
- "escodegen": "^1.11.0",
46
- "eslint": "^5.10.0",
47
- "eslint-config-airbnb-base": "^13.1.0",
48
- "eslint-plugin-import": "^2.14.0",
37
+ "concurrently": "^6.0.0",
38
+ "cross-env": "^7.0.3",
39
+ "cssnano": "^6.0.1",
40
+ "escodegen": "^2.0.0",
41
+ "eslint": "^7.22.0",
42
+ "eslint-config-airbnb-base": "^14.2.1",
43
+ "eslint-plugin-import": "^2.22.1",
49
44
  "esprima": "^4.0.1",
50
- "getopts": "^2.2.3",
51
- "glob": "^7.1.3",
52
- "handlebars": "^4.1.2",
53
- "jsdoc": "^3.6.3",
45
+ "getopts": "^2.3.0",
46
+ "glob": "^7.1.6",
47
+ "glob-parent": "^6.0.2",
48
+ "globby": "^13.1.1",
49
+ "handlebars": "^4.7.7",
50
+ "is-port-reachable": "^3.1.0",
51
+ "jsdoc": "^3.6.6",
54
52
  "json-beautify": "^1.1.1",
55
- "mkdirp": "^0.5.1",
56
- "npm-run-all": "^4.1.3",
57
- "nps": "^5.9.8",
58
- "postcss": "^7.0.18",
59
- "postcss-cli": "^6.1.3",
60
- "postcss-combine-duplicated-selectors": "^7.0.0",
61
- "postcss-import": "^12.0.1",
62
- "properties-reader": "^0.3.1",
63
- "puppeteer": "^1.11.0",
64
- "rimraf": "^2.6.2",
65
- "rollup": "^1.1.2",
66
- "rollup-plugin-babel": "^4.0.3",
67
- "rollup-plugin-filesize": "^6.0.1",
68
- "rollup-plugin-livereload": "^1.0.4",
69
- "rollup-plugin-node-resolve": "^4.0.0",
70
- "rollup-plugin-notify": "^1.1.0",
71
- "rollup-plugin-string": "^2.0.2",
72
- "rollup-plugin-terser": "^5.1.3",
73
- "rollup-plugin-url": "^2.2.0",
74
- "rollup-plugin-visualizer": "^0.9.2",
75
- "serve": "^10.1.1",
76
- "wdio-chromedriver-service": "^5.0.2"
53
+ "mkdirp": "^1.0.4",
54
+ "nps": "^5.10.0",
55
+ "postcss": "^8.4.5",
56
+ "postcss-cli": "^9.1.0",
57
+ "postcss-import": "^14.0.2",
58
+ "postcss-selector-parser": "^6.0.10",
59
+ "prompts": "^2.4.2",
60
+ "properties-reader": "^2.2.0",
61
+ "recursive-readdir": "^2.2.2",
62
+ "resolve": "^1.20.0",
63
+ "rimraf": "^3.0.2",
64
+ "slash": "3.0.0",
65
+ "vite": "^4.4.9",
66
+ "wdio-chromedriver-service": "^7.3.2",
67
+ "zx": "^7.2.3"
77
68
  },
78
- "resolutions": {
79
- "rollup-plugin-livereload/livereload/chokidar": "^3.x"
69
+ "peerDependencies": {
70
+ "chromedriver": "*",
71
+ "typescript": "^4.9.4"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "typescript": {
75
+ "optional": true
76
+ }
77
+ },
78
+ "devDependencies": {
79
+ "yargs": "^17.5.1"
80
80
  }
81
81
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../lib/init-package/index.js");
@@ -1,134 +0,0 @@
1
- const babel = require("rollup-plugin-babel");
2
- const process = require("process");
3
- const resolve = require("rollup-plugin-node-resolve");
4
- const url = require("rollup-plugin-url");
5
- const { terser } = require("rollup-plugin-terser");
6
- const notify = require('rollup-plugin-notify');
7
- const filesize = require('rollup-plugin-filesize');
8
- const livereload = require('rollup-plugin-livereload');
9
- const os = require("os");
10
- const fs = require("fs");
11
-
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
13
- const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
14
-
15
- function ui5DevImportCheckerPlugin() {
16
- return {
17
- name: "ui5-dev-import-checker-plugin",
18
- transform(code, file) {
19
- const re = new RegExp(`^import.*"${packageName}/`);
20
- if (re.test(code)) {
21
- throw new Error(`illegal import in ${file}`);
22
- }
23
- }
24
- };
25
- }
26
-
27
- const getPlugins = ({ transpile }) => {
28
- const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
30
-
31
- if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
35
- }
36
- }));
37
- }
38
-
39
- plugins.push(ui5DevImportCheckerPlugin());
40
-
41
- plugins.push(url({
42
- limit: 0,
43
- include: [
44
- /.*assets\/.*\.json/
45
- ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
49
- }));
50
-
51
-
52
- if (transpile) {
53
- plugins.push(babel({
54
- presets: ["@babel/preset-env"],
55
- exclude: "node_modules/**",
56
- sourcemap: true,
57
- }));
58
- }
59
-
60
- plugins.push(resolve());
61
-
62
- if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
68
- }
69
-
70
- const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
71
- if (es6DevMain && os.platform() !== "win32") {
72
- plugins.push(livereload({
73
- watch: [
74
- "dist/resources/bundle.esm.js",
75
- "dist/**/*.html",
76
- "dist/**/*.json",
77
- ]
78
- }));
79
- }
80
-
81
- return plugins;
82
- };
83
-
84
- const getES6Config = () => {
85
- return [{
86
- input: "bundle.esm.js",
87
- output: {
88
- dir: "dist/resources",
89
- format: "esm",
90
- sourcemap: true
91
- },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
94
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
- return "window";
96
- }
97
- },
98
- watch: {
99
- clearScreen: false
100
- },
101
- plugins: getPlugins({transpile: false}),
102
- }];
103
- };
104
-
105
- const getES5Config = () => {
106
- return [ {
107
- input: "bundle.es5.js",
108
- output: {
109
- dir: "dist/resources",
110
- format: "iife",
111
- name: "sap-ui-webcomponents-bundle",
112
- extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
113
- sourcemap: true
114
- },
115
- moduleContext: (id) => {
116
- if (id.includes("url-search-params-polyfill")) {
117
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
118
- return "window";
119
- }
120
- },
121
- watch: {
122
- clearScreen: false
123
- },
124
- plugins: getPlugins({transpile: true}),
125
- }];
126
- };
127
-
128
- let config = getES6Config();
129
-
130
- if (process.env.ES5_BUILD) {
131
- config = config.concat(getES5Config());
132
- }
133
-
134
- module.exports = config;
@@ -1,3 +0,0 @@
1
- {
2
- "cleanUrls": false
3
- }
@@ -1,143 +0,0 @@
1
- const cssVariables = {};
2
- const template = require('./templates/template').template;
3
- const sinceTemplate = require('./templates/api-component-since').template;
4
- const propertiesTemplate = require('./templates/api-properties-section').template;
5
- const slotsTemplate = require('./templates/api-slots-section').template;
6
- const eventsTemplate = require('./templates/api-events-section').template;
7
- const methodsTemplate = require('./templates/api-methods-section').template;
8
- const cssVariablesTemplate = require('./templates/api-css-variables-section').template;
9
- const Handlebars = require('handlebars/dist/handlebars.min.js');
10
- const fs = require('fs');
11
- const path = require('path');
12
- const mkdirp = require('mkdirp');
13
-
14
- const api = JSON.parse(fs.readFileSync(path.normalize(process.argv[2])));
15
-
16
- const entries = api['symbols'];
17
- const compiledHandlebars = Handlebars.compile(template);
18
- const compiledSinceTemplate = Handlebars.compile(sinceTemplate);
19
- const linkMatcher = /{@link(\s)(\w+)\s*}/gi;
20
- const sinceMarker = "<!--since_tag_marker-->";
21
-
22
- const getComponentByName = name => {
23
- return entries.find(element => {
24
- return element.basename === name;
25
- })
26
- };
27
-
28
- const getCSSVarsByName = name => {
29
- return cssVariables[name] || [];
30
- };
31
-
32
- const capitalize = str => {
33
- return str.replace(/^./, str => str.toUpperCase());
34
- };
35
-
36
- Handlebars.registerHelper('toLowerCase', function (str) {
37
- return str ? str.toLowerCase() : "";
38
- });
39
-
40
- Handlebars.registerHelper('toKebabCase', function (str) {
41
- const kebab = str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
42
- return kebab !== str ? kebab : undefined;
43
- });
44
-
45
- Handlebars.registerHelper('checkEven', function (iIndex) {
46
- return (iIndex % 2 === 0) ? "api-table-roll-even" : "api-table-roll-odd";
47
- });
48
-
49
- Handlebars.registerPartial('properties', propertiesTemplate);
50
- Handlebars.registerPartial('slots', slotsTemplate);
51
- Handlebars.registerPartial('events', eventsTemplate);
52
- Handlebars.registerPartial('methods', methodsTemplate);
53
- Handlebars.registerPartial('cssVariables', cssVariablesTemplate);
54
-
55
- mkdirp.sync(`dist/test-resources/api`);
56
-
57
- let entriesAPI = [];
58
-
59
- const appendCSSVarsAPI = entry => {
60
- entry.cssVariables = getCSSVarsByName(entry.basename);
61
- return entry;
62
- }
63
-
64
- const calculateAPI = entry => {
65
- if (entriesAPI.indexOf(entry.basename) !== -1) {
66
- return entry;
67
- }
68
-
69
- let parent = getComponentByName(entry.extends) || {};
70
-
71
- entry = appendCSSVarsAPI(entry);
72
- parent = appendCSSVarsAPI(parent);
73
-
74
- parent = { ...{ properties: [], events: [], slots: [], cssVariables: [] }, ...parent };
75
-
76
- // extend component documentation
77
- entry.properties = [...(entry.properties || []), ...(parent.properties || [])];
78
- entry.events = [...(entry.events || []), ...(parent.events || [])];
79
- entry.slots = [...(entry.slots || []), ...(parent.slots || [])];
80
- entry.cssVariables = [...(entry.cssVariables || []), ...(parent.cssVariables || [])];
81
-
82
- entriesAPI.push(entry.basename);
83
-
84
- return entry;
85
- }
86
-
87
- const appendAdditionalEntriesAPI = entry => {
88
- if (entry.appenddocs) {
89
- const additionalEntries = entry.appenddocs.split(" ");
90
- entry.additionalDocs = [];
91
-
92
- additionalEntries.forEach(entryName => {
93
- let additionalEntry = getComponentByName(entryName);
94
- additionalEntry = calculateAPI(additionalEntry);
95
- entry.additionalDocs.push(additionalEntry);
96
- });
97
- }
98
-
99
- return entry;
100
- }
101
-
102
- const generateSamplePage = entry => {
103
- let content = "";
104
-
105
- try {
106
- content = fs.readFileSync(`dist/test-resources/samples/${capitalize(entry.basename)}.sample.html`, 'utf8');
107
- } catch (err) { }
108
-
109
- if (content) {
110
- const APIReference = compiledHandlebars(entry).replace(/\[\]/g, " [0..n]");
111
- const EntitySince = compiledSinceTemplate(entry).replace(/\[\]/g, " [0..n]");
112
-
113
- content = content.replace('<!-- JSDoc marker -->', APIReference);
114
- content = content.replace(sinceMarker, EntitySince);
115
-
116
- content = content.replace(linkMatcher, match => {
117
- const component = linkMatcher.exec(match)[2];
118
-
119
- // reset the regex
120
- linkMatcher.lastIndex = 0;
121
-
122
- return `<a href="#" onclick="redirect(event, '${component}')">${component}</a>`;
123
- });
124
-
125
- fs.writeFile(`dist/test-resources/api/${entry.basename}.sample.html`, content, (err) => {
126
- // console.log(err);
127
- });
128
- }
129
- }
130
-
131
- const generateComponentAPI = entry => {
132
- // (1) calculate the API
133
- entry = calculateAPI(entry);
134
-
135
- // (2) append additional API for composition components - List -> ListIems, TabContainer -> Tabs, Table -> TableRow/Column/Cell
136
- entry = appendAdditionalEntriesAPI(entry);
137
-
138
- // (3) generate sample page
139
- generateSamplePage(entry);
140
- }
141
-
142
- entries.forEach(generateComponentAPI);
143
- entriesAPI = [];
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- template: `{{#if this.since}}v{{this.since}}{{/if}}`
3
- };
@@ -1,24 +0,0 @@
1
- module.exports = {
2
- template: `
3
- {{#if cssVariables}}
4
- <h3 class="comment-api-title" >CSS variables</h3>
5
- <p class="small-space-top">You can use the following CSS varialbes to change the component styling.</p>
6
-
7
- <div class="small-space-top api-table">
8
- <div class="head api-table-header-roll">
9
- <div class="cell api-table-header-cell">Name</div>
10
- <div class="cell api-table-header-cell">Description</div>
11
- </div>
12
-
13
- {{#each cssVariables}}
14
- <div class="row {{checkEven @index}}">
15
- <div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
16
- <div class="cell api-table-content-cell api-table-content-cell-description">
17
- {{{this.description}}}
18
- </div>
19
- </div>
20
- {{/each}}
21
-
22
- </div>
23
- {{/if}}`
24
- };
@@ -1,35 +0,0 @@
1
- module.exports = {
2
- template: `
3
- {{#if events}}
4
- <h3 class="comment-api-title space-top">Events</h3>
5
- <p class="small-space-top" >This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as <code>addEventListener</code>. </p>
6
-
7
- <div class="small-space-top api-table">
8
- <div class="head api-table-header-roll">
9
- <div class="cell api-table-header-cell">Name</div>
10
- <div class="cell api-table-header-cell">Description</div>
11
- </div>
12
-
13
- {{#each events}}
14
- <div class="row {{checkEven @index}}">
15
- <div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
16
- <div class="cell api-table-content-cell api-table-content-cell-description">
17
- {{{this.description}}}
18
- {{#if this.since}}
19
- <div class="api-table-content-cell-bold api-table-content-cell-since">since v{{{this.since}}}</div>
20
- {{/if}}
21
- </div>
22
- </div>
23
-
24
- {{#each this.parameters}}
25
- <tr class="api-table-event-param">
26
- <div class="api-table-content-event-params-wrapper">
27
- <div class="cell api-table-param-name api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
28
- <div class="cell api-table-event-param-cell api-table-content-cell api-table-content-cell-description"><strong class="bold" >type:</strong> {{this.type}} <br/> <strong class="api-table-event-description bold">description:</strong> {{{this.description}}}</div>
29
- </div>
30
- </tr>
31
- {{/each}}
32
- {{/each}}
33
- </div>
34
- {{/if}}`
35
- };
@@ -1,26 +0,0 @@
1
- module.exports = {
2
- template: `
3
- {{#if methods}}
4
- <h3 class="comment-api-title space-top">Methods</h3>
5
- <p class="small-space-top" >This Web Component exposes public methods. You can invoke them directly on the Web Component instance.</p>
6
-
7
- <div class="small-space-top api-table">
8
- <div class="head api-table-header-roll">
9
- <div class="cell api-table-header-cell">Name</div>
10
- <div class="cell api-table-header-cell">Description</div>
11
- </div>
12
-
13
- {{#each methods}}
14
- <div class="row {{checkEven @index}}">
15
- <div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
16
- <div class="cell api-table-content-cell api-table-content-cell-description">{{{this.description}}}</div>
17
- </div>
18
-
19
- {{#each this.parameters}}
20
- <div class="cell api-table-content-cell api-table-content-cell-bold api-table-param-name">{{this.name}}</div>
21
- <div class="cell api-table-event-param-cell api-table-content-cell api-table-content-cell-description"><strong class="bold" >type:</strong> {{this.type}} <br/> <strong class="api-table-event-description bold">description:</strong> {{{this.description}}}</div>
22
- {{/each}}
23
- {{/each}}
24
- </div>
25
- {{/if}}`
26
- };
@@ -1,40 +0,0 @@
1
- module.exports = {
2
- template: `
3
- {{#if properties}}
4
- <h3 class="comment-api-title" >Properties/Attributes</h3>
5
- <p class="small-space-top" >You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.</p>
6
-
7
- <div class="small-space-top api-table">
8
- <div class="head api-table-header-roll">
9
- <div class="cell api-table-header-cell">Name</div>
10
- <div class="cell api-table-header-cell">Type</div>
11
- <div class="cell api-table-header-cell">Default Value</div>
12
- <div class="cell api-table-header-cell">Description</div>
13
- </div>
14
-
15
- {{#each properties}}
16
- <div class="row {{checkEven @index}}">
17
- <div class="cell api-table-content-cell api-table-content-cell-bold">
18
- {{this.name}}
19
- {{#if this.readonly}}
20
- (readonly)
21
- {{/if}}
22
- <br>
23
- {{#if (toKebabCase this.name)}}
24
- <code>{{toKebabCase this.name}}</code>
25
- {{/if}}
26
- </div>
27
- <div class="cell api-table-content-cell">{{this.type}}</div>
28
- <div class="cell api-table-content-cell">{{this.defaultValue}}</div>
29
- <div class="cell api-table-content-cell api-table-content-cell-description">
30
- {{{this.description}}}
31
- {{#if this.since}}
32
- <div class="api-table-content-cell-bold api-table-content-cell-since">since v{{{this.since}}}</div>
33
- {{/if}}
34
- </div>
35
- </div>
36
- {{/each}}
37
-
38
- </div>
39
- {{/if}}`
40
- };