@diplodoc/cli-tests 5.23.1 → 5.24.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.
@@ -0,0 +1,67 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes > filelist 1`] = `
4
+ "[
5
+ "included.md",
6
+ "index.md",
7
+ "toc.yaml"
8
+ ]"
9
+ `;
10
+
11
+ exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 1`] = `
12
+ "---
13
+ metadata:
14
+ - name: generator
15
+ content: Diplodoc Platform vDIPLODOC-VERSION
16
+ title: Included Page Title
17
+ description: This is the description for the included page
18
+ vcsPath: included.md
19
+ ---
20
+
21
+ # Included Page
22
+
23
+ This is the content of the included page.
24
+
25
+ ## Section 1
26
+
27
+ Some content in section 1.
28
+
29
+ ## Section 2
30
+
31
+ Some content in section 2.
32
+ "
33
+ `;
34
+
35
+ exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 2`] = `
36
+ "---
37
+ metadata:
38
+ - name: generator
39
+ content: Diplodoc Platform vDIPLODOC-VERSION
40
+ title: Main Page Title
41
+ description: This is the description for the main page
42
+ vcsPath: index.md
43
+ ---
44
+
45
+ # Main Page
46
+
47
+ This is the main page content.
48
+
49
+ ## Including another page
50
+
51
+ Here we include the content from the included page:
52
+
53
+ [Included Page](./included.md)
54
+
55
+ "
56
+ `;
57
+
58
+ exports[`Include with Meta > Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes 3`] = `
59
+ "items:
60
+ - name: Main Page
61
+ href: index.md
62
+ items:
63
+ - name: Included Page
64
+ href: included.md
65
+ path: toc.yaml
66
+ "
67
+ `;
@@ -1176,7 +1176,7 @@ exports[`Regression > internal 45`] = `
1176
1176
  <body class="g-root g-root_theme_light">
1177
1177
  <div id="root"></div>
1178
1178
  <script type="application/json" id="diplodoc-state">
1179
- {"data":{"leading":false,"html":"&lt;p&gt;Text&lt;/p&gt;/n&lt;p&gt;Bob&lt;/p&gt;/n&lt;p&gt;Test&lt;/p&gt;/n&lt;h3 id=\\"f1\\"&gt;&lt;a href=\\"includes.html#f1\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;F1&lt;/span&gt;&lt;/a&gt;F1&lt;/h3&gt;/n&lt;p&gt;Content F1&lt;/p&gt;/n&lt;p id=\\"p1\\"&gt;Some paragraph with anchor&lt;/p&gt;/n/n&lt;p&gt;Bob&lt;/p&gt;/n&lt;p&gt;&lt;a href=\\"latex.html\\"&gt;&lt;img src=\\"_assets/3.png\\" alt=\\"img 3\\" /&gt;&lt;/a&gt;&lt;/p&gt;/n&lt;p&gt;&lt;sup&gt;&lt;i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"xc42lewq\\"&gt;?&lt;/i&gt;&lt;/sup&gt;&lt;/p&gt;/n&lt;p&gt;[&lt;i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"vl3znzw0\\"&gt;?&lt;/i&gt;](http://ya.ru)&lt;/p&gt;/n&lt;p&gt;Link after include&lt;br /&gt;/n&lt;a href=\\"1.html#subtitle\\"&gt;Subtitle&lt;/a&gt;&lt;/p&gt;/n&lt;p&gt;Link after include&lt;/p&gt;/n&lt;dfn class=\\"yfm yfm-term_dfn\\" id=\\":term_element\\" role=\\"dialog\\"&gt;&lt;p&gt;Test terms&lt;/p&gt;/n&lt;/dfn&gt;","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"includes.md"},"headings":[],"title":""},"router":{"pathname":"includes","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
1179
+ {"data":{"leading":false,"html":"&lt;p&gt;Text&lt;/p&gt;/n&lt;p&gt;Bob&lt;/p&gt;/n&lt;p&gt;Test&lt;/p&gt;/n&lt;h3 id=\\"f1\\"&gt;&lt;a href=\\"includes.html#f1\\" class=\\"yfm-anchor\\" aria-hidden=\\"true\\"&gt;&lt;span class=\\"visually-hidden\\" data-no-index=\\"true\\"&gt;F1&lt;/span&gt;&lt;/a&gt;F1&lt;/h3&gt;/n&lt;p&gt;Content F1&lt;/p&gt;/n&lt;p id=\\"p1\\"&gt;Some paragraph with anchor&lt;/p&gt;/n/n&lt;p&gt;Bob&lt;/p&gt;/n&lt;p&gt;&lt;a href=\\"latex.html\\"&gt;&lt;img src=\\"_assets/3.png\\" alt=\\"img 3\\" /&gt;&lt;/a&gt;&lt;/p&gt;/n&lt;p&gt;&lt;sup&gt;&lt;i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"vTERM-ID\\"&gt;?&lt;/i&gt;&lt;/sup&gt;&lt;/p&gt;/n&lt;p&gt;[&lt;i class=\\"yfm yfm-term_title\\" term-key=\\":term\\" role=\\"button\\" aria-describedby=\\":term_element\\" tabindex=\\"0\\" id=\\"vTERM-ID\\"&gt;?&lt;/i&gt;](http://ya.ru)&lt;/p&gt;/n&lt;p&gt;Link after include&lt;br /&gt;/n&lt;a href=\\"1.html#subtitle\\"&gt;Subtitle&lt;/a&gt;&lt;/p&gt;/n&lt;p&gt;Link after include&lt;/p&gt;/n&lt;dfn class=\\"yfm yfm-term_dfn\\" id=\\":term_element\\" role=\\"dialog\\"&gt;&lt;p&gt;Test terms&lt;/p&gt;/n&lt;/dfn&gt;","meta":{"metadata":[{"name":"generator","content":"Diplodoc Platform vDIPLODOC-VERSION"}],"vcsPath":"includes.md"},"headings":[],"title":""},"router":{"pathname":"includes","depth":1,"base":"./"},"lang":"ru","langs":["ru"],"viewerInterface":{"toc":true,"search":true,"feedback":true}}
1180
1180
  </script>
1181
1181
  <script type="application/javascript">
1182
1182
  const data = document.querySelector('script#diplodoc-state');
@@ -61,6 +61,15 @@ describe('Errors', () => {
61
61
  ['--max-asset-size', '2K'],
62
62
  );
63
63
 
64
+ test('mocks/errors/invalid-frontmatter', ({md, html}: TestResult) => {
65
+ expectErrors(md, [
66
+ 'ERR index.md: 2: YFM017 / invalid front matter format [Reason: "duplicated mapping key"; Line: 2; Key: "title"]',
67
+ ]);
68
+ expectErrors(html, [
69
+ 'ERR index.md: 2: YFM017 / invalid front matter format [Reason: "duplicated mapping key"; Line: 2; Key: "title"]',
70
+ ]);
71
+ });
72
+
64
73
  it('translate extract with filtered links', async () => {
65
74
  const {inputPath, outputPath} = getTestPaths('mocks/errors/extract-filtered-link');
66
75
 
@@ -0,0 +1,20 @@
1
+ import {describe, test} from 'vitest';
2
+
3
+ import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
4
+
5
+ describe('Include with Meta', () => {
6
+ test('Build with PAGE_PROCESS_CONCURRENCY=1 should preserve meta information in includes', async () => {
7
+ const {inputPath, outputPath} = getTestPaths('mocks/include-with-meta');
8
+
9
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
10
+ md2md: true,
11
+ md2html: false,
12
+ args: '-j 2',
13
+ env: {
14
+ PAGE_PROCESS_CONCURRENCY: '1',
15
+ },
16
+ });
17
+
18
+ await compareDirectories(outputPath);
19
+ });
20
+ });
@@ -7,6 +7,7 @@ export interface BuildRunArgs {
7
7
  md2md?: boolean;
8
8
  md2html?: boolean;
9
9
  args?: string;
10
+ env?: Record<string, string>;
10
11
  }
11
12
 
12
13
  export interface TranslateRunArgs {
@@ -23,16 +24,11 @@ class Build {
23
24
  this.runner = runner;
24
25
  }
25
26
 
26
- run(input: string, output: string, args: string[]) {
27
- return this.runner.runYfmDocs([
28
- '--input',
29
- input,
30
- '--output',
31
- output,
32
- '--quiet',
33
- '--allowHTML',
34
- ...args,
35
- ]);
27
+ run(input: string, output: string, args: string[], env?: Record<string, string>) {
28
+ return this.runner.runYfmDocs(
29
+ ['--input', input, '--output', output, '--quiet', '--allowHTML', ...args],
30
+ env,
31
+ );
36
32
  }
37
33
  }
38
34
 
@@ -43,17 +39,11 @@ class Extract {
43
39
  this.runner = runner;
44
40
  }
45
41
 
46
- run(input: string, output: string, args: string[]) {
47
- return this.runner.runYfmDocs([
48
- 'translate',
49
- 'extract',
50
- '--input',
51
- input,
52
- '--output',
53
- output,
54
- '--quiet',
55
- ...args,
56
- ]);
42
+ run(input: string, output: string, args: string[], env?: Record<string, string>) {
43
+ return this.runner.runYfmDocs(
44
+ ['translate', 'extract', '--input', input, '--output', output, '--quiet', ...args],
45
+ env,
46
+ );
57
47
  }
58
48
  }
59
49
 
@@ -67,7 +57,7 @@ export class CliTestAdapter {
67
57
  async testBuildPass(
68
58
  inputPath: string,
69
59
  outputPath: string,
70
- {md2md = true, md2html = true, args = ''}: BuildRunArgs = {},
60
+ {md2md = true, md2html = true, args = '', env}: BuildRunArgs = {},
71
61
  ): Promise<void> {
72
62
  await cleanupDirectory(outputPath);
73
63
  await cleanupDirectory(`${outputPath}-md`);
@@ -78,14 +68,16 @@ export class CliTestAdapter {
78
68
  const tasks = [];
79
69
 
80
70
  if (md2md && md2html) {
81
- tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
71
+ tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
82
72
  tasks.push(() =>
83
- this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html']),
73
+ this.build.run(inputPath, `${outputPath}-html`, [...baseArgs, '-f', 'html'], env),
84
74
  );
85
75
  } else if (md2md) {
86
- tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md']));
76
+ tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'md'], env));
87
77
  } else {
88
- tasks.push(() => this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'html']));
78
+ tasks.push(() =>
79
+ this.build.run(inputPath, outputPath, [...baseArgs, '-f', 'html'], env),
80
+ );
89
81
  }
90
82
 
91
83
  for (const task of tasks) {
@@ -10,8 +10,12 @@ export class BinaryRunner implements Runner {
10
10
  this.binaryPath = binaryPath;
11
11
  }
12
12
 
13
- async runYfmDocs(argv: string[]) {
14
- const {stderr, exitCode} = await execa(this.binaryPath, argv, {all: true, reject: false});
13
+ async runYfmDocs(argv: string[], env?: Record<string, string>) {
14
+ const {stderr, exitCode} = await execa(this.binaryPath, argv, {
15
+ all: true,
16
+ reject: false,
17
+ env: {...process.env, ...env},
18
+ });
15
19
  const report = {
16
20
  code: exitCode || 0,
17
21
  warns: fillLog(/^WARN/, stderr),
@@ -5,5 +5,5 @@ export type Report = {
5
5
  };
6
6
 
7
7
  export interface Runner {
8
- runYfmDocs(argv: string[]): Promise<Report>;
8
+ runYfmDocs(argv: string[], env?: Record<string, string>): Promise<Report>;
9
9
  }
@@ -16,6 +16,10 @@ export function platformless(text: string): string {
16
16
  /(content"?[:=]{1}[" ]{1}Diplodoc.*? )v\d+\.\d+\.\d+(?:-[\w-]+)?/g,
17
17
  `$1vDIPLODOC-VERSION`,
18
18
  )
19
+ .replace(
20
+ /(aria-describedby=\\":term_element\\" tabindex=\\"\d\\" id=\\")[a-zA-Z0-9]{1,10}/g,
21
+ `$1vTERM-ID`,
22
+ )
19
23
  .replace(/(\\(?![/"'])){1,2}/g, '/')
20
24
  .replace(
21
25
  /id=\\"inline-code-id-[a-zA-Z0-9]{8}\\"/g,
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Test Document
3
+ title: Duplicate Key
4
+ description: This front matter has a duplicated mapping key
5
+ ---
6
+
7
+ # Test Document
8
+
9
+ This is a test document with invalid front matter.
@@ -0,0 +1 @@
1
+ href: index.md
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: Included Page Title
3
+ description: This is the description for the included page
4
+ ---
5
+
6
+ # Included Page
7
+
8
+ This is the content of the included page.
9
+
10
+ ## Section 1
11
+
12
+ Some content in section 1.
13
+
14
+ ## Section 2
15
+
16
+ Some content in section 2.
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Main Page Title
3
+ description: This is the description for the main page
4
+ ---
5
+
6
+ # Main Page
7
+
8
+ This is the main page content.
9
+
10
+ ## Including another page
11
+
12
+ Here we include the content from the included page:
13
+
14
+ [{#T}](./included.md)
15
+
@@ -0,0 +1,6 @@
1
+ items:
2
+ - name: Main Page
3
+ href: index.md
4
+ items:
5
+ - name: Included Page
6
+ href: included.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.23.1",
3
+ "version": "5.24.1",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },