Skip to content

Commit 79a9014

Browse files
committed
feat(gen_help_html.lua): put commit-id in footer
1 parent d4a253e commit 79a9014

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/gen_help_html.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
--
1717
-- NOTES:
1818
-- * gen() and validate() are the primary entrypoints. validate() only exists because gen() is too
19-
-- slow (~1 min) to run in per-commit CI.
19+
-- slow (~1 min) to run in per-commit CI.
2020
-- * visit_node() is the core function used by gen() to traverse the document tree and produce HTML.
2121
-- * visit_validate() is the core function used by validate().
2222
-- * Files in `new_layout` will be generated with a "flow" layout instead of preformatted/fixed-width layout.
@@ -50,7 +50,6 @@ local tagmap = nil
5050
local helpfiles = nil
5151
local invalid_tags = {}
5252

53-
local commit = '?'
5453
local api = vim.api
5554
local M = {}
5655

@@ -477,7 +476,7 @@ end
477476
-- @param old boolean Preformat paragraphs (for old :help files which are full of arbitrary whitespace)
478477
--
479478
-- @returns html, stats
480-
local function gen_one(fname, to_fname, old)
479+
local function gen_one(fname, to_fname, old, commit)
481480
local stats = {
482481
noise_lines = {},
483482
parse_errors = {},
@@ -604,15 +603,15 @@ local function gen_one(fname, to_fname, old)
604603
<footer>
605604
<div class="container flex">
606605
<div class="generator-stats">
607-
Generated on %s from <code>{%s}</code>
606+
Generated at %s from <code><a href="https://github.com/neovim/neovim/commit/%s">%s</a></code>
608607
</div>
609608
<div class="generator-stats">
610609
parse_errors: %d %s | <span title="%s">noise_lines: %d</span>
611610
</div>
612611
<div>
613612
</footer>
614613
]]):format(
615-
os.date('%Y-%m-%d %H:%M:%S'), commit, #stats.parse_errors, bug_link,
614+
os.date('%Y-%m-%d %H:%M'), commit, commit:sub(1, 7), #stats.parse_errors, bug_link,
616615
html_esc(table.concat(stats.noise_lines, '\n')), #stats.noise_lines)
617616

618617
html = ('%s%s%s</div>\n%s</body>\n</html>\n'):format(
@@ -763,11 +762,12 @@ end
763762
--- @param include table|nil Process only these filenames. Example: {'api.txt', 'autocmd.txt', 'channel.txt'}
764763
---
765764
--- @returns info dict
766-
function M.gen(help_dir, to_dir, include)
765+
function M.gen(help_dir, to_dir, include, commit)
767766
vim.validate{
768767
help_dir={help_dir, function(d) return vim.fn.isdirectory(d) == 1 end, 'valid directory'},
769768
to_dir={to_dir, 's'},
770769
include={include, 't', true},
770+
commit={commit, 's', true},
771771
}
772772

773773
local err_count = 0
@@ -781,7 +781,7 @@ function M.gen(help_dir, to_dir, include)
781781
for _, f in ipairs(helpfiles) do
782782
local helpfile = vim.fs.basename(f)
783783
local to_fname = ('%s/%s'):format(to_dir, get_helppage(helpfile))
784-
local html, stats = gen_one(f, to_fname, not new_layout[helpfile])
784+
local html, stats = gen_one(f, to_fname, not new_layout[helpfile], commit or '?')
785785
tofile(to_fname, html)
786786
print(('generated (%-4s errors): %-15s => %s'):format(#stats.parse_errors, helpfile, vim.fs.basename(to_fname)))
787787
err_count = err_count + #stats.parse_errors

0 commit comments

Comments
 (0)