adapt-authoring-docs 1.3.0 → 1.3.1
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.
- package/docsify/docsify.js +1 -1
- package/package.json +1 -1
- package/tests/docsify.spec.js +3 -16
package/docsify/docsify.js
CHANGED
|
@@ -23,7 +23,7 @@ function generateSectionTitle (sectionName) {
|
|
|
23
23
|
export default async function docsify (app, configs, outputdir, defaultPages) {
|
|
24
24
|
const dir = path.resolve(outputdir, 'manual')
|
|
25
25
|
const sectionsConf = app.config.get('adapt-authoring-docs.manualSections')
|
|
26
|
-
const defaultSection = Object.entries(sectionsConf).
|
|
26
|
+
const defaultSection = Object.entries(sectionsConf).find(([, data]) => data.default)?.[0]
|
|
27
27
|
/**
|
|
28
28
|
* init docsify folder
|
|
29
29
|
*/
|
package/package.json
CHANGED
package/tests/docsify.spec.js
CHANGED
|
@@ -205,18 +205,7 @@ describe('docsify', () => {
|
|
|
205
205
|
})
|
|
206
206
|
|
|
207
207
|
describe('bugs', () => {
|
|
208
|
-
it('
|
|
209
|
-
// BUG: In docsify.js line 26, Object.entries(sectionsConf).reduce((m, [id, data]) => ...)
|
|
210
|
-
// has no initial value. When there is only one section entry, reduce() returns
|
|
211
|
-
// the entry itself (an [id, data] array) without calling the callback.
|
|
212
|
-
// This causes generateSectionTitle to fail with:
|
|
213
|
-
// TypeError: sectionName.slice(...).replaceAll is not a function
|
|
214
|
-
// because sectionName is an array, not a string.
|
|
215
|
-
//
|
|
216
|
-
// To fix: add an initial value to reduce, e.g.:
|
|
217
|
-
// Object.entries(sectionsConf).reduce((m, [id, data]) => data.default ? id : m, undefined)
|
|
218
|
-
// or use Array.find instead:
|
|
219
|
-
// Object.entries(sectionsConf).find(([, data]) => data.default)?.[0]
|
|
208
|
+
it('defaultSection reduce with single entry returns string section name', async () => {
|
|
220
209
|
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'docsify-test-'))
|
|
221
210
|
const outputDir = tmpDir
|
|
222
211
|
const docsSrcDir = await fs.mkdtemp(path.join(os.tmpdir(), 'docsify-src-'))
|
|
@@ -238,10 +227,8 @@ describe('docsify', () => {
|
|
|
238
227
|
}]
|
|
239
228
|
|
|
240
229
|
const { default: docsify } = await import('../docsify/docsify.js')
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
() => docsify(mockApp, configs, outputDir, {}),
|
|
244
|
-
TypeError
|
|
230
|
+
await assert.doesNotReject(
|
|
231
|
+
() => docsify(mockApp, configs, outputDir, {})
|
|
245
232
|
)
|
|
246
233
|
|
|
247
234
|
await fs.rm(docsSrcDir, { recursive: true, force: true })
|