web-documentation 1.0.27 → 1.0.29

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.27",
3
+ "version": "1.0.29",
4
4
  "description": "Declarative multilanguage documentation website generator",
5
5
  "keywords": [
6
6
  "documentation",
@@ -68,7 +68,7 @@
68
68
  "@webcomponents/webcomponentsjs": "^2.8.0",
69
69
  "archiver": "^8.0.0",
70
70
  "bootstrap-icons": "^1.13.1",
71
- "clientnode": "^4.0.1414",
71
+ "clientnode": "^4.0.1419",
72
72
  "css-loader": "^7.1.4",
73
73
  "cssnano": "^8.0.1",
74
74
  "default-gateway": "^7.2.2",
@@ -204,9 +204,8 @@
204
204
  "ejs": {
205
205
  "options": {
206
206
  "locals": {
207
- "API_DOCUMENTATION_PATH": {
208
- "__evaluate__": "path.resolve(currentPath, 'api/')"
209
- },
207
+ "API_DOCUMENTATION_PATH": "api/",
208
+ "HAS_API_DOCUMENTATION": true,
210
209
  "CONTENT": "source/dummyReadme.md",
211
210
  "DISTRIBUTION_BUNDLE_FILE_PATH": "dummyDistributionBundle.zip",
212
211
  "LANGUAGES": {
package/source/deploy.ts CHANGED
@@ -88,7 +88,7 @@ const BUILD_DOCUMENTATION_PAGE_CONFIGURATION = {
88
88
  }
89
89
  },
90
90
  /*
91
- NOTE: We habe to disable offline features since the domains cache is
91
+ NOTE: We have to disable offline features since the domains cache is
92
92
  already in use for the main home page.
93
93
  */
94
94
  offline: null
@@ -179,7 +179,7 @@ const stream2buffer = async (stream: Stream): Promise<Buffer> => {
179
179
  * @param temporaryDocumentationFolderPath - Location where to build
180
180
  * documentation build.
181
181
  * @param distributionBundleFilePath - Location where to save the exported
182
- * build artefacts.
182
+ * build artifacts.
183
183
  * @returns A promise resolving when build process has finished.
184
184
  */
185
185
  const generateAndPushNewDocumentationPage = async (
@@ -259,6 +259,7 @@ const generateAndPushNewDocumentationPage = async (
259
259
  ...parameters,
260
260
  CONTENT,
261
261
  API_DOCUMENTATION_PATH: apiDocumentationPath,
262
+ HAS_API_DOCUMENTATION,
262
263
  DISTRIBUTION_BUNDLE_FILE_PATH:
263
264
  await isFile(DISTRIBUTION_BUNDLE_FILE_PATH) ?
264
265
  relative('./', DISTRIBUTION_BUNDLE_FILE_PATH) :
@@ -450,7 +451,8 @@ const isFileIgnored = async (filePath: string): Promise<boolean> => (
450
451
  */
451
452
  const copyRepositoryFile = async (
452
453
  sourcePath: string, targetPath: string, file: File
453
- ): Promise<false | undefined> => {
454
+ ): Promise<false | undefined> =>
455
+ {
454
456
  if (await isFileIgnored(file.path) || basename(file.name) === 'readme.md')
455
457
  return false
456
458
 
@@ -721,7 +723,7 @@ const main = async (): Promise<void> => {
721
723
  Boolean(SCOPE.scripts) &&
722
724
  Object.prototype.hasOwnProperty.call(SCOPE.scripts, 'build')
723
725
  )
724
- // Prepare build artefacts for further local usage.
726
+ // Prepare build artifacts for further local usage.
725
727
  log.debug(run('yarn build'))
726
728
  }
727
729
  }
@@ -82,14 +82,28 @@ zip file here and inject or request via cdn in HTML:
82
82
  npm install clientnode
83
83
  ```
84
84
 
85
+ <!--showExample-->
86
+
85
87
  ```HTML
86
- <!--Inject downloaded file:
87
- <script src="index.js"></script>
88
- -->
89
- <!--Or integrate via cdn:-->
90
- <script
91
- src="https://torben.website/clientnode/data/distributionBundle/index.js"
92
- ></script>
88
+ <script src="https://unpkg.com/clientnode@latest/dist/bundle/index.js">
89
+ </script>
90
+
91
+ <div id="first-example-playground"></div>
92
+ ```
93
+
94
+ <!--showExample:JavaScript-->
95
+
96
+ ```JavaScript
97
+ const domNode = clientnode.createDomNodes('<p>some content to animate</p>');
98
+
99
+ const endless = () => {
100
+ clientnode.fadeIn(domNode)
101
+ .then(() => clientnode.fadeOut(domNode))
102
+ .then(endless)
103
+ };
104
+ endless();
105
+
106
+ document.querySelector('#first-example-playground').appendChild(domNode);
93
107
  ```
94
108
 
95
109
  The compiled bundle supports AMD, commonjs, commonjs2 and variable injection
@@ -105,13 +119,25 @@ want.
105
119
  Usage
106
120
  -----
107
121
 
108
- Function call from previous generated instance via dom node or instance
109
- reference:
110
- <!--deDE:
111
- Aufruf einer Plugin-Methode anhand der zuvor generierten Instanz bzw. über
112
- den zurückgegebene DOM-Knoten:
113
- -->
122
+ Execute a JSON based expression:
123
+ <!--deDE:Ausführung eines JSON basierten Ausdrucks:-->
124
+
125
+ <!--showExample-->
126
+
127
+ ```HTML
128
+ <div id="second-example-playground"></div>
129
+ ```
130
+
131
+ <!--showExample:JavaScript-->
114
132
 
115
133
  ```JavaScript
116
- console.log('TEST')
134
+ document.querySelector('#second-example-playground').innerText =
135
+ clientnode.evaluateExpression(
136
+ {
137
+ $operator: '+',
138
+ operand1: 2,
139
+ operand2: {$select: 'some.data.in.scope'}
140
+ },
141
+ {some: {data: {in: {scope: 3}}}}
142
+ );
117
143
  ```
@@ -115,10 +115,7 @@ _%>
115
115
  numberOfLanguageLinks = _.LANGUAGES.length
116
116
  START_UP_ANIMATION_NUMBER += numberOfLanguageLinks
117
117
  }
118
- if (
119
- _.API_DOCUMENTATION_PATH &&
120
- _.IS_DIRECTORY(_.API_DOCUMENTATION_PATH)
121
- )
118
+ if (_.HAS_API_DOCUMENTATION)
122
119
  START_UP_ANIMATION_NUMBER += 3
123
120
  else
124
121
  START_UP_ANIMATION_NUMBER += 2
@@ -158,12 +155,8 @@ _%>
158
155
  class="header__inner__links__lang tools-hidden-on-javascript-disabled wu-start-up-animation-number-<%- START_UP_ANIMATION_NUMBER %>"
159
156
  href="#lang-<%- language %>"
160
157
  ><%- language.slice(0, 2) %></a>
161
- <%_ }
162
- if (
163
- _.API_DOCUMENTATION_PATH &&
164
- _.IS_DIRECTORY(_.API_DOCUMENTATION_PATH)
165
- ) {
166
- _%>
158
+ <%_ } _%>
159
+ <%_ if (_.HAS_API_DOCUMENTATION) { _%>
167
160
  <%_ START_UP_ANIMATION_NUMBER -= 1 _%>
168
161
  <a
169
162
  class="header__inner__links__api-link wu-start-up-animation-number-<%- START_UP_ANIMATION_NUMBER %>"
package/source/index.ts CHANGED
@@ -191,7 +191,7 @@ export class WebDocumentation<
191
191
  NOTE: We have to render examples first to avoid having dots in
192
192
  example code.
193
193
  */
194
- this._showExamples()
194
+ await this._showExamples()
195
195
 
196
196
  this._makeCodeEllipsis()
197
197
 
@@ -398,7 +398,7 @@ export class WebDocumentation<
398
398
  /**
399
399
  * Shows marked example codes directly in browser.
400
400
  */
401
- _showExamples(): void {
401
+ async _showExamples(): Promise<void> {
402
402
  for (const domNode of getAll(this.hostDomNode))
403
403
  if (domNode.nodeName === this.options.showExample.domNodeName) {
404
404
  const match: null | RegExpMatchArray =
@@ -418,6 +418,7 @@ export class WebDocumentation<
418
418
 
419
419
  try {
420
420
  let domNode: HTMLElement | string = ''
421
+ let reInjectScripts = false
421
422
  if (match.length > 2 && match[2])
422
423
  if (
423
424
  ['javascript', 'javascripts', 'js']
@@ -439,18 +440,39 @@ export class WebDocumentation<
439
440
  domNode.innerText = code
440
441
  } else if (match[2].toLowerCase() === 'hidden')
441
442
  domNode = code
442
- else
443
+ else {
443
444
  domNode = createDomNodes(format(
444
- this.options.showExample.htmlWrapper,
445
- code
445
+ this.options.showExample.htmlWrapper, code
446
446
  ))
447
- else
447
+ reInjectScripts = true
448
+ }
449
+ else {
448
450
  domNode = createDomNodes(format(
449
- this.options.showExample.htmlWrapper,
450
- code
451
+ this.options.showExample.htmlWrapper, code
451
452
  ))
453
+ reInjectScripts = true
454
+ }
452
455
 
453
456
  codeDomNode.after(domNode)
457
+
458
+ if (reInjectScripts) {
459
+ /*
460
+ Injected script tags are not executed by
461
+ default. So we need to reinject those.
462
+ */
463
+ for (const scriptDomNode of domNode.querySelectorAll('script')) {
464
+ // const newScriptDomNode = scriptDomNode.cloneNode(true)
465
+ const newScriptDomNode = document.createElement('script')
466
+ for (const name of scriptDomNode.getAttributeNames())
467
+ newScriptDomNode.setAttribute(name, scriptDomNode.getAttribute(name))
468
+ newScriptDomNode.textContent = scriptDomNode.textContent
469
+ const promise = new Promise((resolve) => {
470
+ newScriptDomNode.addEventListener('load', resolve)
471
+ })
472
+ scriptDomNode.parentNode.replaceChild(newScriptDomNode, scriptDomNode)
473
+ await promise
474
+ }
475
+ }
454
476
  } catch (error) {
455
477
  log.critical(
456
478
  `Error while integrating code "${code}":`,
@@ -460,7 +482,6 @@ export class WebDocumentation<
460
482
  }
461
483
  }
462
484
 
463
-
464
485
  this.onExamplesLoaded()
465
486
  }
466
487
  // endregion