@diplodoc/cli-tests 0.0.0-rc-toc-translation-202506261401 → 0.0.0-rc-fix-translate-openapi-includer-202507171205

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.
Files changed (27) hide show
  1. package/e2e/__snapshots__/load-custom-resources.spec.ts.snap +7 -0
  2. package/e2e/__snapshots__/metadata.spec.ts.snap +3 -0
  3. package/e2e/__snapshots__/regression.test.ts.snap +20 -0
  4. package/e2e/__snapshots__/rtl.spec.ts.snap +7 -0
  5. package/e2e/__snapshots__/search.test.ts.snap +71 -0
  6. package/e2e/__snapshots__/translation.spec.ts.snap +1692 -1096
  7. package/e2e/search.test.ts +15 -0
  8. package/e2e/translation.spec.ts +33 -8
  9. package/fixtures/utils/test.ts +1 -0
  10. package/mocks/search/input/index.md +3 -0
  11. package/mocks/search/input/toc.yaml +1 -0
  12. package/mocks/translation/dir-files/input/ru/aboba.md +4 -2
  13. package/mocks/translation/dir-files/input/ru/nested/toc.yaml +0 -1
  14. package/mocks/translation/dir-files/input/ru/toc.yaml +1 -7
  15. package/mocks/translation/no-translate/input/index.md +7 -0
  16. package/mocks/translation/no-translate/input/no-translate.md +57 -0
  17. package/mocks/translation/no-translate/input/openapi-spec.yaml +37 -0
  18. package/mocks/translation/no-translate/input/toc.yaml +11 -0
  19. package/mocks/translation/openapi/input/openapi-spec.yaml +42 -0
  20. package/mocks/translation/openapi/input/toc.yaml +8 -0
  21. package/package.json +1 -1
  22. package/mocks/translation/dir-files/input/.yfm +0 -6
  23. package/mocks/translation/dir-files/input/ru/nested/a1.md +0 -3
  24. package/mocks/translation/dir-files/input/ru/nested/folder1/a1.md +0 -3
  25. package/mocks/translation/dir-files/input/ru/nested/folder1/toc-i.yaml +0 -3
  26. package/mocks/translation/dir-files/input/ru/no-var-page.md +0 -3
  27. package/mocks/translation/dir-files/input/ru/to-be-excluded.md +0 -1
@@ -0,0 +1,15 @@
1
+ import {describe, it} from 'vitest';
2
+ import {TestAdapter, compareDirectories, getTestPaths} from '../fixtures';
3
+
4
+ describe('Local search', () => {
5
+ it('internal', async () => {
6
+ const {inputPath, outputPath} = getTestPaths('mocks/search');
7
+
8
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
9
+ md2md: false,
10
+ md2html: true,
11
+ args: '-j2 --search',
12
+ });
13
+ await compareDirectories(outputPath);
14
+ });
15
+ });
@@ -5,13 +5,14 @@ const generateMapTestTemplate = (
5
5
  testTitle: string,
6
6
  testRootPath: string,
7
7
  args: TranslateRunArgs,
8
+ ignoreFileContent = true,
8
9
  ) => {
9
- test(testTitle, async () => {
10
+ test.skip(testTitle, async () => {
10
11
  const {inputPath, outputPath} = getTestPaths(testRootPath);
11
12
 
12
13
  await TestAdapter.testTranslatePass(inputPath, outputPath, args);
13
14
 
14
- await compareDirectories(outputPath);
15
+ await compareDirectories(outputPath, ignoreFileContent);
15
16
  });
16
17
  };
17
18
 
@@ -29,7 +30,32 @@ const generateFilesYamlTestTemplate = (
29
30
  });
30
31
  };
31
32
 
33
+ const buildFilesYamlTestTemplate = (
34
+ testTitle: string,
35
+ testRootPath: string,
36
+ buildProps: {md2md?: boolean; md2html?: boolean},
37
+ ) => {
38
+ test(testTitle, async () => {
39
+ const {inputPath, outputPath} = getTestPaths(testRootPath);
40
+ const {md2md, md2html} =buildProps;
41
+
42
+ await TestAdapter.testBuildPass(inputPath, outputPath, {md2html, md2md});
43
+
44
+ await compareDirectories(outputPath);
45
+ });
46
+ };
47
+
32
48
  describe('Translate command', () => {
49
+ buildFilesYamlTestTemplate('build translated md files and remove no-translate directives', 'mocks/translation/no-translate', {md2md: true});
50
+
51
+ buildFilesYamlTestTemplate('build translated static files and remove no-translate directives', 'mocks/translation/no-translate', {md2html: true});
52
+
53
+ generateFilesYamlTestTemplate('extract openapi spec files', 'mocks/translation/openapi', {
54
+ subcommand: 'extract',
55
+ source: 'ru-RU',
56
+ target: 'es-ES',
57
+ });
58
+
33
59
  generateMapTestTemplate('filter files on extract', 'mocks/translation/dir-files', {
34
60
  subcommand: 'extract',
35
61
  source: 'ru-RU',
@@ -43,20 +69,19 @@ describe('Translate command', () => {
43
69
  subcommand: 'extract',
44
70
  source: 'ru-RU',
45
71
  target: 'es-ES',
46
- additionalArgs: '--exclude ru/to-be-excluded.md',
72
+ additionalArgs: '--exclude ru/_no-translate/*.md',
47
73
  },
48
74
  );
49
75
 
50
- const vars = {skip: 'prod'}
51
76
  generateMapTestTemplate(
52
- 'filter files on extract with extra vars option',
53
- 'mocks/translation/dir-files',
77
+ 'test no-translate directive',
78
+ 'mocks/translation/no-translate',
54
79
  {
55
80
  subcommand: 'extract',
56
81
  source: 'ru-RU',
57
- target: 'es-ES',
58
- additionalArgs: `--vars ${JSON.stringify(vars)}`,
82
+ target: 'es-ES',
59
83
  },
84
+ false,
60
85
  );
61
86
 
62
87
  generateFilesYamlTestTemplate('extract yaml scheme files', 'mocks/translation/yaml-scheme', {
@@ -11,6 +11,7 @@ export function platformless(text: string): string {
11
11
  export function hashless(text: string): string {
12
12
  return text
13
13
  .replace(/-[a-z0-9]{12}\./g, '-hash.')
14
+ .replace(/(\/|\\)[a-z0-9]{12,13}-(index|registry|resources)\./g, '/hash-$2.');
14
15
  }
15
16
 
16
17
  export function bundleless(text: string): string {
@@ -0,0 +1,3 @@
1
+ # Header
2
+
3
+ Content
@@ -0,0 +1 @@
1
+ href: index.md
@@ -1,5 +1,7 @@
1
1
  ## Заголовок include
2
2
 
3
- <!-- [ссылка на файл не в toc.yaml](./aboba-not-in-toc.md) -->
3
+ [ссылка на файл не в toc.yaml](./aboba-not-in-toc.md)
4
+
5
+ {% include [Описание](./_includes/test.md) %}
6
+
4
7
 
5
- {% include [Описание](./_includes/test.md) %}
@@ -3,7 +3,6 @@ href: index.yaml
3
3
  items:
4
4
  - name: API Yandex Cloud
5
5
  href: index.yaml
6
- - include: {mode: merge, path: folder1/toc-i.yaml}
7
6
  - name: Yandex Flavored Markdown
8
7
  href: index-yfm.md
9
8
  items:
@@ -4,10 +4,4 @@ items:
4
4
  - name: Aboba
5
5
  href: aboba.md
6
6
  - name: Не переводить
7
- when: skip == 'prod'
8
- href: _no-translate/exclude.md
9
- - name: Нет переменной в vars
10
- when: novar == 'test'
11
- href: no-var-page.md
12
- - name: exclude-test
13
- href: to-be-excluded.md
7
+ href: _no-translate/exclude.md
@@ -0,0 +1,7 @@
1
+ ## Index header
2
+
3
+ ::no-translate [adsfasdfasdfasdfasdf]
4
+
5
+ lorem
6
+
7
+ asdfasdfasdf
@@ -0,0 +1,57 @@
1
+ # No-translate directive
2
+
3
+ ## Block directive
4
+ :::no-translate
5
+ ### No-translate header
6
+
7
+ :::html-block
8
+ testsetsets
9
+ :::
10
+
11
+ ::: any-other-directive
12
+ content test
13
+ :::
14
+
15
+ Should not be translated.
16
+ Can use **markup** inside.
17
+ :::
18
+
19
+
20
+ ::: some-other-directive
21
+ content here
22
+ :::
23
+ ::: no-translate
24
+ content here
25
+ ::: some-other-directive
26
+ nested content
27
+ :::
28
+ :::
29
+
30
+ ## Leaf directive
31
+
32
+ ::no-translate [## /usr/local/bin/application]
33
+ ::no-translate[**C:\Program Files\Application\config.ini**]
34
+ ::no-translate [~/Documents/project/src/main.rs]
35
+
36
+
37
+ - :no-translate[GET /api/v1/users] — get all users
38
+ - :no-translate[POST /api/v1/auth/login] — authorization
39
+ - :no-translate[PUT /api/v1/users/{id}] — update users data
40
+
41
+ ## Simple case leaf
42
+ Install using command.
43
+ :no-translate[The default port is unless specified.] Next sentence.
44
+ Set NODE_ENV=production for production builds.
45
+
46
+ ## Simple case inline
47
+ Install using :no-translate[npm install @company/package] command.
48
+ The default port is :no-translate[8080] unless specified.
49
+ Set :no-translate[NODE_ENV=production] for production builds.
50
+
51
+ ## Few inline directives
52
+ Use :no-translate[**GET /api/v1/users**] to list users and :no-translate[POST /api/v1/users] to create.
53
+
54
+ ## Empty inline directive
55
+ This is text with empty :no-translate[] directive.
56
+
57
+
@@ -0,0 +1,37 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: OpenAPI definition
4
+ version: v0
5
+ servers:
6
+ - url: http://localhost:8080
7
+ description: Generated server url
8
+ paths:
9
+ /test:
10
+ get:
11
+ tags:
12
+ - test-controller
13
+ summary: Simple get operation. тест новой верстки 3
14
+ description: Defines a simple get :no-translate[skip this] operation with no inputs and a complex
15
+ operationId: getWithPayloadResponse
16
+ responses:
17
+ "200":
18
+ description: 200!!!!
19
+ content:
20
+ application/json:
21
+ schema:
22
+ $ref: '#/components/schemas/RecurceTop'
23
+ components:
24
+ schemas:
25
+ RecurceTop:
26
+ type: object
27
+ properties:
28
+ A:
29
+ type: string
30
+ # $ref: '#/components/schemas/RecurceMiddle'
31
+ RecurceMiddle:
32
+ type: object
33
+ properties:
34
+ B:
35
+ type: array
36
+ items:
37
+ $ref: '#/components/schemas/RecurceTop'
@@ -0,0 +1,11 @@
1
+ title: Test123
2
+ href: index.md
3
+ items:
4
+ - name: Не переводить
5
+ href: no-translate.md
6
+ - name: openapi
7
+ include:
8
+ path: openapi
9
+ includers:
10
+ - name: openapi
11
+ input: openapi-spec.yaml
@@ -0,0 +1,42 @@
1
+ openapi: 3.0.1
2
+ info:
3
+ title: OpenAPI definition
4
+ version: v0
5
+ servers:
6
+ - url: http://localhost:8080
7
+ description: Generated server url
8
+ paths:
9
+ /test:
10
+ get:
11
+ tags:
12
+ - test-controller
13
+ summary: Simple get operation. тест новой верстки 3
14
+ description: Defines a simple get operation with no inputs and a complex
15
+ operationId: getWithPayloadResponse
16
+ responses:
17
+ "200":
18
+ description: 200!!!!
19
+ content:
20
+ application/json:
21
+ schema:
22
+ $ref: '#/components/schemas/RecurceTop'
23
+ components:
24
+ schemas:
25
+ RecurceTop:
26
+ type: object
27
+ properties:
28
+ A:
29
+ type: string
30
+ description: |
31
+ Статус загрузки:
32
+ - `UPLOADED` — загрузка завершена.
33
+ - `IN_PROGRESS` — загрузка находится в процессе обработки.
34
+ - `PROCESSED` — загрузка успешно обработана.
35
+ # $ref: '#/components/schemas/RecurceMiddle'
36
+ RecurceMiddle:
37
+ type: object
38
+ properties:
39
+ B:
40
+ type: array
41
+ items:
42
+ $ref: '#/components/schemas/RecurceTop'
@@ -0,0 +1,8 @@
1
+ items:
2
+ - name: openapi
3
+ include:
4
+ path: openapi
5
+ includers:
6
+ - name: openapi
7
+ input: openapi-spec.yaml
8
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "0.0.0-rc-toc-translation-202506261401",
3
+ "version": "0.0.0-rc-fix-translate-openapi-includer-202507171205",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },
@@ -1,6 +0,0 @@
1
- translate:
2
- extract:
3
- vars:
4
- test: prod
5
- skip: dev
6
-
@@ -1,3 +0,0 @@
1
- ## Included A1
2
-
3
- TEST
@@ -1,3 +0,0 @@
1
- ## Included A1
2
-
3
- TEST
@@ -1,3 +0,0 @@
1
- items:
2
- - name: A1
3
- href: a1.md
@@ -1,3 +0,0 @@
1
- ## No var page
2
-
3
- This page might be translated or not. Depends on --strict-vars option.
@@ -1 +0,0 @@
1
- ## Excluded title