From 769c23cd51e6180ea2a41d1c64a76ac1d9677192 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Fri, 30 Aug 2024 17:27:15 +0100 Subject: [PATCH] ci --- .github/workflows/node.js.yml | 8 +++++--- index.js | 10 ++++++++-- lib/dmd-options.js | 13 +++++++++---- test/api.js | 8 ++++++++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9697de9..550c616 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -4,7 +4,7 @@ name: Node.js CI on: push: - branches: [ master ] + branches: [ master, next ] pull_request: branches: [ master ] @@ -15,8 +15,10 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest] - node-version: [12, 14, 16, 18, 20, 22] + # os: [ubuntu-latest, windows-latest] + # node-version: [12, 14, 16, 18, 20, 22] + os: [windows-latest] + node-version: [22] steps: - uses: actions/checkout@v4 diff --git a/index.js b/index.js index b7c76e4..db24cab 100644 --- a/index.js +++ b/index.js @@ -121,8 +121,14 @@ async function generate (templateData, options) { }) templateData.options = options const output = compiled(templateData) - dmd.cache.writeSync([inputData, inputOptions, dmdVersion], output) - return output + + const adjOutput = output + // const lines = output.split(/\r?\n/) + // const adjOutput = lines.join(options.EOL) + // console.log(JSON.stringify(adjOutput)) + + dmd.cache.writeSync([inputData, inputOptions, dmdVersion], adjOutput) + return adjOutput } /* always skip the cache when custom plugins, partials or helpers are used */ diff --git a/lib/dmd-options.js b/lib/dmd-options.js index df839cf..75b4018 100644 --- a/lib/dmd-options.js +++ b/lib/dmd-options.js @@ -1,9 +1,9 @@ /** * @typicalname options */ -function DmdOptions (options) { +function DmdOptions (options = {}) { const arrayify = require('array-back') - options = options || {} + const os = require('os') /** * The template the supplied documentation will be rendered into. Use the default or supply your own template for full control over the output. @@ -81,14 +81,14 @@ function DmdOptions (options) { this['member-index-format'] = 'grouped' /** - * If true, \{@link XXX} tags are rendered in normal text if XXX is a URL and monospace (code) format otherwise. + * By default, all {@link} tags are rendered in plain text. If `--clever-links` is set, URL {@link} tags are rendered in plain text, otherwise monospace. * @type {boolean} * @dafult */ this['clever-links'] = false /** - * If true, all \{@link} tags are rendered in monospace (code) format. This setting is ignored in `clever-links` is true. + * By default, all {@link} tags are rendered in plain text. If `--monospace-links` is set, all links are rendered in monospace format. This setting is ignored if `--clever-links` is set. * @type {boolean} * @default */ @@ -130,6 +130,11 @@ function DmdOptions (options) { * @type {array} */ this.partial = arrayify(options.partial) + + /** + * Specify the EOL to be used in dmd output. Defaults to `os.EOL` (your local system default). + */ + this.EOL = options.EOL || os.EOL } module.exports = DmdOptions diff --git a/test/api.js b/test/api.js index 4e83311..76870a3 100644 --- a/test/api.js +++ b/test/api.js @@ -24,6 +24,7 @@ test.set('dmd.async() again to exercise the cache', async function () { test.set('dmd.async({ noCache }) returns correct data', async function () { const options = { noCache: true } const result = await dmd(fixture, options) + console.log(JSON.stringify(result)) a.ok(/is a class/.test(result)) }) @@ -53,4 +54,11 @@ test.set('Dmd issue #89 - Max callstack size exceeded bug', async function () { a.doesNotReject(() => dmd(templateData, options)) }) +skip.set('dmd.async({ noCache }) with custom line endings', async function () { + const options = { noCache: true, EOL: "++" } + const result = await dmd(fixture, options) + a.equal(result, '++++## someclass++is a class++++') +}) + + module.exports = { test, only, skip }