From 7bf7496557d939331193069f56c3faa91d81d9d3 Mon Sep 17 00:00:00 2001
From: Daniel Belmes <3631206+DanielBelmes@users.noreply.github.com>
Date: Sat, 5 Aug 2023 11:50:47 -0700
Subject: fix server caching issue causing Theme failures (#22378)
* fix server caching issue causing Theme failures
* Fix tester to ignore version cache param
* fix case of people using -d:nimTestsNimdocFixup
* rsttester needed the same fix
---
compiler/docgen.nim | 4 ++--
config/nimdoc.cfg | 4 ++--
nimdoc/rsttester.nim | 6 ++++--
nimdoc/tester.nim | 6 ++++--
4 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 5120b5223..b25a82e4c 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -1723,7 +1723,7 @@ proc genOutFile(d: PDoc, groupedToc = false): string =
"moduledesc", d.modDescFinal, "date", getDateStr(), "time", getClockStr(),
"content", content, "author", d.meta[metaAuthor],
"version", esc(d.target, d.meta[metaVersion]), "analytics", d.analytics,
- "deprecationMsg", d.modDeprecationMsg]
+ "deprecationMsg", d.modDeprecationMsg, "nimVersion", $NimMajor & "." & $NimMinor & "." & $NimPatch]
else:
code = content
result = code
@@ -1907,7 +1907,7 @@ proc commandBuildIndex*(conf: ConfigRef, dir: string, outFile = RelativeFile"")
"title", "Index",
"subtitle", "", "tableofcontents", "", "moduledesc", "",
"date", getDateStr(), "time", getClockStr(),
- "content", content, "author", "", "version", "", "analytics", ""]
+ "content", content, "author", "", "version", "", "analytics", "", "nimVersion", $NimMajor & "." & $NimMinor & "." & $NimPatch]
# no analytics because context is not available
try:
diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg
index abe039738..9f36e7d1c 100644
--- a/config/nimdoc.cfg
+++ b/config/nimdoc.cfg
@@ -237,10 +237,10 @@ doc.file = """
-
+
-
+
diff --git a/nimdoc/rsttester.nim b/nimdoc/rsttester.nim
index a0bdfca1e..be2b56c67 100644
--- a/nimdoc/rsttester.nim
+++ b/nimdoc/rsttester.nim
@@ -24,11 +24,13 @@ proc testRst2Html(fixup = false) =
let sourceFile = expectedHtml.replace('\\', '/').replace("/expected/", "/source/").replace(".html", ".rst")
exec("$1 rst2html $2" % [nimExe, sourceFile])
let producedHtml = expectedHtml.replace('\\', '/').replace("/expected/", "/source/htmldocs/")
- if readFile(expectedHtml) != readFile(producedHtml):
+ let versionCacheParam = "?v=" & $NimMajor & "." & $NimMinor & "." & $NimPatch
+ let producedFile = readFile(producedHtml).replace(versionCacheParam,"") #remove version cache param used for cache invalidation
+ if readFile(expectedHtml) != producedFile:
echo diffFiles(expectedHtml, producedHtml).output
inc failures
if fixup:
- copyFile(producedHtml, expectedHtml)
+ writeFile(expectedHtml, producedFile)
else:
echo "SUCCESS: files identical: ", producedHtml
if failures == 0:
diff --git a/nimdoc/tester.nim b/nimdoc/tester.nim
index e94caae7c..0c0be3699 100644
--- a/nimdoc/tester.nim
+++ b/nimdoc/tester.nim
@@ -59,16 +59,18 @@ proc testNimDoc(prjDir, docsDir: string; switches: NimSwitches; fixup = false) =
echo("$1 buildIndex $2" % [nimExe, nimBuildIndexSwitches])
for expected in walkDirRec(prjDir / "expected/", checkDir=true):
+ let versionCacheParam = "?v=" & $NimMajor & "." & $NimMinor & "." & $NimPatch
let produced = expected.replace('\\', '/').replace("/expected/", "/$1/" % [docsDir])
if not fileExists(produced):
echo "FAILURE: files not found: ", produced
inc failures
- elif readFile(expected) != readFile(produced):
+ let producedFile = readFile(produced).replace(versionCacheParam,"") #remove version cache param used for cache invalidation
+ if readFile(expected) != producedFile:
echo "FAILURE: files differ: ", produced
echo diffFiles(expected, produced).output
inc failures
if fixup:
- copyFile(produced, expected)
+ writeFile(expected, producedFile)
else:
echo "SUCCESS: files identical: ", produced
--
cgit 1.4.1-2-gfad0