diff --git a/__tests__/__snapshots__/bin.js.snap b/__tests__/__snapshots__/bin.js.snap index 04c9b6fcc..bbdce4280 100644 --- a/__tests__/__snapshots__/bin.js.snap +++ b/__tests__/__snapshots__/bin.js.snap @@ -2,16 +2,16 @@ exports[`--config 1`] = ` " - + - + documentation | Documentation - - - - - + + + + +
@@ -23,6 +23,9 @@ exports[`--config 1`] = ` placeholder='Filter' id='filter-input' class='col12 block input' + spellcheck='false' + autocapitalize='off' + autocorrect='off' type='text' />
@@ -229,54 +242,16 @@ exports[`--config 1`] = `
-
-
+
-

- Highlighted section -

- - -

The public key is a base64 encoded string of a protobuf containing an RSA DER -buffer. This uses a node buffer to pass the base64 encoded public key protobuf -to the multihash for ID generation.

-
var PeerId = require('peer-id')
-
-PeerId.create({ bits: 1024 }, (err, id) => {
-  console.log(JSON.stringify(id.toJSON(), null, 2)
-})
-
{
-  \\"id\\": \\"Qma9T5YraSnpRDZqRR4krcSJabThc8nwZuJV3LercPHufi\\",
-  \\"privKey\\": \\"CAAS4AQwggJcAgEAAoGBAMBgbIqyOL26oV3nGPBYrdpbv..\\",
-  \\"pubKey\\": \\"CAASogEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMBgbIqyOL26oV3nGPBYrdpbvzCY...\\"
-}
-
- - -
-
- -
+

+ Highlighted section +

-
- -

- Highlighted section -

- - -
- - -

The public key is a base64 encoded string of a protobuf containing an RSA DER +

The public key is a base64 encoded string of a protobuf containing an RSA DER buffer. This uses a node buffer to pass the base64 encoded public key protobuf to the multihash for ID generation.

-
var PeerId = require('peer-id')
-
-PeerId.create({ bits: 1024 }, (err, id) => {
-  console.log(JSON.stringify(id.toJSON(), null, 2)
-})
{
   \\"id\\": \\"Qma9T5YraSnpRDZqRR4krcSJabThc8nwZuJV3LercPHufi\\",
   \\"privKey\\": \\"CAAS4AQwggJcAgEAAoGBAMBgbIqyOL26oV3nGPBYrdpbv..\\",
@@ -284,35 +259,9 @@ PeerId.create({ bits: 
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- +
+
@@ -330,10 +279,7 @@ PeerId.create({ bits: Creates a new Klass

- -
new Klass(foo: any)
-

@@ -375,6 +321,8 @@ PeerId.create({ bits: Static Members

@@ -394,10 +342,7 @@ PeerId.create({ bits: Klass This is a [link to something that does not exist]DoesNot

- -
isClass(other: Object, also: any): boolean
- @@ -452,6 +397,10 @@ This is a [link to something that does not exist]DoesNot
@@ -472,10 +421,7 @@ This is a [link to something that does not exist]DoesNotA function that triggers the case where the autolinker doesn't find the referenced class type

- -
- @@ -522,6 +468,10 @@ the referenced class type

+ + + +
@@ -541,10 +491,7 @@ the referenced class type

This method takes a Buffer object that will be linked to nodejs.org

- -
isBuffer(buf: (Buffer | string), size: number): boolean
- @@ -601,6 +548,10 @@ the referenced class type

+ + + +
@@ -620,10 +571,7 @@ the referenced class type

This method takes an array of buffers and counts them

- -
isArrayOfBuffers(buffers: Array<Buffer>): number
- @@ -665,6 +613,8 @@ the referenced class type

+ +
Example
@@ -678,6 +628,8 @@ k.isArrayOfBuffers(); + + @@ -697,10 +649,7 @@ k.isArrayOfBuffers();

A magic number that identifies this Klass.

- -
MAGIC_NUMBER
- @@ -721,6 +670,10 @@ k.isArrayOfBuffers(); + + + + @@ -753,10 +706,7 @@ k.isArrayOfBuffers();

Get this Klass's foo

- -
getFoo(): Number
- @@ -784,6 +734,8 @@ k.isArrayOfBuffers(); + +
Example

this shows you how to getFoo

@@ -797,6 +749,8 @@ k.isArrayOfBuffers(); + + @@ -816,10 +770,7 @@ k.isArrayOfBuffers();

A function with an options parameter

- -
withOptions(options: Object, otherOptions: number?)
- @@ -898,6 +849,10 @@ k.isArrayOfBuffers(); + + + + @@ -917,10 +872,7 @@ k.isArrayOfBuffers();

A function with a deep options parameter

- -
withDeepOptions(options: Object)
- @@ -1001,6 +953,10 @@ k.isArrayOfBuffers(); + + + + @@ -1011,6 +967,8 @@ k.isArrayOfBuffers(); + +
Events
@@ -1028,10 +986,7 @@ k.isArrayOfBuffers();

Klass event

- -
event
- @@ -1052,6 +1007,10 @@ k.isArrayOfBuffers(); + + + + @@ -1067,6 +1026,7 @@ k.isArrayOfBuffers(); +
@@ -1084,10 +1044,7 @@ k.isArrayOfBuffers();

a typedef with nested properties

- -
CustomError
- @@ -1139,8 +1096,13 @@ k.isArrayOfBuffers(); + + + +
+
@@ -1160,10 +1122,7 @@ k.isArrayOfBuffers(); a klass instance multiword, like a klass

- -
bar(): Klass
- @@ -1197,8 +1156,13 @@ like a klass

+ + + +
+
@@ -1206,8 +1170,8 @@ like a klass

-

- bar +

+ bar2

@@ -1216,10 +1180,7 @@ like a klass

Rest property function

- - -
bar(toys: ...Number): undefined
- +
bar2(toys: ...Number): undefined
@@ -1266,8 +1227,13 @@ like a klass

+ + + +
+
@@ -1275,8 +1241,8 @@ like a klass

+ + + + + + + + +
+ + + + +
+ + +
+ +

+ tableObj +

+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
Col 1Col 2Col 3
Dat 1Dat 2Dat 3
Dat 4Dat 5Dat 6
+ +
tableObj
+ + + + + + + + + + + + + + + + + + + + + + + @@ -1530,6 +1573,7 @@ like a
klass. This needs a +
@@ -1573,6 +1617,7 @@ Array [ "type": "root", }, "examples": Array [], + "implements": Array [], "kind": "function", "loc": Object { "end": Object { @@ -1606,6 +1651,7 @@ Array [ "tags": Array [], "throws": Array [], "todos": Array [], + "yields": Array [], }, Object { "augments": Array [], @@ -1637,6 +1683,7 @@ Array [ "type": "root", }, "examples": Array [], + "implements": Array [], "kind": "function", "loc": Object { "end": Object { @@ -1670,6 +1717,7 @@ Array [ "tags": Array [], "throws": Array [], "todos": Array [], + "yields": Array [], }, Object { "augments": Array [], @@ -1701,6 +1749,7 @@ Array [ "type": "root", }, "examples": Array [], + "implements": Array [], "kind": "function", "loc": Object { "end": Object { @@ -1734,6 +1783,7 @@ Array [ "tags": Array [], "throws": Array [], "todos": Array [], + "yields": Array [], }, ] `; diff --git a/__tests__/bin.js b/__tests__/bin.js index 2bdf2359c..36048086e 100644 --- a/__tests__/bin.js +++ b/__tests__/bin.js @@ -5,6 +5,10 @@ import os from 'os'; import { exec } from 'child_process'; import tmp from 'tmp'; import fs from 'fs-extra'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); function documentation(args, options, parseJSON) { if (!options) { @@ -44,7 +48,7 @@ function normalize(result) { return result; } -test.skip('documentation binary', async function () { +test('documentation binary', async function () { const data = await documentation(['build fixture/simple.input.js'], {}); expect(data.length).toBe(1); }); @@ -56,14 +60,14 @@ test.skip('defaults to parsing package.json main', async function () { expect(data.length).toBeTruthy(); }); -test.skip('accepts config file', async function () { +test('accepts config file', async function () { const data = await documentation([ 'build fixture/sorting/input.js -c fixture/config.json' ]); expect(normalize(data)).toMatchSnapshot(); }); -test.skip('accepts config file - reports failures', async function () { +test('accepts config file - reports failures', async function () { try { await documentation( ['build fixture/sorting/input.js -c fixture/config-bad.yml'], @@ -75,7 +79,7 @@ test.skip('accepts config file - reports failures', async function () { } }); -test.skip('accepts config file - reports parse failures', async function () { +test('accepts config file - reports parse failures', async function () { try { await documentation( ['build fixture/sorting/input.js -c fixture/config-malformed.json'], @@ -87,14 +91,14 @@ test.skip('accepts config file - reports parse failures', async function () { } }); -test.skip('--shallow option', async function () { +test('--shallow option', async function () { const data = await documentation([ 'build --shallow fixture/internal.input.js' ]); expect(data.length).toBe(0); }); -test.skip('external modules option', async function () { +test('external modules option', async function () { const data = await documentation([ 'build fixture/external.input.js ' + '--external=external --external=external/node_modules' @@ -102,14 +106,14 @@ test.skip('external modules option', async function () { expect(data.length).toBe(2); }); -test.skip('when a file is specified both in a glob and explicitly, it is only documented once', async function () { +test('when a file is specified both in a glob and explicitly, it is only documented once', async function () { const data = await documentation([ 'build fixture/simple.input.js fixture/simple.input.*' ]); expect(data.length).toBe(1); }); -test.skip('extension option', async function () { +test('extension option', async function () { const data = await documentation([ 'build fixture/extension/index.otherextension ' + '--requireExtension=otherextension --parseExtension=otherextension' @@ -117,12 +121,12 @@ test.skip('extension option', async function () { expect(data.length).toBe(1); }); -test.skip('extension option', function () { +test('extension option', function () { return documentation(['build fixture/extension.jsx']); }); describe('invalid arguments', function () { - test.skip('bad -f option', async function () { + test('bad -f option', async function () { try { await documentation( ['build -f DOES-NOT-EXIST fixture/internal.input.js'], @@ -134,7 +138,7 @@ describe('invalid arguments', function () { } }); - test.skip('html with no destination', async function () { + test('html with no destination', async function () { try { await documentation(['build -f html fixture/internal.input.js']); } catch (err) { @@ -148,7 +152,7 @@ describe('invalid arguments', function () { } }); - test.skip('bad command', async function () { + test('bad command', async function () { try { await documentation(['-f html fixture/internal.input.js'], {}, false); } catch (err) { @@ -159,7 +163,7 @@ describe('invalid arguments', function () { const semver = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi; -test.skip('--config', async function () { +test('--config', async function () { const dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString()); fs.mkdirSync(dst); const outputIndex = path.join(dst, 'index.html'); @@ -172,18 +176,18 @@ test.skip('--config', async function () { false ); let output = fs.readFileSync(outputIndex, 'utf8'); - const version = require('../package.json').version; + const version = (await import('../package.json')).default.version; output = output.replace(new RegExp(version.replace(/\./g, '\\.'), 'g'), ''); expect(output).toMatchSnapshot(); }); -test.skip('--version', async function () { +test('--version', async function () { const output = await documentation(['--version'], {}, false); expect(output).toBeTruthy(); }); describe('lint command', function () { - test.skip('generates lint output', async function () { + test('generates lint output', async function () { try { await documentation(['lint fixture/lint/lint.input.js'], {}, false); } catch (err) { @@ -192,7 +196,7 @@ describe('lint command', function () { } }); - test.skip('generates no output on a good file', async function () { + test('generates no output on a good file', async function () { const data = await documentation( ['lint fixture/simple.input.js'], {}, @@ -201,7 +205,7 @@ describe('lint command', function () { expect(data).toBe(''); }); - test.skip('exposes syntax error on a bad file', async function () { + test('exposes syntax error on a bad file', async function () { try { await documentation( ['lint fixture/bad/syntax.input', '--parseExtension input'], @@ -213,7 +217,7 @@ describe('lint command', function () { } }); - test.skip('lint with no inputs', async function () { + test('lint with no inputs', async function () { try { await documentation( ['lint'], @@ -227,7 +231,7 @@ describe('lint command', function () { } }); - test.skip('generates lint output with shallow', async function () { + test('generates lint output with shallow', async function () { const data = await documentation( ['lint fixture/lint/lint.input.shallow.js --shallow'], {}, @@ -237,7 +241,7 @@ describe('lint command', function () { }); }); -test.skip('given no files', async function () { +test('given no files', async function () { try { await documentation(['build']); } catch (err) { @@ -251,7 +255,7 @@ test.skip('given no files', async function () { } }); -test.skip('with an invalid command', async function () { +test('with an invalid command', async function () { try { await documentation(['invalid'], {}, false); } catch (err) { diff --git a/__tests__/test.js b/__tests__/test.js index 6ab6cb194..241cd4389 100644 --- a/__tests__/test.js +++ b/__tests__/test.js @@ -106,15 +106,9 @@ describe('html', function () { const result = await documentation.build([file], options); const html = await outputHtml(result, {}); const clean = html - .sort((a, b) => a.path > b.path) - .filter(r => r.path.match(/(html)$/)) - .map(r => - r.contents - .toString() - .replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '') - .replace(/\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, '') - ) - .join('\n'); + .replace(/documentation \d+\.\d+\.\d+(-\w+(\.\d+)?)?/g, '') + .replace(/\d+\.\d+\.\d+(-\w+(\.\d+)?)?<\/code>/g, ''); + expect(clean).toMatchSnapshot(); }); }); diff --git a/package-lock.json b/package-lock.json index e23d0eb29..c29bc179b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1199,14 +1199,6 @@ "picomatch": "^2.0.4" } }, - "append-buffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", - "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", - "requires": { - "buffer-equal": "^1.0.0" - } - }, "arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", @@ -1402,11 +1394,6 @@ "node-int64": "^0.4.0" } }, - "buffer-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", - "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=" - }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -2360,14 +2347,6 @@ "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", "dev": true }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "requires": { - "object-keys": "^1.0.12" - } - }, "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", @@ -2547,46 +2526,6 @@ } } }, - "duplexify": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", - "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", - "requires": { - "end-of-stream": "^1.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.0.0", - "stream-shift": "^1.0.0" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "electron-to-chromium": { "version": "1.3.867", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.867.tgz", @@ -2603,14 +2542,6 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "requires": { - "once": "^1.4.0" - } - }, "enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", @@ -3156,44 +3087,6 @@ "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", "dev": true }, - "flush-write-stream": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", - "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", - "requires": { - "inherits": "^2.0.3", - "readable-stream": "^2.3.6" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "form-data": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", @@ -3242,15 +3135,6 @@ } } }, - "fs-mkdirp-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", - "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", - "requires": { - "graceful-fs": "^4.1.11", - "through2": "^2.0.3" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3448,69 +3332,6 @@ "is-glob": "^4.0.1" } }, - "glob-stream": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", - "requires": { - "extend": "^3.0.0", - "glob": "^7.1.1", - "glob-parent": "^3.1.0", - "is-negated-glob": "^1.0.0", - "ordered-read-streams": "^1.0.0", - "pumpify": "^1.3.5", - "readable-stream": "^2.1.5", - "remove-trailing-separator": "^1.0.1", - "to-absolute-glob": "^2.0.0", - "unique-stream": "^2.0.2" - }, - "dependencies": { - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - } - }, - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "requires": { - "is-extglob": "^2.1.0" - } - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -4038,11 +3859,6 @@ "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.0.tgz", "integrity": "sha512-vGOtYkiaxwIiR0+Ng/zNId+ZZehGfINwTzdrDqc6iubbnQWhnPuYymOzOKUDqa2cSl59yHnEh2h6MvRLQsyNug==" }, - "is-negated-glob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", - "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=" - }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -4117,12 +3933,8 @@ "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" - }, - "is-valid-glob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", - "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=" + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true }, "is-windows": { "version": "1.0.2", @@ -4859,7 +4671,8 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true }, "json-stringify-safe": { "version": "5.0.1", @@ -4908,51 +4721,6 @@ "@babel/traverse": "^7.10.5" } }, - "lazystream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", - "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", - "requires": { - "readable-stream": "^2.0.5" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "lead": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", - "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", - "requires": { - "flush-write-stream": "^1.0.2" - } - }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -6268,14 +6036,6 @@ "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==" }, - "now-and-later": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/now-and-later/-/now-and-later-2.0.1.tgz", - "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", - "requires": { - "once": "^1.3.2" - } - }, "npm-run-path": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", @@ -6306,22 +6066,6 @@ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", "integrity": "sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==" }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -6359,43 +6103,6 @@ "word-wrap": "^1.2.3" } }, - "ordered-read-streams": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", - "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", - "requires": { - "readable-stream": "^2.0.1" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", @@ -6533,11 +6240,6 @@ "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", "dev": true }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=" - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -6721,25 +6423,6 @@ "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", "dev": true }, - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "pumpify": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", - "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", - "requires": { - "duplexify": "^3.6.0", - "inherits": "^2.0.3", - "pump": "^2.0.0" - } - }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -7063,32 +6746,6 @@ "unified": "^10.0.0" } }, - "remove-bom-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz", - "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", - "requires": { - "is-buffer": "^1.1.5", - "is-utf8": "^0.2.1" - }, - "dependencies": { - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" - } - } - }, - "remove-bom-stream": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", - "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", - "requires": { - "remove-bom-buffer": "^3.0.0", - "safe-buffer": "^5.1.0", - "through2": "^2.0.3" - } - }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -7148,14 +6805,6 @@ "global-dirs": "^0.1.1" } }, - "resolve-options": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", - "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", - "requires": { - "value-or-function": "^3.0.0" - } - }, "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -7563,11 +7212,6 @@ } } }, - "stream-shift": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", - "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" - }, "strict-uri-encode": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", @@ -7831,15 +7475,6 @@ } } }, - "through2-filter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/through2-filter/-/through2-filter-3.0.0.tgz", - "integrity": "sha512-jaRjI2WxN3W1V8/FMZ9HKIBXixtiqs3SQSX4/YGIiP3gL6djW48VoZq9tDqeCWs3MT8YY5wb/zli8VW8snY1CA==", - "requires": { - "through2": "~2.0.0", - "xtend": "~4.0.0" - } - }, "tiny-lr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-2.0.0.tgz", @@ -7878,15 +7513,6 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, - "to-absolute-glob": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", - "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", - "requires": { - "is-absolute": "^1.0.0", - "is-negated-glob": "^1.0.0" - } - }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -7900,14 +7526,6 @@ "is-number": "^7.0.0" } }, - "to-through": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", - "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", - "requires": { - "through2": "^2.0.3" - } - }, "totalist": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/totalist/-/totalist-2.0.0.tgz", @@ -8047,15 +7665,6 @@ } } }, - "unique-stream": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", - "integrity": "sha512-2nY4TnBE70yoxHkDli7DMazpWiP7xMdCYqU2nBRO0UB+ZpEkGsSija7MvmvnZFUeC+mrgiUfcHSr3LmRFIg4+A==", - "requires": { - "json-stable-stringify-without-jsonify": "^1.0.1", - "through2-filter": "^3.0.0" - } - }, "unist-builder": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-2.0.3.tgz", @@ -8176,11 +7785,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "value-or-function": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", - "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=" - }, "vfile": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.1.1.tgz", @@ -8347,83 +7951,6 @@ "replace-ext": "^1.0.0" } }, - "vinyl-fs": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", - "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==", - "requires": { - "fs-mkdirp-stream": "^1.0.0", - "glob-stream": "^6.1.0", - "graceful-fs": "^4.0.0", - "is-valid-glob": "^1.0.0", - "lazystream": "^1.0.0", - "lead": "^1.0.0", - "object.assign": "^4.0.4", - "pumpify": "^1.3.5", - "readable-stream": "^2.3.3", - "remove-bom-buffer": "^3.0.0", - "remove-bom-stream": "^1.2.0", - "resolve-options": "^1.1.0", - "through2": "^2.0.0", - "to-through": "^2.0.0", - "value-or-function": "^3.0.0", - "vinyl": "^2.0.0", - "vinyl-sourcemap": "^1.1.0" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "vinyl-sourcemap": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", - "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", - "requires": { - "append-buffer": "^1.0.2", - "convert-source-map": "^1.5.0", - "graceful-fs": "^4.1.6", - "normalize-path": "^2.1.1", - "now-and-later": "^2.0.0", - "remove-bom-buffer": "^3.0.0", - "vinyl": "^2.0.0" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, "vue-template-compiler": { "version": "2.6.14", "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz", diff --git a/package.json b/package.json index 2481c3479..dc1be9959 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "vfile-reporter": "^7.0.2", "vfile-sort": "^3.0.0", "vinyl": "^2.1.0", - "vinyl-fs": "^3.0.2", "yargs": "^17.2.1" }, "optionalDependencies": { diff --git a/src/commands/build.js b/src/commands/build.js index 48eebe12c..264b1205e 100644 --- a/src/commands/build.js +++ b/src/commands/build.js @@ -1,8 +1,6 @@ -import streamArray from 'stream-array'; import { sharedOutputOptions, sharedInputOptions } from './shared_options.js'; import path from 'path'; import fs from 'fs'; -import vfs from 'vinyl-fs'; import chokidar from 'chokidar'; import * as documentation from '../index.js'; import _ from 'lodash'; @@ -79,6 +77,10 @@ const handler = function build(argv) { updateWatcher(); } + if (!output) { + return; + } + if (argv.output === 'stdout') { if (argv.watch) { // In watch mode, clear the screen first to make updated outputs @@ -86,8 +88,6 @@ const handler = function build(argv) { process.stdout.write('\u001b[2J'); } process.stdout.write(output); - } else if (Array.isArray(output)) { - streamArray(output).pipe(vfs.dest(argv.output)); } else { fs.writeFileSync(argv.output, output); } diff --git a/src/default_theme/index.js b/src/default_theme/index.js index 169d66e62..dcd7ded70 100644 --- a/src/default_theme/index.js +++ b/src/default_theme/index.js @@ -1,11 +1,8 @@ -import fs from 'fs'; +import fs from 'fs/promises'; import path from 'path'; -import File from 'vinyl'; -import vfs from 'vinyl-fs'; -import _ from 'lodash'; -import concat from 'concat-stream'; +import template from 'lodash/template.js'; import GithubSlugger from 'github-slugger'; -import { util } from '../index'; +import { util } from '../index.js'; import hljs from 'highlight.js'; import { fileURLToPath } from 'url'; @@ -14,6 +11,20 @@ const __dirname = path.dirname(__filename); const { LinkerStack, createFormatters } = util; +async function copyDir(sorce, dest) { + await fs.mkdir(dest, { recursive: true }); + let entries = await fs.readdir(sorce, { withFileTypes: true }); + + for (let entry of entries) { + let srcPath = path.join(sorce, entry.name); + let destPath = path.join(dest, entry.name); + + entry.isDirectory() + ? await copyDir(srcPath, destPath) + : await fs.copyFile(srcPath, destPath); + } +} + function isFunction(section) { return ( section.kind === 'function' || @@ -24,7 +35,7 @@ function isFunction(section) { ); } -export default function (comments, config) { +export default async function (comments, config) { var linkerStack = new LinkerStack(config).namespaceResolver( comments, function (namespace) { @@ -90,47 +101,34 @@ export default function (comments, config) { } }; - sharedImports.imports.renderSectionList = _.template( - fs.readFileSync(path.join(__dirname, 'section_list._'), 'utf8'), + sharedImports.imports.renderSectionList = template( + await fs.readFile(path.join(__dirname, 'section_list._'), 'utf8'), sharedImports ); - sharedImports.imports.renderSection = _.template( - fs.readFileSync(path.join(__dirname, 'section._'), 'utf8'), + sharedImports.imports.renderSection = template( + await fs.readFile(path.join(__dirname, 'section._'), 'utf8'), sharedImports ); - sharedImports.imports.renderNote = _.template( - fs.readFileSync(path.join(__dirname, 'note._'), 'utf8'), + sharedImports.imports.renderNote = template( + await fs.readFile(path.join(__dirname, 'note._'), 'utf8'), sharedImports ); - sharedImports.imports.renderParamProperty = _.template( - fs.readFileSync(path.join(__dirname, 'paramProperty._'), 'utf8'), + sharedImports.imports.renderParamProperty = template( + await fs.readFile(path.join(__dirname, 'paramProperty._'), 'utf8'), sharedImports ); - var pageTemplate = _.template( - fs.readFileSync(path.join(__dirname, 'index._'), 'utf8'), + var pageTemplate = template( + await fs.readFile(path.join(__dirname, 'index._'), 'utf8'), sharedImports ); - // push assets into the pipeline as well. - return new Promise(resolve => { - vfs.src([__dirname + '/assets/**'], { base: __dirname }).pipe( - concat(function (files) { - resolve( - files.concat( - new File({ - path: 'index.html', - contents: Buffer.from( - pageTemplate({ - docs: comments, - config - }), - 'utf8' - ) - }) - ) - ); - }) - ); - }); + const string = pageTemplate({ docs: comments, config }); + + if (!config.output) { + return string; + } + + await copyDir(__dirname + '/assets/', config.output + '/assets/'); + await fs.writeFile(config.output + '/index.html', string, 'utf8'); } diff --git a/src/extractors/comments.js b/src/extractors/comments.js index 6f609f167..2ab7dc884 100644 --- a/src/extractors/comments.js +++ b/src/extractors/comments.js @@ -1,7 +1,7 @@ import babelTraverse from '@babel/traverse'; import isJSDocComment from '../is_jsdoc_comment.js'; -const traverse = babelTraverse.default; +const traverse = babelTraverse.default || babelTraverse; /** * Iterate through the abstract syntax tree, finding a different kind of comment diff --git a/src/extractors/exported.js b/src/extractors/exported.js index 6e681dc76..4470cb452 100644 --- a/src/extractors/exported.js +++ b/src/extractors/exported.js @@ -8,7 +8,7 @@ import findTarget from '../infer/finders.js'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); -const traverse = babelTraverse.default; +const traverse = babelTraverse.default || babelTraverse; /** * Iterate through the abstract syntax tree, finding ES6-style exports, diff --git a/src/flow_doctrine.js b/src/flow_doctrine.js index 909676032..f81f2ffc8 100644 --- a/src/flow_doctrine.js +++ b/src/flow_doctrine.js @@ -1,5 +1,5 @@ import generator from '@babel/generator'; -const generate = generator.default; +const generate = generator.default || generator; const namedTypes = { NumberTypeAnnotation: 'number', diff --git a/src/infer/augments.js b/src/infer/augments.js index b9556f905..f310c167b 100644 --- a/src/infer/augments.js +++ b/src/infer/augments.js @@ -1,7 +1,7 @@ import babelGenerate from '@babel/generator'; import findTarget from './finders.js'; -const generate = babelGenerate.default; +const generate = babelGenerate.default || babelGenerate; /** * Infers an `augments` tag from an ES6 class declaration diff --git a/src/infer/implements.js b/src/infer/implements.js index 82208308c..26240898e 100644 --- a/src/infer/implements.js +++ b/src/infer/implements.js @@ -1,7 +1,7 @@ import babelGenerate from '@babel/generator'; import findTarget from './finders.js'; -const generate = babelGenerate.default; +const generate = babelGenerate.default || babelGenerate; /** * Infers an `augments` tag from an ES6 class declaration diff --git a/src/infer/params.js b/src/infer/params.js index afc328185..2103af6df 100644 --- a/src/infer/params.js +++ b/src/infer/params.js @@ -4,7 +4,7 @@ import _ from 'lodash'; import findTarget from './finders.js'; import typeAnnotation from '../type_annotation.js'; -const generate = babelGenerate.default; +const generate = babelGenerate.default || babelGenerate; /** * Infers param tags by reading function parameter names diff --git a/src/output/html.js b/src/output/html.js index 485c2b27b..ead58f67d 100644 --- a/src/output/html.js +++ b/src/output/html.js @@ -23,9 +23,10 @@ import mergeConfig from '../merge_config.js'; */ export default async function html(comments, localConfig = {}) { const config = await mergeConfig(localConfig); - const themePath = - (config.theme && path.resolve(process.cwd(), config.theme)) || - '../default_theme/index.js'; + const themePath = config.theme && path.resolve(process.cwd(), config.theme); + if (themePath) { + return (await import(themePath)).default(comments, config); + } - return (await import(themePath)).default(comments, config); + return (await import('../default_theme/index.js')).default(comments, config); } diff --git a/src/ts_doctrine.js b/src/ts_doctrine.js index 43c38b07f..d31a0a50b 100644 --- a/src/ts_doctrine.js +++ b/src/ts_doctrine.js @@ -1,5 +1,5 @@ import generator from '@babel/generator'; -const generate = generator.default; +const generate = generator.default || generator; const namedTypes = { TSBigIntKeyword: 'bigint',