fix(extend-lion-docs): support multi line exports
This commit is contained in:
parent
835c2804a9
commit
c5992d630f
5 changed files with 135 additions and 3 deletions
13
.changeset/giant-deers-poke.md
Normal file
13
.changeset/giant-deers-poke.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
'rocket-preset-extend-lion-docs': patch
|
||||
---
|
||||
|
||||
Support multi line exports and comments in exports
|
||||
|
||||
```js
|
||||
export {
|
||||
// html,
|
||||
calculateSum,
|
||||
offsetValue,
|
||||
} from './src/helpers.js';
|
||||
```
|
||||
|
|
@ -3,6 +3,14 @@ import path from 'path';
|
|||
// @ts-ignore
|
||||
import { init, parse } from 'es-module-lexer/dist/lexer.js';
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isComment(value) {
|
||||
return value.startsWith('//') || value.startsWith('/*') || value.startsWith('*/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} src
|
||||
* @returns
|
||||
|
|
@ -16,12 +24,16 @@ function getImportNames(src) {
|
|||
const full = src.substring(importObj.ss, importObj.se);
|
||||
if (full.includes('{')) {
|
||||
const namesString = full.substring(full.indexOf('{') + 1, full.indexOf('}'));
|
||||
namesString.split(',').forEach(name => {
|
||||
namesString.split('\n').forEach(nameLine => {
|
||||
nameLine.split(',').forEach(name => {
|
||||
const trimmedNamed = name.trim();
|
||||
if (trimmedNamed && !isComment(trimmedNamed)) {
|
||||
names.push(name.trim());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
export {
|
||||
//
|
||||
html,
|
||||
CSSResult,
|
||||
// something,
|
||||
adoptStyles,
|
||||
} from 'lit';
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"name": "@lion/core",
|
||||
"version": "0.5.0",
|
||||
"description": "Vertically stacked list of invokers that can be clicked to reveal or hide content associated with them.",
|
||||
"license": "MIT",
|
||||
"author": "ing-bank",
|
||||
"homepage": "https://github.com/ing-bank/lion/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ing-bank/lion.git",
|
||||
"directory": "packages/accordion"
|
||||
},
|
||||
"main": "index.js",
|
||||
"module": "index.js",
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"*.js",
|
||||
"custom-elements.json",
|
||||
"docs",
|
||||
"src",
|
||||
"test",
|
||||
"test-helpers",
|
||||
"translations",
|
||||
"types"
|
||||
],
|
||||
"scripts": {
|
||||
"custom-elements-manifest": "custom-elements-manifest analyze --litelement --exclude \"docs/**/*\" \"test-helpers/**/*\"",
|
||||
"debug": "cd ../../ && npm run debug -- --group accordion",
|
||||
"debug:firefox": "cd ../../ && npm run debug:firefox -- --group accordion",
|
||||
"debug:webkit": "cd ../../ && npm run debug:webkit -- --group accordion",
|
||||
"publish-docs": "node ../../packages-node/publish-docs/src/cli.js --github-url https://github.com/ing-bank/lion/ --git-root-dir ../../",
|
||||
"prepublishOnly": "npm run publish-docs && npm run custom-elements-manifest",
|
||||
"test": "cd ../../ && npm run test:browser -- --group accordion"
|
||||
},
|
||||
"sideEffects": [
|
||||
"lion-accordion.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@lion/core": "0.17.0"
|
||||
},
|
||||
"keywords": [
|
||||
"accordion",
|
||||
"lion",
|
||||
"web-components"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"customElementsManifest": "custom-elements.json",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./docs/": "./docs/"
|
||||
}
|
||||
}
|
||||
|
|
@ -165,6 +165,52 @@ describe('generateExtendDocsConfig', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('can handle exports with multiple lines', async () => {
|
||||
const result = await execute('fixtures/multi-line');
|
||||
|
||||
expect(result).to.deep.equal([
|
||||
{
|
||||
name: '@lion/core - html',
|
||||
variable: {
|
||||
from: 'html',
|
||||
to: 'html',
|
||||
paths: [
|
||||
{
|
||||
from: '@lion/core',
|
||||
to: 'ing-web/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '@lion/core - CSSResult',
|
||||
variable: {
|
||||
from: 'CSSResult',
|
||||
to: 'CSSResult',
|
||||
paths: [
|
||||
{
|
||||
from: '@lion/core',
|
||||
to: 'ing-web/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '@lion/core - adoptStyles',
|
||||
variable: {
|
||||
from: 'adoptStyles',
|
||||
to: 'adoptStyles',
|
||||
paths: [
|
||||
{
|
||||
from: '@lion/core',
|
||||
to: 'ing-web/core',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('can customize the target', async () => {
|
||||
const result = await execute('fixtures/accordion', {
|
||||
classPrefix: 'Wolf',
|
||||
|
|
|
|||
Loading…
Reference in a new issue