web-documentation 1.0.23 → 1.0.25
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/build/deploy.js +1 -1
- package/package.json +3 -3
- package/source/deploy.ts +20 -9
- package/source/dummyReadme.md +2 -4
- package/source/index.ts +22 -13
- package/source/renderMarkdown.mjs +25 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-documentation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
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.
|
|
71
|
+
"clientnode": "^4.0.1414",
|
|
72
72
|
"css-loader": "^7.1.4",
|
|
73
73
|
"cssnano": "^8.0.1",
|
|
74
74
|
"default-gateway": "^7.2.2",
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"ejs": {
|
|
205
205
|
"options": {
|
|
206
206
|
"locals": {
|
|
207
|
-
"API_DOCUMENTATION_PATH": "/
|
|
207
|
+
"API_DOCUMENTATION_PATH": "/api/",
|
|
208
208
|
"CONTENT": "source/dummyReadme.md",
|
|
209
209
|
"DISTRIBUTION_BUNDLE_FILE_PATH": "dummyDistributionBundle.zip",
|
|
210
210
|
"LANGUAGES": {
|
package/source/deploy.ts
CHANGED
|
@@ -497,7 +497,11 @@ const tidyUp = async (): Promise<void> => {
|
|
|
497
497
|
HAS_API_DOCUMENTATION &&
|
|
498
498
|
!(await isDirectory(oldAPIDocumentationDirectoryPath))
|
|
499
499
|
)
|
|
500
|
-
|
|
500
|
+
try {
|
|
501
|
+
run(`git checkout '${oldAPIDocumentationDirectoryPath}'`)
|
|
502
|
+
} catch (error) {
|
|
503
|
+
log.warn(error)
|
|
504
|
+
}
|
|
501
505
|
|
|
502
506
|
if (!run('git branch').includes('* main'))
|
|
503
507
|
log.debug(run('git checkout main'))
|
|
@@ -578,8 +582,9 @@ const main = async (): Promise<void> => {
|
|
|
578
582
|
log.info('API documentation creation script detected.')
|
|
579
583
|
try {
|
|
580
584
|
log.debug(run('yarn document'))
|
|
585
|
+
log.info('API documentation created.')
|
|
581
586
|
} catch (error) {
|
|
582
|
-
log.
|
|
587
|
+
log.warn(error)
|
|
583
588
|
HAS_API_DOCUMENTATION = false
|
|
584
589
|
}
|
|
585
590
|
}
|
|
@@ -680,13 +685,19 @@ const main = async (): Promise<void> => {
|
|
|
680
685
|
log.debug(
|
|
681
686
|
run('corepack install', {cwd: temporaryDocumentationFolderPath})
|
|
682
687
|
)
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
|
|
689
|
+
try {
|
|
690
|
+
log.debug(run(
|
|
691
|
+
'yarn install',
|
|
692
|
+
{
|
|
693
|
+
cwd: temporaryDocumentationFolderPath,
|
|
694
|
+
env: {...process.env, NODE_ENV: 'debug'}
|
|
695
|
+
}
|
|
696
|
+
))
|
|
697
|
+
} catch (error) {
|
|
698
|
+
log.warn(error)
|
|
699
|
+
}
|
|
700
|
+
|
|
690
701
|
log.debug(run('yarn clear', {cwd: temporaryDocumentationFolderPath}))
|
|
691
702
|
|
|
692
703
|
await generateAndPushNewDocumentationPage(
|
package/source/dummyReadme.md
CHANGED
|
@@ -60,18 +60,16 @@ You need utilities for:<!--deDE:Sie benötigen Hilfsfunktionen für:-->
|
|
|
60
60
|
- URLs
|
|
61
61
|
|
|
62
62
|
<!--Place for automatic generated table of contents.-->
|
|
63
|
-
<div class="
|
|
63
|
+
<div class="wd-table-of-contents" style="display: none">
|
|
64
64
|
<!--|deDE:Inhalt-->
|
|
65
65
|
<h2 id="content">Content</h2>
|
|
66
|
+
<!--wd-table-of-contents-->
|
|
66
67
|
</div>
|
|
67
68
|
|
|
68
69
|
<!--|deDE:Installation-->
|
|
69
70
|
Installation
|
|
70
71
|
------------
|
|
71
72
|
|
|
72
|
-
<!--|deDE:Klassische Dom-Integration-->
|
|
73
|
-
### Classical dom injection
|
|
74
|
-
|
|
75
73
|
You can install via package manager, simply download the compiled version as
|
|
76
74
|
zip file here and inject or request via cdn in HTML:
|
|
77
75
|
<!--deDE:
|
package/source/index.ts
CHANGED
|
@@ -76,7 +76,9 @@ export class WebDocumentation<
|
|
|
76
76
|
}}"
|
|
77
77
|
>
|
|
78
78
|
<web-internationalization
|
|
79
|
-
options="{selectors: {
|
|
79
|
+
options="{selectors: {
|
|
80
|
+
knownTranslation: '.wd-table-of-contents'
|
|
81
|
+
}}"
|
|
80
82
|
>
|
|
81
83
|
<slot>Please provide a template to transclude.</slot>
|
|
82
84
|
</web-internationalization>
|
|
@@ -97,8 +99,8 @@ export class WebDocumentation<
|
|
|
97
99
|
'.section__home h1, .section__home h2, ' +
|
|
98
100
|
'.section__home h3, .section__home h4, ' +
|
|
99
101
|
'.section__home h5, .section__home h6',
|
|
100
|
-
tableOfContent: '.
|
|
101
|
-
tableOfContentLinks: '.
|
|
102
|
+
tableOfContent: '.wd-table-of-contents',
|
|
103
|
+
tableOfContentLinks: '.wd-table-of-contents ul li a[href^="#"]'
|
|
102
104
|
},
|
|
103
105
|
|
|
104
106
|
showExample: {
|
|
@@ -170,7 +172,7 @@ export class WebDocumentation<
|
|
|
170
172
|
* @param reason - Why an update has been triggered.
|
|
171
173
|
* @param resolveRendering - Indicates whether rendering should be resolved
|
|
172
174
|
* finally. Should be set to "false" via super calls in inherited render
|
|
173
|
-
* methods which do further dom manipulations
|
|
175
|
+
* methods which do further dom manipulations afterward and resolve the
|
|
174
176
|
* rendering process by their own.
|
|
175
177
|
* @returns A promise resolving when rendering has finished. A promise may
|
|
176
178
|
* be needed for classes inheriting from this class.
|
|
@@ -237,7 +239,8 @@ export class WebDocumentation<
|
|
|
237
239
|
if (!this.tableOfContentDomNode)
|
|
238
240
|
return
|
|
239
241
|
|
|
240
|
-
let
|
|
242
|
+
let listItemsHTML = ''
|
|
243
|
+
|
|
241
244
|
let level = 0
|
|
242
245
|
let firstLevel = 0
|
|
243
246
|
let first = true
|
|
@@ -253,11 +256,11 @@ export class WebDocumentation<
|
|
|
253
256
|
firstLevel = newLevel
|
|
254
257
|
|
|
255
258
|
if (newLevel > level)
|
|
256
|
-
|
|
259
|
+
listItemsHTML += '<ul>'
|
|
257
260
|
else if (newLevel < level)
|
|
258
|
-
|
|
261
|
+
listItemsHTML += '</ul>'
|
|
259
262
|
|
|
260
|
-
|
|
263
|
+
listItemsHTML += `
|
|
261
264
|
<li>
|
|
262
265
|
<a href="#${domNode.getAttribute('id') ?? 'unknown'}">
|
|
263
266
|
${domNode.innerText}
|
|
@@ -270,13 +273,18 @@ export class WebDocumentation<
|
|
|
270
273
|
}
|
|
271
274
|
// Close remaining inner lists.
|
|
272
275
|
while (level < firstLevel) {
|
|
273
|
-
|
|
276
|
+
listItemsHTML += '</ul>'
|
|
274
277
|
level += 1
|
|
275
278
|
}
|
|
276
279
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
for (const domNode of this.tableOfContentDomNode.childNodes)
|
|
281
|
+
if (
|
|
282
|
+
domNode.nodeType === Node.COMMENT_NODE &&
|
|
283
|
+
domNode.nodeValue === 'wd-table-of-contents'
|
|
284
|
+
) {
|
|
285
|
+
domNode.after(createDomNodes(listItemsHTML))
|
|
286
|
+
domNode.remove()
|
|
287
|
+
}
|
|
280
288
|
|
|
281
289
|
this.tableOfContentLinkDomNodes =
|
|
282
290
|
this.tableOfContentDomNode.querySelectorAll<HTMLAnchorElement>(
|
|
@@ -301,7 +309,8 @@ export class WebDocumentation<
|
|
|
301
309
|
}
|
|
302
310
|
)
|
|
303
311
|
|
|
304
|
-
this.tableOfContentDomNode.style.display
|
|
312
|
+
if (this.tableOfContentDomNode.style.display === 'none')
|
|
313
|
+
this.tableOfContentDomNode.style.display = 'initial'
|
|
305
314
|
}
|
|
306
315
|
/**
|
|
307
316
|
* This method makes dotes after code lines which are too long. This
|
|
@@ -6,6 +6,8 @@ import {markedXhtml} from 'marked-xhtml'
|
|
|
6
6
|
|
|
7
7
|
const {getLanguage, highlight} = highlightJSModule
|
|
8
8
|
|
|
9
|
+
const TOC_INDICATOR_HTML = '<!--wd-table-of-contents-->'
|
|
10
|
+
|
|
9
11
|
const marked = new Marked(
|
|
10
12
|
markedHighlight({
|
|
11
13
|
/*
|
|
@@ -22,8 +24,29 @@ const marked = new Marked(
|
|
|
22
24
|
|
|
23
25
|
export default (options) => {
|
|
24
26
|
marked.setOptions(options)
|
|
25
|
-
// Include an id attribute when emitting headings (h1, h2, h3,
|
|
26
|
-
marked.use(gfmHeadingId(
|
|
27
|
+
// Include an id attribute when emitting headings (h1, h2, h3, ...).
|
|
28
|
+
marked.use(gfmHeadingId(
|
|
29
|
+
{prefix: 'wd-heading-'},
|
|
30
|
+
{
|
|
31
|
+
hooks: {
|
|
32
|
+
// Adds an autogenerated table of contents list.
|
|
33
|
+
postprocess: (html) => {
|
|
34
|
+
const headings = getHeadingList()
|
|
35
|
+
const tableOfContents = `
|
|
36
|
+
<ul>${
|
|
37
|
+
headings
|
|
38
|
+
.map(({id, raw, level}) =>
|
|
39
|
+
`<li><a href="#${id}">${raw}</a></li>`
|
|
40
|
+
)
|
|
41
|
+
.join('\n')
|
|
42
|
+
}</ul>
|
|
43
|
+
`
|
|
44
|
+
|
|
45
|
+
return html.replace(TOC_INDICATOR_HTML, tableOfContents)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
))
|
|
27
50
|
// Favors self-closing xhtml tags.
|
|
28
51
|
marked.use(markedXhtml())
|
|
29
52
|
|