web-documentation 1.0.40 → 1.0.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-documentation",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "Declarative multilanguage documentation website generator",
5
5
  "keywords": [
6
6
  "documentation",
@@ -150,6 +150,10 @@
150
150
  },
151
151
  "library": false,
152
152
  "module": {
153
+ "aliases": {
154
+ "web-component-wrapper/decorator$": "web-component-wrapper/compatible/decorator",
155
+ "web-component-wrapper/Web": "web-component-wrapper/compatible/Web"
156
+ },
153
157
  "enforceDeduplication": true,
154
158
  "html": {
155
159
  "options": {
package/source/deploy.ts CHANGED
@@ -50,14 +50,13 @@ export interface WebDocumentationConfiguration {
50
50
  tagline?: string
51
51
  trackingCode?: string
52
52
  }
53
-
54
- interface MAKE_TEMPORARY_FILE_OPTIONS {
53
+ interface MakeTemporaryFileOptions {
55
54
  directory: boolean
56
55
  encoding?: BufferEncoding | null
57
56
  extension: string
58
57
  prefix: string
59
58
  }
60
- interface SCOPE_TYPE extends Mapping<unknown> {
59
+ interface PackageConfiguration extends Mapping<unknown> {
61
60
  description?: string
62
61
  webDocumentation?: WebDocumentationConfiguration
63
62
  files?: Array<string>
@@ -105,7 +104,8 @@ const DOCUMENTATION_WEBSITE_REPOSITORY =
105
104
  // `git@github.com:thaibault/${DOCUMENTATION_WEBSITE_NAME}`
106
105
  `https://github.com/thaibault/${DOCUMENTATION_WEBSITE_NAME}.git`
107
106
  const PROJECT_PAGE_COMMIT_MESSAGE = 'Update project homepage content.'
108
- let SCOPE: SCOPE_TYPE = {name: '__dummy__', version: '1.0.0'}
107
+ let PACKAGE_CONFIGURATION: PackageConfiguration =
108
+ {name: '__dummy__', version: '1.0.0'}
109
109
  let HAS_API_DOCUMENTATION = false
110
110
  // endregion
111
111
  // region functions
@@ -116,9 +116,9 @@ let HAS_API_DOCUMENTATION = false
116
116
  * @returns Determined file path.
117
117
  */
118
118
  const makeTemporaryFile = async (
119
- givenOptions: Partial<MAKE_TEMPORARY_FILE_OPTIONS> = {}
119
+ givenOptions: Partial<MakeTemporaryFileOptions> = {}
120
120
  ): Promise<string> => {
121
- const options: MAKE_TEMPORARY_FILE_OPTIONS = {
121
+ const options: MakeTemporaryFileOptions = {
122
122
  directory: false,
123
123
  encoding: 'utf8',
124
124
  extension: '',
@@ -243,13 +243,13 @@ const generateAndPushNewDocumentationPage = async (
243
243
 
244
244
  let parameters: Mapping<unknown> = {}
245
245
  for (const [key, value] of Object.entries(
246
- SCOPE.webDocumentation || {}
246
+ PACKAGE_CONFIGURATION.webDocumentation || {}
247
247
  ))
248
248
  parameters[camelCaseToDelimited(key).toUpperCase()] = value
249
- if (!parameters.TAGLINE && SCOPE.description)
250
- parameters.TAGLINE = SCOPE.description
251
- if (!parameters.NAME && SCOPE.name)
252
- parameters.NAME = SCOPE.name
249
+ if (!parameters.TAGLINE && PACKAGE_CONFIGURATION.description)
250
+ parameters.TAGLINE = PACKAGE_CONFIGURATION.description
251
+ if (!parameters.NAME && PACKAGE_CONFIGURATION.name)
252
+ parameters.NAME = PACKAGE_CONFIGURATION.name
253
253
 
254
254
  log.debug(`Found parameters "${represent(parameters)}" to render.`)
255
255
 
@@ -278,7 +278,8 @@ const generateAndPushNewDocumentationPage = async (
278
278
 
279
279
  const serializedParameters: string =
280
280
  JSON.stringify(evaluateDynamicData(
281
- BUILD_DOCUMENTATION_PAGE_CONFIGURATION, {parameters, ...SCOPE}
281
+ BUILD_DOCUMENTATION_PAGE_CONFIGURATION,
282
+ {parameters, ...PACKAGE_CONFIGURATION}
282
283
  ))
283
284
  const parametersFilePath: string =
284
285
  await makeTemporaryFile({extension: '.json'})
@@ -286,7 +287,7 @@ const generateAndPushNewDocumentationPage = async (
286
287
 
287
288
  const evaluationResult: EvaluationResult = evaluate(
288
289
  BUILD_DOCUMENTATION_PAGE_COMMAND_TEMPLATE,
289
- {parameters, parametersFilePath, ...SCOPE}
290
+ {parameters, parametersFilePath, ...PACKAGE_CONFIGURATION}
290
291
  )
291
292
 
292
293
  if (evaluationResult.error)
@@ -343,8 +344,8 @@ const generateAndPushNewDocumentationPage = async (
343
344
  * @returns Path to build distribution bundle or "null" of building failed.
344
345
  */
345
346
  const createDistributionBundle = async (): Promise<null | string> => {
346
- if (SCOPE.scripts && SCOPE.scripts.build) {
347
- const buildCommand = `yarn ${SCOPE.scripts.build}`
347
+ if (PACKAGE_CONFIGURATION.scripts?.build) {
348
+ const buildCommand = `yarn ${PACKAGE_CONFIGURATION.scripts.build}`
348
349
  log.info(`Build distribution bundle via "${buildCommand}".`)
349
350
  log.debug(run(buildCommand))
350
351
  }
@@ -353,9 +354,9 @@ const createDistributionBundle = async (): Promise<null | string> => {
353
354
  const distributionBundleFilePath: string =
354
355
  await makeTemporaryFile({extension: '.zip'})
355
356
 
356
- const filePaths = SCOPE.files || []
357
- if (SCOPE.main)
358
- filePaths.push(SCOPE.main)
357
+ const filePaths = PACKAGE_CONFIGURATION.files || []
358
+ if (PACKAGE_CONFIGURATION.main)
359
+ filePaths.push(PACKAGE_CONFIGURATION.main)
359
360
 
360
361
  if (filePaths.length === 0)
361
362
  return null
@@ -527,10 +528,12 @@ const main = async (): Promise<void> => {
527
528
  run('git branch').includes('* main') &&
528
529
  run('git branch --all').includes('gh-pages')
529
530
  ) {
530
- SCOPE = optionalRequire(resolve('./package.json')) || SCOPE
531
+ PACKAGE_CONFIGURATION =
532
+ optionalRequire(resolve('./package.json')) ||
533
+ PACKAGE_CONFIGURATION
531
534
 
532
535
  const evaluationResult: EvaluationResult = evaluate(
533
- `\`${API_DOCUMENTATION_PATH_SUFFIX}\``, SCOPE
536
+ `\`${API_DOCUMENTATION_PATH_SUFFIX}\``, PACKAGE_CONFIGURATION
534
537
  )
535
538
 
536
539
  if (evaluationResult.error)
@@ -568,8 +571,10 @@ const main = async (): Promise<void> => {
568
571
  }
569
572
 
570
573
  HAS_API_DOCUMENTATION =
571
- Boolean(SCOPE.scripts) &&
572
- Object.prototype.hasOwnProperty.call(SCOPE.scripts, 'document')
574
+ Boolean(PACKAGE_CONFIGURATION.scripts) &&
575
+ Object.prototype.hasOwnProperty.call(
576
+ PACKAGE_CONFIGURATION.scripts, 'document'
577
+ )
573
578
  if (HAS_API_DOCUMENTATION) {
574
579
  log.info('API documentation creation script detected.')
575
580
  try {
@@ -710,8 +715,10 @@ const main = async (): Promise<void> => {
710
715
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
711
716
  RUN_FINAL_BUILD &&
712
717
  /* eslint-enable @typescript-eslint/no-unnecessary-condition */
713
- Boolean(SCOPE.scripts) &&
714
- Object.prototype.hasOwnProperty.call(SCOPE.scripts, 'build')
718
+ Boolean(PACKAGE_CONFIGURATION.scripts) &&
719
+ Object.prototype.hasOwnProperty.call(
720
+ PACKAGE_CONFIGURATION.scripts, 'build'
721
+ )
715
722
  )
716
723
  // Prepare build artifacts for further local usage.
717
724
  log.debug(run('yarn build'))
package/source/index.ts CHANGED
@@ -33,9 +33,9 @@ import {
33
33
  wrap
34
34
  } from 'clientnode'
35
35
  import {func, object} from 'clientnode/property-types'
36
- import {property} from 'web-component-wrapper/compatible/decorator'
36
+ import {property} from 'web-component-wrapper/decorator'
37
37
  import {WebComponentAPI} from 'web-component-wrapper/type'
38
- import {Web} from 'web-component-wrapper/compatible/Web'
38
+ import {Web} from 'web-component-wrapper/Web'
39
39
  import {api as websiteUtilitiesAPI} from 'website-utilities'
40
40
  import {api as webInternationalizationAPI} from 'web-internationalization'
41
41
 
@@ -417,7 +417,7 @@ export class WebDocumentation<
417
417
  code = codeDomNode.innerText
418
418
 
419
419
  try {
420
- let domNode: HTMLElement | string = ''
420
+ let domNode: HTMLElement | null = null
421
421
  let reInjectScripts = false
422
422
  if (match.length > 2 && match[2])
423
423
  if (
@@ -425,7 +425,17 @@ export class WebDocumentation<
425
425
  .includes(match[2].toLowerCase())
426
426
  )
427
427
  try {
428
+ /*
429
+ eslint-disable
430
+ @typescript-eslint/no-implied-eval,
431
+ @typescript-eslint/no-unsafe-call
432
+ */
428
433
  new Function(code)()
434
+ /*
435
+ eslint-enable
436
+ @typescript-eslint/no-implied-eval,
437
+ @typescript-eslint/no-unsafe-call
438
+ */
429
439
  } catch (error) {
430
440
  log.warn(
431
441
  'Error occurred during running ' +
@@ -459,40 +469,41 @@ export class WebDocumentation<
459
469
  reInjectScripts = true
460
470
  }
461
471
 
462
- if (domNode)
472
+ if (domNode) {
463
473
  codeDomNode.after(domNode)
464
474
 
465
- if (reInjectScripts)
466
- /*
467
- Injected script tags are not executed by
468
- default. So we need to reinject those.
469
- */
470
- for (const scriptDomNode of
471
- domNode.querySelectorAll('script')
472
- ) {
473
- const newScriptDomNode =
474
- document.createElement('script')
475
- for (const name of
476
- scriptDomNode.getAttributeNames()
477
- )
478
- newScriptDomNode.setAttribute(
479
- name,
480
- scriptDomNode.getAttribute(name) as
481
- string
475
+ if (reInjectScripts)
476
+ /*
477
+ Injected script tags are not executed by
478
+ default. So we need to reinject those.
479
+ */
480
+ for (const scriptDomNode of
481
+ domNode.querySelectorAll('script')
482
+ ) {
483
+ const newScriptDomNode =
484
+ document.createElement('script')
485
+ for (const name of
486
+ scriptDomNode.getAttributeNames()
482
487
  )
483
- newScriptDomNode.textContent =
484
- scriptDomNode.textContent
485
- const promise = new Promise((resolve) => {
486
- newScriptDomNode.addEventListener(
487
- 'load', resolve
488
- )
489
- })
490
- if (scriptDomNode.parentNode)
491
- scriptDomNode.parentNode.replaceChild(
492
- newScriptDomNode, scriptDomNode
493
- )
494
- await promise
495
- }
488
+ newScriptDomNode.setAttribute(
489
+ name,
490
+ scriptDomNode.getAttribute(name) as
491
+ string
492
+ )
493
+ newScriptDomNode.textContent =
494
+ scriptDomNode.textContent
495
+ const promise = new Promise((resolve) => {
496
+ newScriptDomNode.addEventListener(
497
+ 'load', resolve
498
+ )
499
+ })
500
+ if (scriptDomNode.parentNode)
501
+ scriptDomNode.parentNode.replaceChild(
502
+ newScriptDomNode, scriptDomNode
503
+ )
504
+ await promise
505
+ }
506
+ }
496
507
  } catch (error) {
497
508
  log.critical(
498
509
  `Error while integrating code "${code}":`,