diff --git a/doc/gitsigns.txt b/doc/gitsigns.txt index bda1a13..ad5aef3 100644 --- a/doc/gitsigns.txt +++ b/doc/gitsigns.txt @@ -1213,4 +1213,3 @@ GitSignsChanged After any event in which Gitsigns can potentially change ------------------------------------------------------------------------------ vim:tw=78:ts=8:ft=help:norl: - diff --git a/gen_help.lua b/gen_help.lua index 1631a91..2aa6d00 100755 --- a/gen_help.lua +++ b/gen_help.lua @@ -7,22 +7,13 @@ local startswith = vim.startswith local config = require('lua.gitsigns.config') ---- @param path string ---- @return string -local function read_file(path) - local f = assert(io.open(path, 'r')) - local t = f:read('*all') - f:close() - return t -end - -- To make sure the output is consistent between runs (to minimise diffs), we -- need to iterate through the schema keys in a deterministic way. To do this we -- do a smple scan over the file the schema is defined in and collect the keys -- in the order they are defined. --- @return string[] local function get_ordered_schema_keys() - local ci = read_file('lua/gitsigns/config.lua'):gmatch('[^\n\r]+') + local ci = io.lines('lua/gitsigns/config.lua') --- @type Iterator[string] for l in ci do if startswith(l, 'M.schema = {') then @@ -356,7 +347,7 @@ end --- @param path string --- @return string local function gen_functions_doc_from_file(path) - local i = read_file(path):gmatch('([^\n]*)\n?') --- @type Iterator[string] + local i = io.lines(path) --- @type Iterator[string] local blocks = {} --- @type string[][] @@ -450,7 +441,7 @@ end --- @return string local function get_setup_from_readme() - local readme = read_file('README.md'):gmatch('([^\n]*)\n?') --- @type Iterator + local readme = io.lines('README.md') --- @type Iterator[string] local res = {} --- @type string[] local function append(line) @@ -493,7 +484,7 @@ local function get_marker_text(marker) end local function main() - local template = read_file('etc/doc_template.txt'):gmatch('([^\n]*)\n?') --- @type Iterator + local template = io.lines('etc/doc_template.txt') --- @type Iterator[string] local out = assert(io.open('doc/gitsigns.txt', 'w'))