From 926e5a6bb279d3c598af06d774f5d3403cc5b841 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Thu, 15 Aug 2024 22:47:05 +0200 Subject: [PATCH 1/5] require full code coverage (for now) --- package.json | 2 +- scripts/md2html/md2html.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bf24c3ea56..b6edc22d7d 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "license": "Apache-2.0", "scripts": { "build": "bash ./scripts/md2html/build.sh", - "test": "c8 vitest --watch=false" + "test": "c8 --100 vitest --watch=false" }, "readmeFilename": "README.md", "files": [ diff --git a/scripts/md2html/md2html.js b/scripts/md2html/md2html.js index 8be4c21152..71fb269781 100644 --- a/scripts/md2html/md2html.js +++ b/scripts/md2html/md2html.js @@ -209,7 +209,7 @@ for (let l in lines) { line = line.replace('',''); } - // replace deprecated with + // replace deprecated with - needed for older specs line = line.replace(/<\/a>/g,''); line = line.split('\\|').join('|'); // was ¦ From 74e60a7470882dce5ef91c8ab9dbb907cfa84bfb Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Fri, 16 Aug 2024 11:02:34 +0200 Subject: [PATCH 2/5] Link to html wrapper page instead of yaml --- scripts/md2html/md2html.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/md2html/md2html.js b/scripts/md2html/md2html.js index 71fb269781..4cac897395 100644 --- a/scripts/md2html/md2html.js +++ b/scripts/md2html/md2html.js @@ -271,12 +271,14 @@ for (let l in lines) { // fix relative links (to examples) if (!inCodeBlock && line.indexOf('](../examples/') >= 0) { + // links to examples go to learn site, links to yaml files go to wrapper html line = line.replace(/\(\.\.\/examples\/([^)]+)\)/g,function(match,group1){ console.warn("example link",group1); - //TODO: group1 = group1.replace('.yaml','.html'); + group1 = group1.replace('.yaml','.html'); return `(https://learn.openapis.org/examples/${group1})`; }) } else if (!inCodeBlock && line.indexOf('](../') >= 0) { + // links to other sibling files go to github const regExp = /\((\.\.[^)]+)\)/g; line = line.replace(regExp,function(match,group1){ console.warn('relative link',group1); From bcafc212b12437e4b0b4c3b01801e8b7e1203bbd Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Fri, 16 Aug 2024 11:04:28 +0200 Subject: [PATCH 3/5] Adjust test fixture --- tests/md2html/fixtures/basic-new.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/md2html/fixtures/basic-new.html b/tests/md2html/fixtures/basic-new.html index dbbe203d0a..f9fecd4a12 100644 --- a/tests/md2html/fixtures/basic-new.html +++ b/tests/md2html/fixtures/basic-new.html @@ -10,7 +10,7 @@

Definition of Foo.

Another Heading 2

Text for second section

-

Relative link to example

+

Relative link to example

Relative link to something else

Heading 3

Text for first subsection

From 5a1b24149ca3ec2508aefe40a05dfccb391ea9aa Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sat, 17 Aug 2024 19:33:11 +0200 Subject: [PATCH 4/5] Add vitest config --- vitest.config.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 vitest.config.js diff --git a/vitest.config.js b/vitest.config.js new file mode 100644 index 0000000000..b8c8dfb4c0 --- /dev/null +++ b/vitest.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + forceRerunTriggers: ['**/scripts/**', '**/tests/**'], + }, +}) \ No newline at end of file From 3c2c9c607dcb2c64a19cc9327cf6f3c965b57934 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Tue, 20 Aug 2024 17:59:15 +0200 Subject: [PATCH 5/5] Don't rely on toc-end comment --- scripts/md2html/md2html.js | 2 +- tests/md2html/fixtures/basic-old.html | 1 - tests/md2html/fixtures/basic-old.md | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/md2html/md2html.js b/scripts/md2html/md2html.js index 4cac897395..ef95f67761 100644 --- a/scripts/md2html/md2html.js +++ b/scripts/md2html/md2html.js @@ -190,7 +190,7 @@ for (let l in lines) { // remove TOC from older spec versions, respec will generate a new one if (line.startsWith('## Table of Contents')) inTOC = true; - if (line.startsWith('

Heading 2

Text for first section

Broken anchor

diff --git a/tests/md2html/fixtures/basic-old.md b/tests/md2html/fixtures/basic-old.md index 6ff065e949..22be28ae57 100644 --- a/tests/md2html/fixtures/basic-old.md +++ b/tests/md2html/fixtures/basic-old.md @@ -10,8 +10,6 @@ This is the conformance section Will be removed - - ## Heading 2 Text for first section