@diplodoc/cli-tests 5.5.3 → 5.7.0

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.
@@ -3,22 +3,23 @@
3
3
  exports[`Generate html document with correct lang and dir attributes. Load correct bundles. > documentation with only one rtl lang > filelist 1`] = `
4
4
  "[
5
5
  ".yfm",
6
- "_bundle/search-async-0",
7
6
  "_bundle/app-css-1",
8
- "_bundle/app-js-1",
9
- "_bundle/app-css-3",
7
+ "_bundle/app-js-2",
10
8
  "_bundle/latex-extension.css",
11
9
  "_bundle/latex-extension.js",
12
10
  "_bundle/mermaid-extension.js",
13
11
  "_bundle/page-constructor-extension.css",
14
12
  "_bundle/page-constructor-extension.js",
15
- "_bundle/search-js-0",
13
+ "_bundle/search-async-0",
14
+ "_bundle/search-async-1",
16
15
  "_bundle/search-css-0",
17
- "_bundle/search-js-1",
18
- "_bundle/search-css-3",
19
16
  "_bundle/search-css-1",
20
- "_bundle/search-js-2",
21
17
  "_bundle/search-css-2",
18
+ "_bundle/search-css-3",
19
+ "_bundle/search-css-4",
20
+ "_bundle/search-js-0",
21
+ "_bundle/search-js-1",
22
+ "_bundle/search-js-2",
22
23
  "index.html",
23
24
  "page.html",
24
25
  "toc.js"
@@ -41,7 +42,8 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
41
42
 
42
43
 
43
44
  <link type="text/css" rel="stylesheet" href="_bundle/search-css-2"/>
44
- <link type="text/css" rel="stylesheet" href="_bundle/app-css-3"/>
45
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-3"/>
46
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-4"/>
45
47
  </head>
46
48
  <body class="g-root g-root_theme_light">
47
49
  <div id="root"></div>
@@ -56,9 +58,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
56
58
  window.STATIC_CONTENT = false;
57
59
  </script>
58
60
  <script type="application/javascript" defer src="toc.js"></script>
59
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
60
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
61
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
61
62
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
63
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
62
64
 
63
65
  </body>
64
66
  </html>"
@@ -78,7 +80,8 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
78
80
 
79
81
 
80
82
  <link type="text/css" rel="stylesheet" href="_bundle/search-css-2"/>
81
- <link type="text/css" rel="stylesheet" href="_bundle/app-css-3"/>
83
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-3"/>
84
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-4"/>
82
85
  </head>
83
86
  <body class="g-root g-root_theme_light">
84
87
  <div id="root"></div>
@@ -93,9 +96,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
93
96
  window.STATIC_CONTENT = false;
94
97
  </script>
95
98
  <script type="application/javascript" defer src="toc.js"></script>
96
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
97
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
99
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
98
100
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
101
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
99
102
 
100
103
  </body>
101
104
  </html>"
@@ -106,22 +109,23 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
106
109
  exports[`Generate html document with correct lang and dir attributes. Load correct bundles. > documentation with rtl and ltr langs > filelist 1`] = `
107
110
  "[
108
111
  ".yfm",
109
- "_bundle/search-async-0",
110
112
  "_bundle/app-css-1",
111
- "_bundle/app-js-1",
112
- "_bundle/app-css-3",
113
+ "_bundle/app-js-2",
113
114
  "_bundle/latex-extension.css",
114
115
  "_bundle/latex-extension.js",
115
116
  "_bundle/mermaid-extension.js",
116
117
  "_bundle/page-constructor-extension.css",
117
118
  "_bundle/page-constructor-extension.js",
118
- "_bundle/search-js-0",
119
+ "_bundle/search-async-0",
120
+ "_bundle/search-async-1",
119
121
  "_bundle/search-css-0",
120
- "_bundle/search-js-1",
121
- "_bundle/search-css-3",
122
122
  "_bundle/search-css-1",
123
- "_bundle/search-js-2",
124
123
  "_bundle/search-css-2",
124
+ "_bundle/search-css-3",
125
+ "_bundle/search-css-4",
126
+ "_bundle/search-js-0",
127
+ "_bundle/search-js-1",
128
+ "_bundle/search-js-2",
125
129
  "ar/index.html",
126
130
  "ar/page.html",
127
131
  "ar/toc.js",
@@ -148,7 +152,8 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
148
152
 
149
153
 
150
154
  <link type="text/css" rel="stylesheet" href="_bundle/search-css-2"/>
151
- <link type="text/css" rel="stylesheet" href="_bundle/app-css-3"/>
155
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-3"/>
156
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-4"/>
152
157
  </head>
153
158
  <body class="g-root g-root_theme_light">
154
159
  <div id="root"></div>
@@ -163,9 +168,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
163
168
  window.STATIC_CONTENT = false;
164
169
  </script>
165
170
  <script type="application/javascript" defer src="ar/toc.js"></script>
166
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
167
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
171
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
168
172
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
173
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
169
174
 
170
175
  </body>
171
176
  </html>"
@@ -185,7 +190,8 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
185
190
 
186
191
 
187
192
  <link type="text/css" rel="stylesheet" href="_bundle/search-css-2"/>
188
- <link type="text/css" rel="stylesheet" href="_bundle/app-css-3"/>
193
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-3"/>
194
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-4"/>
189
195
  </head>
190
196
  <body class="g-root g-root_theme_light">
191
197
  <div id="root"></div>
@@ -200,9 +206,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
200
206
  window.STATIC_CONTENT = false;
201
207
  </script>
202
208
  <script type="application/javascript" defer src="ar/toc.js"></script>
203
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
204
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
209
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
205
210
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
211
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
206
212
 
207
213
  </body>
208
214
  </html>"
@@ -224,7 +230,7 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
224
230
  <style type="text/css">html, body {min-height:100vh; height:100vh;}</style>
225
231
 
226
232
 
227
- <link type="text/css" rel="stylesheet" href="_bundle/search-css-1"/>
233
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-0"/>
228
234
  <link type="text/css" rel="stylesheet" href="_bundle/app-css-1"/>
229
235
  </head>
230
236
  <body class="g-root g-root_theme_light">
@@ -240,9 +246,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
240
246
  window.STATIC_CONTENT = false;
241
247
  </script>
242
248
  <script type="application/javascript" defer src="en/toc.js"></script>
243
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
244
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
249
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
245
250
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
251
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
246
252
 
247
253
  </body>
248
254
  </html>"
@@ -262,7 +268,7 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
262
268
  <style type="text/css">html, body {min-height:100vh; height:100vh;}</style>
263
269
 
264
270
 
265
- <link type="text/css" rel="stylesheet" href="_bundle/search-css-1"/>
271
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-0"/>
266
272
  <link type="text/css" rel="stylesheet" href="_bundle/app-css-1"/>
267
273
  </head>
268
274
  <body class="g-root g-root_theme_light">
@@ -278,9 +284,9 @@ exports[`Generate html document with correct lang and dir attributes. Load corre
278
284
  window.STATIC_CONTENT = false;
279
285
  </script>
280
286
  <script type="application/javascript" defer src="en/toc.js"></script>
281
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
282
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
287
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
283
288
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
289
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
284
290
 
285
291
  </body>
286
292
  </html>"
@@ -3,22 +3,23 @@
3
3
  exports[`Local search > internal > filelist 1`] = `
4
4
  "[
5
5
  ".yfm",
6
- "_bundle/search-async-0",
7
6
  "_bundle/app-css-1",
8
- "_bundle/app-js-1",
9
- "_bundle/app-css-3",
7
+ "_bundle/app-js-2",
10
8
  "_bundle/latex-extension.css",
11
9
  "_bundle/latex-extension.js",
12
10
  "_bundle/mermaid-extension.js",
13
11
  "_bundle/page-constructor-extension.css",
14
12
  "_bundle/page-constructor-extension.js",
15
- "_bundle/search-js-0",
13
+ "_bundle/search-async-0",
14
+ "_bundle/search-async-1",
16
15
  "_bundle/search-css-0",
17
- "_bundle/search-js-1",
18
- "_bundle/search-css-3",
19
16
  "_bundle/search-css-1",
20
- "_bundle/search-js-2",
21
17
  "_bundle/search-css-2",
18
+ "_bundle/search-css-3",
19
+ "_bundle/search-css-4",
20
+ "_bundle/search-js-0",
21
+ "_bundle/search-js-1",
22
+ "_bundle/search-js-2",
22
23
  "_search/api.js",
23
24
  "_search/en/hash-resources.js",
24
25
  "_search/en/hash-index.js",
@@ -53,11 +54,11 @@ exports[`Local search > internal 2`] = `
53
54
  <base href="./" />
54
55
  <title>Header</title>
55
56
  <meta name="generator" content="Diplodoc Platform vDIPLODOC-VERSION">
56
-
57
+ <meta http-equiv="Content-Security-Policy" content="worker-src 'self';">
57
58
  <style type="text/css">html, body {min-height:100vh; height:100vh;}</style>
58
59
  <link rel="icon" type="image/x-icon" href="https://storage.yandexcloud.net/diplodoc-www-assets/favicon/favicon.ico">
59
60
 
60
- <link type="text/css" rel="stylesheet" href="_bundle/search-css-1"/>
61
+ <link type="text/css" rel="stylesheet" href="_bundle/search-css-0"/>
61
62
  <link type="text/css" rel="stylesheet" href="_bundle/app-css-1"/>
62
63
  </head>
63
64
  <body class="g-root g-root_theme_light">
@@ -74,9 +75,9 @@ exports[`Local search > internal 2`] = `
74
75
  </script>
75
76
  <script type="application/javascript" defer src="toc.js"></script>
76
77
  <script type="application/javascript" defer src="_search/en/hash-resources.js"></script>
77
- <script type="application/javascript" defer src="_bundle/search-js-0"></script>
78
- <script type="application/javascript" defer src="_bundle/app-js-1"></script>
78
+ <script type="application/javascript" defer src="_bundle/search-js-1"></script>
79
79
  <script type="application/javascript" defer src="_bundle/search-js-2"></script>
80
+ <script type="application/javascript" defer src="_bundle/app-js-2"></script>
80
81
 
81
82
  </body>
82
83
  </html>"
@@ -14,7 +14,6 @@ function test(path: string, expect: Function) {
14
14
 
15
15
  const md = await TestAdapter.build.run(inputPath, outputPath, ['-j2', '-f', 'md']);
16
16
  const html = await TestAdapter.build.run(inputPath, outputPath + '-html', ['-j2', '-f', 'html']);
17
-
18
17
  return expect({md, html});
19
18
  });
20
19
  }
@@ -28,6 +27,14 @@ describe('Errors', () => {
28
27
  });
29
28
  });
30
29
 
30
+ describe('Warnings', () => {
31
+ test('mocks/warning/unreachable-autotitle', ({html}: TestResult) => {
32
+ expectWarnings(html, [
33
+ 'WARN index.md: 1: YFM010 / unreachable-autotitle-anchor Auto title anchor is unreachable [Context: "[Unreachable autotitle anchor: "link.html#unknown_yfm010"][{#T}](./link.md#unknown_yfm010)"]',
34
+ ]);
35
+ });
36
+ });
37
+
31
38
  function expectErrors(report: Report, errors: string[]) {
32
39
  expect(report.code).toEqual(1);
33
40
 
@@ -35,3 +42,11 @@ function expectErrors(report: Report, errors: string[]) {
35
42
  expect(report.errors).toContain(error);
36
43
  }
37
44
  }
45
+
46
+ function expectWarnings(report: Report, warnings: string[]) {
47
+ expect(report.warns.length).toEqual(warnings.length);
48
+
49
+ for (const warn of warnings) {
50
+ expect(report.warns).toContain(warn);
51
+ }
52
+ }
@@ -0,0 +1,4 @@
1
+ declare module "@diplodoc/cli/manifest" {
2
+ const manifest: Record<string, Record<string, string[]>>;
3
+ export = manifest;
4
+ }
@@ -1,5 +1,6 @@
1
1
  import {Runner} from './types';
2
2
  import {execa} from 'execa';
3
+ import strip from 'strip-ansi';
3
4
 
4
5
  export class BinaryRunner implements Runner {
5
6
  private readonly binaryPath: string;
@@ -29,7 +30,7 @@ export class BinaryRunner implements Runner {
29
30
 
30
31
  function fillLog(filter: RegExp, source: string) {
31
32
  return source.split('\n')
32
- .filter((line) => line.match(filter))
33
- .map((line) => line.trim())
34
- .filter(Boolean);
33
+ .map((line) => strip(line).trim())
34
+ .filter(Boolean)
35
+ .filter((line) => line.match(filter));
35
36
  }
@@ -1,12 +1,12 @@
1
1
  import {readFileSync} from 'node:fs';
2
+ import {rm} from 'node:fs/promises';
2
3
  import {join, resolve} from 'node:path';
3
4
  import {glob} from 'glob';
4
5
  import {bundleless, hashless, platformless} from './test';
5
6
  import {expect} from 'vitest';
6
- import {$} from 'execa';
7
7
 
8
8
  export function getFileContent(filePath: string) {
9
- return bundleless(platformless(readFileSync(filePath, 'utf8')));
9
+ return platformless(bundleless(readFileSync(filePath, 'utf8')));
10
10
  }
11
11
 
12
12
  const uselessFile = (file: string) =>
@@ -21,9 +21,9 @@ export async function compareDirectories(outputPath: string, ignoreFileContent =
21
21
  nodir: true,
22
22
  posix: true,
23
23
  })
24
- ).sort();
24
+ ).map(bundleless).sort();
25
25
 
26
- expect(hashless(bundleless(JSON.stringify(filesFromOutput, null, 2)))).toMatchSnapshot('filelist');
26
+ expect(hashless(JSON.stringify(filesFromOutput, null, 2))).toMatchSnapshot('filelist');
27
27
 
28
28
  if (!ignoreFileContent) {
29
29
  filesFromOutput.filter(uselessFile).forEach((filePath) => {
@@ -46,5 +46,5 @@ export function getTestPaths(testRootPath: string): TestPaths {
46
46
  }
47
47
 
48
48
  export function cleanupDirectory(path: string) {
49
- return $`rm -rf ${path}`;
49
+ return rm(path, {recursive: true, force: true});
50
50
  }
@@ -1,6 +1,8 @@
1
- import {readFileSync} from 'node:fs';
1
+ import assets from '@diplodoc/cli/manifest';
2
2
 
3
3
  export function platformless(text: string): string {
4
+ let index = 1;
5
+
4
6
  return hashless(text)
5
7
  .replace(/\r\n/g, '\n')
6
8
  .replace(/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/g, 'UUID')
@@ -8,7 +10,11 @@ export function platformless(text: string): string {
8
10
  /(content"?[:=]{1}[" ]{1}Diplodoc.*? )v\d+\.\d+\.\d+(?:-[\w-]+)?/g,
9
11
  `$1vDIPLODOC-VERSION`,
10
12
  )
11
- .replace(/(\\(?![/"'])){1,2}/g, '/');
13
+ .replace(/(\\(?![/"'])){1,2}/g, '/')
14
+ .replace(
15
+ /id=\\"inline-code-id-[a-zA-Z0-9]{8}\\"/g,
16
+ () => `id="inline-code-id-${index++}"`
17
+ )
12
18
  }
13
19
 
14
20
  export function hashless(text: string): string {
@@ -18,8 +24,6 @@ export function hashless(text: string): string {
18
24
  }
19
25
 
20
26
  export function bundleless(text: string): string {
21
- const assets = require('@diplodoc/client/manifest') as Record<string, Record<string, string[]>>;
22
-
23
27
  for (const [entryKey, entry] of Object.entries(assets)) {
24
28
  for (const [typeKey, type] of Object.entries(entry)) {
25
29
  for (let index = 0; index < type.length; index++) {
@@ -35,6 +39,3 @@ export function bundleless(text: string): string {
35
39
  return text;
36
40
  }
37
41
 
38
- export function getNormalizedContent(filePath: string): string {
39
- return bundleless(platformless(readFileSync(filePath, 'utf8')));
40
- }
@@ -1,4 +1,6 @@
1
1
  items:
2
2
  - name: Use merged
3
3
  href: ./merge.md
4
+ - name: Multitoc item
5
+ href: ../1.md
4
6
  - include: {path: ../merge-source/toc-m.yaml, mode: merge}
@@ -9,6 +9,8 @@ items:
9
9
  href: ./1
10
10
  - name: Item with empty href
11
11
  href:
12
+ - name: Multitoc item
13
+ href: ./merge/merged.md
12
14
  - include: {path: toc-i.yaml}
13
15
  - include: {path: sub/toc.yaml, mode: link}
14
16
  - href: ./mermaid
@@ -0,0 +1 @@
1
+ [{#T}](./link.md#unknown_yfm010)
@@ -0,0 +1,4 @@
1
+ href: index.md
2
+ items:
3
+ name: link
4
+ href: link.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.5.3",
3
+ "version": "5.7.0",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },
@@ -27,19 +27,18 @@
27
27
  "@diplodoc/cli": "file:.."
28
28
  },
29
29
  "dependencies": {
30
- "@diplodoc/client": "^3.9.0",
31
30
  "@types/node": "18.x",
32
31
  "@vitest/coverage-istanbul": "^3.1.1",
33
32
  "@vitest/coverage-v8": "^3.1.1",
34
- "commander": "^13.1.0",
35
33
  "execa": "^9.5.3",
36
34
  "glob": "^11.0.2",
37
35
  "js-yaml": "^4.1.0",
36
+ "strip-ansi": "^7.1.0",
38
37
  "ts-dedent": "^2.2.0",
39
- "ts-node": "^10.4.0",
40
- "typescript": "^5.3.3"
38
+ "typescript": "^5.9.2"
41
39
  },
42
40
  "peerDependencies": {
41
+ "@diplodoc/cli": "*",
43
42
  "vitest": "^3.1.1"
44
43
  }
45
44
  }