Ver Fonte

refactor(i18n): remove obsolete link lookup

pku-xht há 3 semanas atrás
pai
commit
f6fb074036
2 ficheiros alterados com 9 adições e 18 exclusões
  1. 9 6
      scripts/translation-pairing.spec.ts
  2. 0 12
      scripts/translation-pairing.ts

+ 9 - 6
scripts/translation-pairing.spec.ts

@@ -20,7 +20,6 @@ import {
   blobHash,
   isTranslationScopeFile,
   languageSwitcherTargets,
-  linksTo,
   pairAnchorOfArgument,
   parseTranslationMarkdown,
   parseTranslationPairingCliArgs,
@@ -187,17 +186,21 @@ describe('translation pairing switchers', () => {
     const targets = languageSwitcherTargets('python/sdk/README.zh.md')
     const canonicalMarkdown = '# README\n\nEnglish | [中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/python/sdk/README.zh.md)\n'
     const canonical = parseTranslationMarkdown(canonicalMarkdown)
-    const wrongPath = parseTranslationMarkdown(
-      '[中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md)',
-    )
+    const wrongMarkdown = '# README\n\nEnglish | [中文](https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md)\n'
+    const wrongPath = parseTranslationMarkdown(wrongMarkdown)
 
-    expect(linksTo(canonical, targets)).toBe(true)
     expect(translationStructureSignature(canonical, targets, {
       repoRoot: process.cwd(),
       sourcePath: 'python/sdk/README.md',
       markdown: canonicalMarkdown,
     }).links).toEqual([])
-    expect(linksTo(wrongPath, targets)).toBe(false)
+    expect(translationStructureSignature(wrongPath, targets, {
+      repoRoot: process.cwd(),
+      sourcePath: 'python/sdk/README.md',
+      markdown: wrongMarkdown,
+    }).links).toEqual([
+      'https://github.com/deepseek-ai/deepseek-harness/blob/master/other/README.zh.md',
+    ])
   })
 
   it('excludes only the header switcher from the structural links', () => {

+ 0 - 12
scripts/translation-pairing.ts

@@ -314,18 +314,6 @@ export function languageSwitcherTargets(counterpart: string): string[] {
   return [basename(counterpart), `${PUBLIC_REPOSITORY_BLOB_ROOT}${counterpart}`]
 }
 
-/** Whether the tree contains a link to any accepted target. */
-export function linksTo(tree: Nodes, targets: string | readonly string[]): boolean {
-  const accepted = new Set(typeof targets === 'string' ? [targets] : targets)
-  let found = false
-  const visit = (node: Nodes): void => {
-    if (node.type === 'link' && accepted.has(node.url)) found = true
-    if ('children' in node) for (const child of node.children) visit(child)
-  }
-  visit(tree)
-  return found
-}
-
 /** Generated English sources cannot carry a switcher without making their generator stale. */
 export function requiresSourceLanguageSwitcher(source: string): boolean {
   return ![