Skip to content

Commit a50f493

Browse files
authored
Merge pull request #2255 from wilzbach/changelog-pending-nav-inject
Include pending.dd in the changelog footer generation
2 parents 1c91a78 + 2bd3dc1 commit a50f493

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

ddoc/source/preprocessor.d

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,34 @@ auto genChangelogVersion(string fileName, string fileText)
319319

320320
// inject the changelog footer
321321
auto fileBaseName = fileName.baseName;
322-
auto r = changelogFiles.enumerate.find!(a => a.value.baseName == fileBaseName);
322+
auto r = changelogFiles.chain("pending.dd".only).enumerate.find!(a => a.value.baseName == fileBaseName);
323323
if (r.length != 0)
324324
{
325325
auto el = r.front;
326326
macros ~= "\nCHANGELOG_NAV_INJECT=";
327327
auto versions = changelogFiles.map!(a => a.baseName.until(".dd"));
328+
auto hasPrerelease = versions[$ - 1].canFind("_pre");
328329
// mapping for the first and last page is different
329330
if (el.index == 0)
331+
{
330332
macros ~="\n$(CHANGELOG_NAV_FIRST %s)".format(versions[1]);
331-
else if (el.index == changelogFiles.length - 1 ||
332-
// prerelease pages shouldn't be linked to from the released versions
333-
el.index == changelogFiles.length - 2 && versions[$ - 1].canFind("_pre"))
334-
macros ~="\n$(CHANGELOG_NAV_LAST %s)".format(versions[el.index - 1]);
333+
}
334+
else if (
335+
// latest version + nightlies (pending.dd)
336+
el.index >= versions.length ||
337+
// prerelease pages
338+
el.index == versions.length - 1 && hasPrerelease)
339+
{
340+
macros ~="\n$(CHANGELOG_NAV_LAST %s)".format(versions.retro.find!(v => !v.canFind("_pre", "pending")).front);
341+
}
342+
else if (el.index == versions.length - 1 && !hasPrerelease)
343+
{
344+
macros ~="\n$(CHANGELOG_NAV_LAST %s)".format(versions[$ - 2]);
345+
}
335346
else
347+
{
336348
macros ~="\n$(CHANGELOG_NAV %s, %s)".format(versions[el.index - 1], versions[el.index + 1]);
349+
}
337350
macros ~= "\n_=";
338351
}
339352
fileText ~= macros;

0 commit comments

Comments
 (0)