@diplodoc/cli-tests 0.0.0-rc-fix-translate-openapi-includer-202507171205 → 0.0.0-rc-liquid-conditions-saving-202509050811

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 (108) hide show
  1. package/e2e/__snapshots__/generate-map.spec.ts.snap +345 -0
  2. package/e2e/__snapshots__/include-toc.test.ts.snap +8 -0
  3. package/e2e/__snapshots__/load-custom-resources.spec.ts.snap +64 -59
  4. package/e2e/__snapshots__/metadata.spec.ts.snap +29 -24
  5. package/e2e/__snapshots__/preprocess.test.ts.snap +549 -0
  6. package/e2e/__snapshots__/regression.test.ts.snap +177 -142
  7. package/e2e/__snapshots__/rtl.spec.ts.snap +44 -41
  8. package/e2e/__snapshots__/search.test.ts.snap +37 -22
  9. package/e2e/__snapshots__/skip-html-extension.spec.ts.snap +211 -0
  10. package/e2e/__snapshots__/translation.spec.ts.snap +518 -2
  11. package/e2e/errors.spec.ts +33 -2
  12. package/e2e/generate-map.spec.ts +9 -3
  13. package/e2e/preprocess.test.ts +33 -0
  14. package/e2e/redirects-validation.spec.ts +61 -0
  15. package/e2e/search.test.ts +1 -1
  16. package/e2e/skip-html-extension.spec.ts +15 -0
  17. package/e2e/translation.spec.ts +47 -2
  18. package/fixtures/cliAdapter.ts +23 -0
  19. package/fixtures/globals.d.ts +4 -0
  20. package/fixtures/runners/binary.ts +4 -3
  21. package/fixtures/runners/types.ts +1 -2
  22. package/fixtures/utils/file.ts +5 -5
  23. package/fixtures/utils/test.ts +17 -8
  24. package/mocks/docs-viewer-interface/input/.yfm +6 -0
  25. package/mocks/docs-viewer-interface/input/index.md +3 -0
  26. package/mocks/docs-viewer-interface/input/toc.yaml +5 -0
  27. package/mocks/errors/extract-filtered-link/input/filtered.md +1 -0
  28. package/mocks/errors/extract-filtered-link/input/filtered2.md +0 -0
  29. package/mocks/errors/extract-filtered-link/input/index.md +7 -0
  30. package/mocks/errors/extract-filtered-link/input/toc.yaml +1 -0
  31. package/mocks/load-custom-resources/md2html-with-resources/input/page.md +9 -2
  32. package/mocks/load-custom-resources/md2md-with-resources/input/page.md +9 -2
  33. package/mocks/load-custom-resources/single-page-with-resources/input/page.md +9 -2
  34. package/mocks/metadata/md2html-with-metadata/input/page.md +8 -1
  35. package/mocks/metadata/md2md-with-metadata/input/page.md +7 -0
  36. package/mocks/preprocess/input/.yfm +1 -0
  37. package/mocks/preprocess/input/1.md +29 -0
  38. package/mocks/preprocess/input/_assets/1.png +0 -0
  39. package/mocks/preprocess/input/_assets/1.svg +0 -0
  40. package/mocks/preprocess/input/autotitle.md +23 -0
  41. package/mocks/preprocess/input/commented-include.md +3 -0
  42. package/mocks/preprocess/input/images.md +5 -0
  43. package/mocks/preprocess/input/included-item.md +12 -0
  44. package/mocks/preprocess/input/includes/deep.md +1 -0
  45. package/mocks/preprocess/input/includes/deepWithIndent.md +6 -0
  46. package/mocks/preprocess/input/includes/presets.yaml +2 -0
  47. package/mocks/preprocess/input/includes/sub/user.md +1 -0
  48. package/mocks/preprocess/input/includes/sub/userWithIndent.md +5 -0
  49. package/mocks/preprocess/input/includes/test.md +1 -0
  50. package/mocks/preprocess/input/includes/user.md +1 -0
  51. package/mocks/preprocess/input/includes.md +18 -0
  52. package/mocks/preprocess/input/latex.md +3 -0
  53. package/mocks/preprocess/input/mermaid.md +13 -0
  54. package/mocks/preprocess/input/presets.yaml +8 -0
  55. package/mocks/preprocess/input/sub/folder/item-1.md +7 -0
  56. package/mocks/preprocess/input/sub/toc.yaml +5 -0
  57. package/mocks/preprocess/input/toc-i.yaml +3 -0
  58. package/mocks/preprocess/input/toc.yaml +16 -0
  59. package/mocks/redirects-validation/extensions-deprecation/input/blah.md +0 -0
  60. package/mocks/redirects-validation/extensions-deprecation/input/redirects.yaml +5 -0
  61. package/mocks/redirects-validation/extensions-deprecation/input/toc.yaml +4 -0
  62. package/mocks/redirects-validation/invalid-regex/input/blah.md +0 -0
  63. package/mocks/redirects-validation/invalid-regex/input/redirects.yaml +3 -0
  64. package/mocks/redirects-validation/invalid-regex/input/toc.yaml +4 -0
  65. package/mocks/redirects-validation/malformed-redirect/input/blah.md +0 -0
  66. package/mocks/redirects-validation/malformed-redirect/input/redirects.yaml +6 -0
  67. package/mocks/redirects-validation/malformed-redirect/input/toc.yaml +4 -0
  68. package/mocks/redirects-validation/same-path/input/blah.md +0 -0
  69. package/mocks/redirects-validation/same-path/input/redirects.yaml +3 -0
  70. package/mocks/redirects-validation/same-path/input/toc.yaml +4 -0
  71. package/mocks/redirects-validation/unparseable/input/blah.md +0 -0
  72. package/mocks/redirects-validation/unparseable/input/redirects.yaml +11 -0
  73. package/mocks/redirects-validation/unparseable/input/toc.yaml +4 -0
  74. package/mocks/regression/input/.yfm +2 -0
  75. package/mocks/regression/input/images.md +2 -0
  76. package/mocks/regression/input/includes/deep.md +2 -0
  77. package/mocks/regression/input/includes/presets.yaml +1 -0
  78. package/mocks/regression/input/includes/tools.md +1 -0
  79. package/mocks/regression/input/includes.md +5 -0
  80. package/mocks/regression/input/merge/merge.md +2 -0
  81. package/mocks/regression/input/merge/presets.yaml +1 -0
  82. package/mocks/regression/input/merge/toc.yaml +2 -0
  83. package/mocks/regression/input/presets.yaml +1 -0
  84. package/mocks/regression/input/toc.yaml +2 -0
  85. package/mocks/search/input/.yfm +12 -0
  86. package/mocks/skip-html-extension/input/.yfm +1 -0
  87. package/mocks/skip-html-extension/input/folder/index.md +1 -0
  88. package/mocks/skip-html-extension/input/index-test-html/index.md +4 -0
  89. package/mocks/skip-html-extension/input/index.md +6 -0
  90. package/mocks/skip-html-extension/input/page1.md +3 -0
  91. package/mocks/skip-html-extension/input/page2.md +6 -0
  92. package/mocks/skip-html-extension/input/toc.yaml +13 -0
  93. package/mocks/translation/conditions/input/index.md +37 -0
  94. package/mocks/translation/dir-files/input/.yfm +6 -0
  95. package/mocks/translation/dir-files/input/ru/aboba.md +2 -4
  96. package/mocks/translation/dir-files/input/ru/nested/a1.md +3 -0
  97. package/mocks/translation/dir-files/input/ru/nested/folder1/a1.md +3 -0
  98. package/mocks/translation/dir-files/input/ru/nested/folder1/toc-i.yaml +3 -0
  99. package/mocks/translation/dir-files/input/ru/nested/syntax/base.md +2 -0
  100. package/mocks/translation/dir-files/input/ru/nested/toc.yaml +1 -0
  101. package/mocks/translation/dir-files/input/ru/no-var-page.md +3 -0
  102. package/mocks/translation/dir-files/input/ru/to-be-excluded.md +1 -0
  103. package/mocks/translation/dir-files/input/ru/toc.yaml +7 -1
  104. package/mocks/translation/openapi/input/toc.yaml +1 -1
  105. package/mocks/warning/unreachable-autotitle/input/index.md +1 -0
  106. package/mocks/warning/unreachable-autotitle/input/link.md +0 -0
  107. package/mocks/warning/unreachable-autotitle/input/toc.yaml +4 -0
  108. package/package.json +5 -5
@@ -612,6 +612,47 @@ path: toc.yaml
612
612
  "
613
613
  `;
614
614
 
615
+ exports[`Translate command > do not filter files on extract > filelist 1`] = `
616
+ "[
617
+ "es/_includes/test.md.skl",
618
+ "es/_includes/test.md.xliff",
619
+ "es/_no-translate/exclude.md.skl",
620
+ "es/_no-translate/exclude.md.xliff",
621
+ "es/aboba.md.skl",
622
+ "es/aboba.md.xliff",
623
+ "es/index.md.skl",
624
+ "es/index.md.xliff",
625
+ "es/nested/a1.md.skl",
626
+ "es/nested/a1.md.xliff",
627
+ "es/nested/folder1/a1.md.skl",
628
+ "es/nested/folder1/a1.md.xliff",
629
+ "es/nested/folder1/toc-i.yaml.skl",
630
+ "es/nested/folder1/toc-i.yaml.xliff",
631
+ "es/nested/index-yfm.md.skl",
632
+ "es/nested/index-yfm.md.xliff",
633
+ "es/nested/index.yaml.skl",
634
+ "es/nested/index.yaml.xliff",
635
+ "es/nested/not-in-toc.md.skl",
636
+ "es/nested/not-in-toc.md.xliff",
637
+ "es/nested/syntax/base.md.skl",
638
+ "es/nested/syntax/base.md.xliff",
639
+ "es/nested/syntax/index.md.skl",
640
+ "es/nested/syntax/index.md.xliff",
641
+ "es/nested/syntax/lists.md.skl",
642
+ "es/nested/syntax/lists.md.xliff",
643
+ "es/nested/toc.yaml.skl",
644
+ "es/nested/toc.yaml.xliff",
645
+ "es/no-var-page.md.skl",
646
+ "es/no-var-page.md.xliff",
647
+ "es/not-in-toc.md.skl",
648
+ "es/not-in-toc.md.xliff",
649
+ "es/to-be-excluded.md.skl",
650
+ "es/to-be-excluded.md.xliff",
651
+ "es/toc.yaml.skl",
652
+ "es/toc.yaml.xliff"
653
+ ]"
654
+ `;
655
+
615
656
  exports[`Translate command > extract openapi spec files > filelist 1`] = `
616
657
  "[
617
658
  "openapi-spec.yaml.skl",
@@ -716,6 +757,7 @@ exports[`Translate command > extract openapi spec files 3`] = `
716
757
  includers:
717
758
  - name: openapi
718
759
  input: openapi-spec.yaml
760
+ mode: link
719
761
  "
720
762
  `;
721
763
 
@@ -1686,12 +1728,12 @@ exports[`Translate command > filter files on extract > filelist 1`] = `
1686
1728
  "[
1687
1729
  "es/_includes/test.md.skl",
1688
1730
  "es/_includes/test.md.xliff",
1689
- "es/_no-translate/exclude.md.skl",
1690
- "es/_no-translate/exclude.md.xliff",
1691
1731
  "es/aboba.md.skl",
1692
1732
  "es/aboba.md.xliff",
1693
1733
  "es/index.md.skl",
1694
1734
  "es/index.md.xliff",
1735
+ "es/nested/a1.md.skl",
1736
+ "es/nested/a1.md.xliff",
1695
1737
  "es/nested/index-yfm.md.skl",
1696
1738
  "es/nested/index-yfm.md.xliff",
1697
1739
  "es/nested/index.yaml.skl",
@@ -1702,6 +1744,10 @@ exports[`Translate command > filter files on extract > filelist 1`] = `
1702
1744
  "es/nested/syntax/lists.md.xliff",
1703
1745
  "es/nested/toc.yaml.skl",
1704
1746
  "es/nested/toc.yaml.xliff",
1747
+ "es/no-var-page.md.skl",
1748
+ "es/no-var-page.md.xliff",
1749
+ "es/to-be-excluded.md.skl",
1750
+ "es/to-be-excluded.md.xliff",
1705
1751
  "es/toc.yaml.skl",
1706
1752
  "es/toc.yaml.xliff"
1707
1753
  ]"
@@ -1715,6 +1761,8 @@ exports[`Translate command > filter files on extract with extra exclude option >
1715
1761
  "es/aboba.md.xliff",
1716
1762
  "es/index.md.skl",
1717
1763
  "es/index.md.xliff",
1764
+ "es/nested/a1.md.skl",
1765
+ "es/nested/a1.md.xliff",
1718
1766
  "es/nested/index-yfm.md.skl",
1719
1767
  "es/nested/index-yfm.md.xliff",
1720
1768
  "es/nested/index.yaml.skl",
@@ -1725,11 +1773,98 @@ exports[`Translate command > filter files on extract with extra exclude option >
1725
1773
  "es/nested/syntax/lists.md.xliff",
1726
1774
  "es/nested/toc.yaml.skl",
1727
1775
  "es/nested/toc.yaml.xliff",
1776
+ "es/no-var-page.md.skl",
1777
+ "es/no-var-page.md.xliff",
1728
1778
  "es/toc.yaml.skl",
1729
1779
  "es/toc.yaml.xliff"
1730
1780
  ]"
1731
1781
  `;
1732
1782
 
1783
+ exports[`Translate command > filter files on extract with extra vars option > filelist 1`] = `
1784
+ "[
1785
+ "es/_includes/test.md.skl",
1786
+ "es/_includes/test.md.xliff",
1787
+ "es/_no-translate/exclude.md.skl",
1788
+ "es/_no-translate/exclude.md.xliff",
1789
+ "es/aboba.md.skl",
1790
+ "es/aboba.md.xliff",
1791
+ "es/index.md.skl",
1792
+ "es/index.md.xliff",
1793
+ "es/nested/a1.md.skl",
1794
+ "es/nested/a1.md.xliff",
1795
+ "es/nested/index-yfm.md.skl",
1796
+ "es/nested/index-yfm.md.xliff",
1797
+ "es/nested/index.yaml.skl",
1798
+ "es/nested/index.yaml.xliff",
1799
+ "es/nested/syntax/base.md.skl",
1800
+ "es/nested/syntax/base.md.xliff",
1801
+ "es/nested/syntax/lists.md.skl",
1802
+ "es/nested/syntax/lists.md.xliff",
1803
+ "es/nested/toc.yaml.skl",
1804
+ "es/nested/toc.yaml.xliff",
1805
+ "es/no-var-page.md.skl",
1806
+ "es/no-var-page.md.xliff",
1807
+ "es/to-be-excluded.md.skl",
1808
+ "es/to-be-excluded.md.xliff",
1809
+ "es/toc.yaml.skl",
1810
+ "es/toc.yaml.xliff"
1811
+ ]"
1812
+ `;
1813
+
1814
+ exports[`Translate command > remove falsy liquid conditions structures > filelist 1`] = `
1815
+ "[
1816
+ "index.md.skl",
1817
+ "index.md.xliff"
1818
+ ]"
1819
+ `;
1820
+
1821
+ exports[`Translate command > remove falsy liquid conditions structures 1`] = `
1822
+ "%%%0%%%
1823
+ <!-- [missed file](./missed.md) -->
1824
+
1825
+
1826
+
1827
+
1828
+ #### %%%1%%%
1829
+
1830
+ {% if list contains "item" %}
1831
+
1832
+ %%%2%%%
1833
+
1834
+ {% endif %}
1835
+
1836
+ #### %%%3%%%
1837
+
1838
+ "
1839
+ `;
1840
+
1841
+ exports[`Translate command > remove falsy liquid conditions structures 2`] = `
1842
+ "<?xml version="1.0" encoding="UTF-8"?>
1843
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
1844
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
1845
+ <header>
1846
+ <skeleton>
1847
+ <external-file href="file.skl"></external-file>
1848
+ </skeleton>
1849
+ </header>
1850
+ <body>
1851
+ <trans-unit id="0">
1852
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
1853
+ </trans-unit>
1854
+ <trans-unit id="1">
1855
+ <source xml:space="preserve">Standalone contains condition</source>
1856
+ </trans-unit>
1857
+ <trans-unit id="2">
1858
+ <source xml:space="preserve">#### List</source>
1859
+ </trans-unit>
1860
+ <trans-unit id="3">
1861
+ <source xml:space="preserve">Inline contains condition</source>
1862
+ </trans-unit>
1863
+ </body>
1864
+ </file>
1865
+ </xliff>"
1866
+ `;
1867
+
1733
1868
  exports[`Translate command > removes no-translate directive and leaves content as is > filelist 1`] = `
1734
1869
  "[
1735
1870
  "index.md.skl",
@@ -1996,6 +2131,105 @@ exports[`Translate command > removes no-translate directive and leaves content a
1996
2131
  </xliff>"
1997
2132
  `;
1998
2133
 
2134
+ exports[`Translate command > save truthy liquid conditions structures > filelist 1`] = `
2135
+ "[
2136
+ "index.md.skl",
2137
+ "index.md.xliff"
2138
+ ]"
2139
+ `;
2140
+
2141
+ exports[`Translate command > save truthy liquid conditions structures 1`] = `
2142
+ "%%%0%%%
2143
+ <!-- [missed file](./missed.md) -->
2144
+ {% if prod == true %}%%%1%%%{% endif %}
2145
+
2146
+ {% if inner == true %}%%%2%%%{% endif %}
2147
+
2148
+ {% if prod == true %}%%%3%%%{% endif %}{% endif %}
2149
+
2150
+ {% if prod == true %}
2151
+
2152
+ {% if list contains "item" %}
2153
+
2154
+ %%%4%%%
2155
+
2156
+ {% if item == true %}%%%5%%% %%%6%%% {% endif %}
2157
+
2158
+ %%%7%%%
2159
+
2160
+ {% endif %}
2161
+
2162
+ {% endif %}
2163
+
2164
+ #### %%%8%%%
2165
+
2166
+ {% if list contains "item" %}
2167
+
2168
+ %%%9%%%
2169
+
2170
+ {% endif %}
2171
+
2172
+ #### %%%10%%%
2173
+
2174
+ {% if prod == true %}
2175
+
2176
+ %%%11%%% {% endif %}
2177
+
2178
+ {% endif %}
2179
+ "
2180
+ `;
2181
+
2182
+ exports[`Translate command > save truthy liquid conditions structures 2`] = `
2183
+ "<?xml version="1.0" encoding="UTF-8"?>
2184
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2185
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2186
+ <header>
2187
+ <skeleton>
2188
+ <external-file href="file.skl"></external-file>
2189
+ </skeleton>
2190
+ </header>
2191
+ <body>
2192
+ <trans-unit id="0">
2193
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
2194
+ </trans-unit>
2195
+ <trans-unit id="1">
2196
+ <source xml:space="preserve">Test text</source>
2197
+ </trans-unit>
2198
+ <trans-unit id="2">
2199
+ <source xml:space="preserve">inner test text</source>
2200
+ </trans-unit>
2201
+ <trans-unit id="3">
2202
+ <source xml:space="preserve">Test text<x ctype="liquid_Literal" equiv-text="{% if inner == true %}" id="x-1"/>inner test text</source>
2203
+ </trans-unit>
2204
+ <trans-unit id="4">
2205
+ <source xml:space="preserve">#### List</source>
2206
+ </trans-unit>
2207
+ <trans-unit id="5">
2208
+ <source xml:space="preserve">1.</source>
2209
+ </trans-unit>
2210
+ <trans-unit id="6">
2211
+ <source xml:space="preserve">Item</source>
2212
+ </trans-unit>
2213
+ <trans-unit id="7">
2214
+ <source xml:space="preserve">Some text</source>
2215
+ </trans-unit>
2216
+ <trans-unit id="8">
2217
+ <source xml:space="preserve">Standalone contains condition</source>
2218
+ </trans-unit>
2219
+ <trans-unit id="9">
2220
+ <source xml:space="preserve">#### List</source>
2221
+ </trans-unit>
2222
+ <trans-unit id="10">
2223
+ <source xml:space="preserve">Inline contains condition</source>
2224
+ </trans-unit>
2225
+ <trans-unit id="11">
2226
+ <source xml:space="preserve">#### List <x ctype="liquid_Literal" equiv-text="{% if list contains &quot;item&quot; %}" id="x-2"/> sub text</source>
2227
+ </trans-unit>
2228
+ </body>
2229
+ </file>
2230
+ </xliff>"
2231
+ `;
2232
+
1999
2233
  exports[`Translate command > skip no-translate marked content > filelist 1`] = `
2000
2234
  "[
2001
2235
  "index.md.skl",
@@ -2261,3 +2495,285 @@ exports[`Translate command > skip no-translate marked content 8`] = `
2261
2495
  </file>
2262
2496
  </xliff>"
2263
2497
  `;
2498
+
2499
+ exports[`Translate command > test no-translate directive > filelist 1`] = `
2500
+ "[
2501
+ "index.md.skl",
2502
+ "index.md.xliff",
2503
+ "no-translate.md.skl",
2504
+ "no-translate.md.xliff",
2505
+ "openapi-spec.yaml.skl",
2506
+ "openapi-spec.yaml.xliff",
2507
+ "toc.yaml.skl",
2508
+ "toc.yaml.xliff"
2509
+ ]"
2510
+ `;
2511
+
2512
+ exports[`Translate command > test no-translate directive 1`] = `
2513
+ "## %%%0%%%
2514
+
2515
+ ::no-translate [adsfasdfasdfasdfasdf]
2516
+
2517
+ %%%1%%%
2518
+
2519
+ %%%2%%%"
2520
+ `;
2521
+
2522
+ exports[`Translate command > test no-translate directive 2`] = `
2523
+ "<?xml version="1.0" encoding="UTF-8"?>
2524
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2525
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2526
+ <header>
2527
+ <skeleton>
2528
+ <external-file href="file.skl"></external-file>
2529
+ </skeleton>
2530
+ </header>
2531
+ <body>
2532
+ <trans-unit id="0">
2533
+ <source xml:space="preserve">Index header</source>
2534
+ </trans-unit>
2535
+ <trans-unit id="1">
2536
+ <source xml:space="preserve">lorem</source>
2537
+ </trans-unit>
2538
+ <trans-unit id="2">
2539
+ <source xml:space="preserve">asdfasdfasdf</source>
2540
+ </trans-unit>
2541
+ </body>
2542
+ </file>
2543
+ </xliff>"
2544
+ `;
2545
+
2546
+ exports[`Translate command > test no-translate directive 3`] = `
2547
+ "# %%%0%%%
2548
+
2549
+ ## %%%1%%%
2550
+ :::no-translate
2551
+ ### No-translate header
2552
+
2553
+ :::html-block
2554
+ testsetsets
2555
+ :::
2556
+
2557
+ ::: any-other-directive
2558
+ content test
2559
+ :::
2560
+
2561
+ Should not be translated.
2562
+ Can use **markup** inside.
2563
+ :::
2564
+
2565
+
2566
+ %%%2%%%
2567
+
2568
+ ## %%%3%%%
2569
+
2570
+ ::no-translate [## /usr/local/bin/application]
2571
+ ::no-translate[**C:/Program Files/Application/config.ini**]
2572
+ ::no-translate [~/Documents/project/src/main.rs]
2573
+
2574
+
2575
+ - :no-translate[GET /api/v1/users] %%%4%%%
2576
+ - :no-translate[POST /api/v1/auth/login] %%%5%%%
2577
+ - :no-translate[PUT /api/v1/users/{id}] %%%6%%%
2578
+
2579
+ ## %%%7%%%
2580
+ %%%8%%%
2581
+ :no-translate[The default port is unless specified.] %%%9%%%
2582
+ %%%10%%%
2583
+
2584
+ ## %%%11%%%
2585
+ %%%12%%%
2586
+ %%%13%%%
2587
+ %%%14%%%
2588
+
2589
+ ## %%%15%%%
2590
+ %%%16%%%
2591
+
2592
+ ## %%%17%%%
2593
+ %%%18%%%
2594
+
2595
+
2596
+ "
2597
+ `;
2598
+
2599
+ exports[`Translate command > test no-translate directive 4`] = `
2600
+ "<?xml version="1.0" encoding="UTF-8"?>
2601
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2602
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2603
+ <header>
2604
+ <skeleton>
2605
+ <external-file href="file.skl"></external-file>
2606
+ </skeleton>
2607
+ </header>
2608
+ <body>
2609
+ <trans-unit id="0">
2610
+ <source xml:space="preserve">No-translate directive</source>
2611
+ </trans-unit>
2612
+ <trans-unit id="1">
2613
+ <source xml:space="preserve">Block directive</source>
2614
+ </trans-unit>
2615
+ <trans-unit id="2">
2616
+ <source xml:space="preserve">::: some-other-directive<x ctype="lb" equiv-text="&amp;#10;" id="x-1"/>content here<x ctype="lb" equiv-text="&amp;#10;" id="x-2"/>:::<x ctype="lb" equiv-text="&amp;#10;" id="x-3"/>::: no-translate<x ctype="lb" equiv-text="&amp;#10;" id="x-4"/>content here<x ctype="lb" equiv-text="&amp;#10;" id="x-5"/>::: some-other-directive<x ctype="lb" equiv-text="&amp;#10;" id="x-6"/>nested content<x ctype="lb" equiv-text="&amp;#10;" id="x-7"/>:::<x ctype="lb" equiv-text="&amp;#10;" id="x-8"/>:::</source>
2617
+ </trans-unit>
2618
+ <trans-unit id="3">
2619
+ <source xml:space="preserve">Leaf directive</source>
2620
+ </trans-unit>
2621
+ <trans-unit id="4">
2622
+ <source xml:space="preserve">— get all users</source>
2623
+ </trans-unit>
2624
+ <trans-unit id="5">
2625
+ <source xml:space="preserve">— authorization</source>
2626
+ </trans-unit>
2627
+ <trans-unit id="6">
2628
+ <source xml:space="preserve">— update users data</source>
2629
+ </trans-unit>
2630
+ <trans-unit id="7">
2631
+ <source xml:space="preserve">Simple case leaf</source>
2632
+ </trans-unit>
2633
+ <trans-unit id="8">
2634
+ <source xml:space="preserve">Install using command.</source>
2635
+ </trans-unit>
2636
+ <trans-unit id="9">
2637
+ <source xml:space="preserve">Next sentence.</source>
2638
+ </trans-unit>
2639
+ <trans-unit id="10">
2640
+ <source xml:space="preserve">Set NODE_ENV=production for production builds.</source>
2641
+ </trans-unit>
2642
+ <trans-unit id="11">
2643
+ <source xml:space="preserve">Simple case inline</source>
2644
+ </trans-unit>
2645
+ <trans-unit id="12">
2646
+ <source xml:space="preserve">Install using <x ctype="no_translate_inline" equiv-text=":no-translate[npm install @company/package]" id="x-9"/> command.</source>
2647
+ </trans-unit>
2648
+ <trans-unit id="13">
2649
+ <source xml:space="preserve">The default port is <x ctype="no_translate_inline" equiv-text=":no-translate[8080]" id="x-10"/> unless specified.</source>
2650
+ </trans-unit>
2651
+ <trans-unit id="14">
2652
+ <source xml:space="preserve">Set <x ctype="no_translate_inline" equiv-text=":no-translate[NODE_ENV=production]" id="x-11"/> for production builds.</source>
2653
+ </trans-unit>
2654
+ <trans-unit id="15">
2655
+ <source xml:space="preserve">Few inline directives</source>
2656
+ </trans-unit>
2657
+ <trans-unit id="16">
2658
+ <source xml:space="preserve">Use <x ctype="no_translate_inline" equiv-text=":no-translate[**GET /api/v1/users**]" id="x-12"/> to list users and <x ctype="no_translate_inline" equiv-text=":no-translate[POST /api/v1/users]" id="x-13"/> to create.</source>
2659
+ </trans-unit>
2660
+ <trans-unit id="17">
2661
+ <source xml:space="preserve">Empty inline directive</source>
2662
+ </trans-unit>
2663
+ <trans-unit id="18">
2664
+ <source xml:space="preserve">This is text with empty <x ctype="no_translate_inline" equiv-text=":no-translate[]" id="x-14"/> directive.</source>
2665
+ </trans-unit>
2666
+ </body>
2667
+ </file>
2668
+ </xliff>"
2669
+ `;
2670
+
2671
+ exports[`Translate command > test no-translate directive 5`] = `
2672
+ "openapi: 3.0.1
2673
+ info:
2674
+ title: '%%%0%%%'
2675
+ version: v0
2676
+ servers:
2677
+ - url: http://localhost:8080
2678
+ description: '%%%1%%%'
2679
+ paths:
2680
+ /test:
2681
+ get:
2682
+ tags:
2683
+ - test-controller
2684
+ summary: '%%%2%%%'
2685
+ description: '%%%3%%%'
2686
+ operationId: getWithPayloadResponse
2687
+ responses:
2688
+ '200':
2689
+ description: '%%%4%%%'
2690
+ content:
2691
+ application/json:
2692
+ schema:
2693
+ $ref: '#/components/schemas/RecurceTop'
2694
+ components:
2695
+ schemas:
2696
+ RecurceTop:
2697
+ type: object
2698
+ properties:
2699
+ A:
2700
+ type: string
2701
+ RecurceMiddle:
2702
+ type: object
2703
+ properties:
2704
+ B:
2705
+ type: array
2706
+ items:
2707
+ $ref: '#/components/schemas/RecurceTop'
2708
+ "
2709
+ `;
2710
+
2711
+ exports[`Translate command > test no-translate directive 6`] = `
2712
+ "<?xml version="1.0" encoding="UTF-8"?>
2713
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2714
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2715
+ <header>
2716
+ <skeleton>
2717
+ <external-file href="file.skl"></external-file>
2718
+ </skeleton>
2719
+ </header>
2720
+ <body>
2721
+ <trans-unit id="0">
2722
+ <source xml:space="preserve">OpenAPI definition</source>
2723
+ </trans-unit>
2724
+ <trans-unit id="1">
2725
+ <source xml:space="preserve">Generated server url</source>
2726
+ </trans-unit>
2727
+ <trans-unit id="2">
2728
+ <source xml:space="preserve">Simple get operation. тест новой верстки 3</source>
2729
+ </trans-unit>
2730
+ <trans-unit id="3">
2731
+ <source xml:space="preserve">Defines a simple get <x ctype="no_translate_inline" equiv-text=":no-translate[skip this]" id="x-15"/> operation with no inputs and a complex</source>
2732
+ </trans-unit>
2733
+ <trans-unit id="4">
2734
+ <source xml:space="preserve">200!!!!</source>
2735
+ </trans-unit>
2736
+ </body>
2737
+ </file>
2738
+ </xliff>"
2739
+ `;
2740
+
2741
+ exports[`Translate command > test no-translate directive 7`] = `
2742
+ "title: '%%%0%%%'
2743
+ href: index.md
2744
+ items:
2745
+ - name: '%%%1%%%'
2746
+ href: no-translate.md
2747
+ - name: '%%%2%%%'
2748
+ include:
2749
+ path: openapi
2750
+ includers:
2751
+ - name: openapi
2752
+ input: openapi-spec.yaml
2753
+ mode: link
2754
+ "
2755
+ `;
2756
+
2757
+ exports[`Translate command > test no-translate directive 8`] = `
2758
+ "<?xml version="1.0" encoding="UTF-8"?>
2759
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2760
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2761
+ <header>
2762
+ <skeleton>
2763
+ <external-file href="file.skl"></external-file>
2764
+ </skeleton>
2765
+ </header>
2766
+ <body>
2767
+ <trans-unit id="0">
2768
+ <source xml:space="preserve">Test123</source>
2769
+ </trans-unit>
2770
+ <trans-unit id="1">
2771
+ <source xml:space="preserve">Не переводить</source>
2772
+ </trans-unit>
2773
+ <trans-unit id="2">
2774
+ <source xml:space="preserve">openapi</source>
2775
+ </trans-unit>
2776
+ </body>
2777
+ </file>
2778
+ </xliff>"
2779
+ `;
@@ -13,12 +13,12 @@ function test(path: string, expect: Function) {
13
13
  const {inputPath, outputPath} = getTestPaths(path);
14
14
 
15
15
  const md = await TestAdapter.build.run(inputPath, outputPath, ['-j2', '-f', 'md']);
16
- const html = await TestAdapter.build.run(outputPath, outputPath + '-html', ['-j2', '-f', 'html']);
17
-
16
+ const html = await TestAdapter.build.run(inputPath, outputPath + '-html', ['-j2', '-f', 'html']);
18
17
  return expect({md, html});
19
18
  });
20
19
  }
21
20
 
21
+
22
22
  describe('Errors', () => {
23
23
  test('mocks/errors/unreachable-link', ({html}: TestResult) => {
24
24
  expectErrors(html, [
@@ -26,6 +26,29 @@ describe('Errors', () => {
26
26
  'ERR index.md: 2: YFM003 / unreachable-link Link is unreachable [Context: "[Unreachable link: "missed.html"][missed file](./missed.md)"]'
27
27
  ]);
28
28
  });
29
+
30
+ it('translate extract with filtered links', async () => {
31
+ const {inputPath, outputPath} = getTestPaths('mocks/errors/extract-filtered-link');
32
+
33
+ const result = await TestAdapter.extract.run(inputPath, outputPath, ['--source', 'ru-RU', '--target', 'es-ES', '--filter']);
34
+
35
+ expect(result.code).toEqual(1);
36
+
37
+ expect(result.errors).toEqual([
38
+ "ERR File index.md contains link to filtered.md, which was filtered from toc.yaml or it's not been included initially",
39
+ "ERR File index.md contains link to filtered2.md, which was filtered from toc.yaml or it's not been included initially",
40
+ "ERR File index.md contains link to filtered2.md, which was filtered from toc.yaml or it's not been included initially",
41
+ "ERR File index.md contains link to filtered3.md, which was filtered from toc.yaml or it's not been included initially",
42
+ ])
43
+ });
44
+ });
45
+
46
+ describe('Warnings', () => {
47
+ test('mocks/warning/unreachable-autotitle', ({html}: TestResult) => {
48
+ expectWarnings(html, [
49
+ '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)"]',
50
+ ]);
51
+ });
29
52
  });
30
53
 
31
54
  function expectErrors(report: Report, errors: string[]) {
@@ -35,3 +58,11 @@ function expectErrors(report: Report, errors: string[]) {
35
58
  expect(report.errors).toContain(error);
36
59
  }
37
60
  }
61
+
62
+ function expectWarnings(report: Report, warnings: string[]) {
63
+ expect(report.warns.length).toEqual(warnings.length);
64
+
65
+ for (const warn of warnings) {
66
+ expect(report.warns).toContain(warn);
67
+ }
68
+ }
@@ -1,6 +1,7 @@
1
1
  import {describe, expect, test} from 'vitest';
2
2
  import {TestAdapter, bundleless, getFileContent, getTestPaths} from '../fixtures';
3
- import {join} from 'path';
3
+ import {join} from 'node:path';
4
+ import {readFile} from 'node:fs/promises';
4
5
 
5
6
  const generateMapTestTemplate = (
6
7
  testTitle: string,
@@ -11,11 +12,17 @@ const generateMapTestTemplate = (
11
12
  test(testTitle, async () => {
12
13
  const {inputPath, outputPath} = getTestPaths(testRootPath);
13
14
 
14
- await TestAdapter.testBuildPass(inputPath, outputPath, {md2md, md2html, args: '--add-map-file'});
15
+ await TestAdapter.testBuildPass(inputPath, outputPath, {
16
+ md2md,
17
+ md2html,
18
+ args: '--add-map-file --build-manifest',
19
+ });
15
20
 
16
21
  const content = getFileContent(join(outputPath, 'files.json'));
22
+ const manifestContent = await readFile(join(outputPath, 'yfm-build-manifest.json'), 'utf-8');
17
23
 
18
24
  expect(bundleless(content)).toMatchSnapshot();
25
+ expect(JSON.parse(manifestContent)).toMatchSnapshot();
19
26
  });
20
27
  };
21
28
 
@@ -28,7 +35,6 @@ describe('Generate map for', () => {
28
35
  generateMapTestTemplate(
29
36
  'project with single language and toc include - only md2html',
30
37
  'mocks/generate-map/test1',
31
- false,
32
38
  );
33
39
 
34
40
  generateMapTestTemplate('project with multiple language', 'mocks/generate-map/test2');