Skip to content

Commit b6e6203

Browse files
committed
Generate changelog navigation footer
1 parent 2a67f28 commit b6e6203

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ddoc/source/preprocessor.d

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,26 @@ auto genChangelogVersion(string fileName, string fileText)
317317
auto ver = file.name.baseName.stripExtension.until("_pre");
318318
macros ~= "$(CHANGELOG_VERSION%s %s, %s)\n".format(file.name.endsWith("_pre.dd") ? "_PRE" : "", ver, date);
319319
}
320+
321+
// inject the changelog footer
322+
auto fileBaseName = fileName.baseName;
323+
auto r = changelogFiles.enumerate.find!(a => a.value.baseName == fileBaseName);
324+
if (r.length != 0)
325+
{
326+
auto el = r.front;
327+
macros ~= "\nCHANGELOG_NAV_INJECT=";
328+
auto versions = changelogFiles.map!(a => a.baseName.until(".dd"));
329+
// mapping for the first and last page is different
330+
if (el.index == 0)
331+
macros ~="\n$(CHANGELOG_NAV_FIRST %s)".format(versions[1]);
332+
else if (el.index == changelogFiles.length - 1 ||
333+
// prerelease pages shouldn't be linked to from the released versions
334+
el.index == changelogFiles.length - 2 && versions[$ - 1].canFind("_pre"))
335+
macros ~="\n$(CHANGELOG_NAV_LAST %s)".format(versions[el.index - 1]);
336+
else
337+
macros ~="\n$(CHANGELOG_NAV %s, %s)".format(versions[el.index - 1], versions[el.index + 1]);
338+
macros ~= "\n_=";
339+
}
320340
fileText ~= macros;
321341
}
322342
return fileText;
@@ -438,4 +458,4 @@ string fixDdocBugs(string inputFile, string text)
438458
text = text.replace(`typeof(new E(__FILE__, __LINE__)`, `typeof(new E(string.init, size_t.init)`);
439459
}
440460
return text;
441-
}
461+
}

0 commit comments

Comments
 (0)