mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
docs(tui): rename term.txt, nvim_terminal_emulator.txt #30398
Problem: It has long been a convention that references to the builtin terminal UI should mention "tui", not "term", in order to avoid ambiguity vs the builtin `:terminal` feature. The final step was to rename term.txt; let's that step. Solution: - rename term.txt => tui.txt - rename nvim_terminal_emulator.txt => terminal.txt - `gen_help_html.lua`: generate redirects for renamed pages.
This commit is contained in:
parent
22479ce563
commit
44afd07443
@ -27,7 +27,7 @@ Features
|
|||||||
- [API access](https://github.com/neovim/neovim/wiki/Related-projects#api-clients)
|
- [API access](https://github.com/neovim/neovim/wiki/Related-projects#api-clients)
|
||||||
from any language including C/C++, C#, Clojure, D, Elixir, Go, Haskell, Java/Kotlin,
|
from any language including C/C++, C#, Clojure, D, Elixir, Go, Haskell, Java/Kotlin,
|
||||||
JavaScript/Node.js, Julia, Lisp, Lua, Perl, Python, Racket, Ruby, Rust
|
JavaScript/Node.js, Julia, Lisp, Lua, Perl, Python, Racket, Ruby, Rust
|
||||||
- Embedded, scriptable [terminal emulator](https://neovim.io/doc/user/nvim_terminal_emulator.html)
|
- Embedded, scriptable [terminal emulator](https://neovim.io/doc/user/terminal.html)
|
||||||
- Asynchronous [job control](https://github.com/neovim/neovim/pull/2247)
|
- Asynchronous [job control](https://github.com/neovim/neovim/pull/2247)
|
||||||
- [Shared data (shada)](https://github.com/neovim/neovim/pull/2506) among multiple editor instances
|
- [Shared data (shada)](https://github.com/neovim/neovim/pull/2506) among multiple editor instances
|
||||||
- [XDG base directories](https://github.com/neovim/neovim/pull/3470) support
|
- [XDG base directories](https://github.com/neovim/neovim/pull/3470) support
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*terminal_emulator.txt* Nvim
|
*terminal.txt* Nvim
|
||||||
|
|
||||||
|
|
||||||
NVIM REFERENCE MANUAL by Thiago de Arruda
|
NVIM REFERENCE MANUAL by Thiago de Arruda
|
@ -1,4 +1,4 @@
|
|||||||
*term.txt* Nvim
|
*tui.txt* Nvim
|
||||||
|
|
||||||
|
|
||||||
NVIM REFERENCE MANUAL
|
NVIM REFERENCE MANUAL
|
@ -1,6 +1,4 @@
|
|||||||
-- Converts Vim :help files to HTML. Validates |tag| links and document syntax (parser errors).
|
--- Converts Nvim :help files to HTML. Validates |tag| links and document syntax (parser errors).
|
||||||
--
|
|
||||||
-- NOTE: :helptags checks for duplicate tags, whereas this script checks _links_ (to tags).
|
|
||||||
--
|
--
|
||||||
-- USAGE (For CI/local testing purposes): Simply `make lintdoc` or `scripts/lintdoc.lua`, which
|
-- USAGE (For CI/local testing purposes): Simply `make lintdoc` or `scripts/lintdoc.lua`, which
|
||||||
-- basically does the following:
|
-- basically does the following:
|
||||||
@ -23,6 +21,8 @@
|
|||||||
-- 1. nvim -V1 -es +"lua require('scripts.gen_help_html')._test()" +q
|
-- 1. nvim -V1 -es +"lua require('scripts.gen_help_html')._test()" +q
|
||||||
--
|
--
|
||||||
-- NOTES:
|
-- NOTES:
|
||||||
|
-- * This script is used by the automation repo: https://github.com/neovim/doc
|
||||||
|
-- * :helptags checks for duplicate tags, whereas this script checks _links_ (to tags).
|
||||||
-- * gen() and validate() are the primary (programmatic) entrypoints. validate() only exists
|
-- * gen() and validate() are the primary (programmatic) entrypoints. validate() only exists
|
||||||
-- because gen() is too slow (~1 min) to run in per-commit CI.
|
-- because gen() is too slow (~1 min) to run in per-commit CI.
|
||||||
-- * visit_node() is the core function used by gen() to traverse the document tree and produce HTML.
|
-- * visit_node() is the core function used by gen() to traverse the document tree and produce HTML.
|
||||||
@ -80,6 +80,12 @@ local new_layout = {
|
|||||||
['vim_diff.txt'] = true,
|
['vim_diff.txt'] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Map of new:old pages, to redirect renamed pages.
|
||||||
|
local redirects = {
|
||||||
|
['tui'] = 'term',
|
||||||
|
['terminal'] = 'nvim_terminal_emulator',
|
||||||
|
}
|
||||||
|
|
||||||
-- TODO: These known invalid |links| require an update to the relevant docs.
|
-- TODO: These known invalid |links| require an update to the relevant docs.
|
||||||
local exclude_invalid = {
|
local exclude_invalid = {
|
||||||
["'string'"] = 'eval.txt',
|
["'string'"] = 'eval.txt',
|
||||||
@ -212,6 +218,7 @@ local function is_noise(line, noise_lines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a github issue URL at neovim/tree-sitter-vimdoc with prefilled content.
|
--- Creates a github issue URL at neovim/tree-sitter-vimdoc with prefilled content.
|
||||||
|
--- @return string
|
||||||
local function get_bug_url_vimdoc(fname, to_fname, sample_text)
|
local function get_bug_url_vimdoc(fname, to_fname, sample_text)
|
||||||
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
|
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
|
||||||
local bug_url = (
|
local bug_url = (
|
||||||
@ -227,6 +234,7 @@ local function get_bug_url_vimdoc(fname, to_fname, sample_text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a github issue URL at neovim/neovim with prefilled content.
|
--- Creates a github issue URL at neovim/neovim with prefilled content.
|
||||||
|
--- @return string
|
||||||
local function get_bug_url_nvim(fname, to_fname, sample_text, token_name)
|
local function get_bug_url_nvim(fname, to_fname, sample_text, token_name)
|
||||||
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
|
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
|
||||||
local bug_url = (
|
local bug_url = (
|
||||||
@ -255,7 +263,7 @@ local function get_helppage(f)
|
|||||||
return 'index.html'
|
return 'index.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
return (f:gsub('%.txt$', '.html'))
|
return (f:gsub('%.txt$', '')) .. '.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Counts leading spaces (tab=8) to decide the indent size of multiline text.
|
--- Counts leading spaces (tab=8) to decide the indent size of multiline text.
|
||||||
@ -767,14 +775,21 @@ local function ensure_runtimepath()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Opens `fname` in a buffer and gets a treesitter parser for the buffer contents.
|
--- Opens `fname` (or `text`, if given) in a buffer and gets a treesitter parser for the buffer contents.
|
||||||
---
|
---
|
||||||
--- @param fname string help file to parse
|
--- @param fname string :help file to parse
|
||||||
|
--- @param text string? :help file contents
|
||||||
--- @param parser_path string? path to non-default vimdoc.so
|
--- @param parser_path string? path to non-default vimdoc.so
|
||||||
--- @return vim.treesitter.LanguageTree, integer (lang_tree, bufnr)
|
--- @return vim.treesitter.LanguageTree, integer (lang_tree, bufnr)
|
||||||
local function parse_buf(fname, parser_path)
|
local function parse_buf(fname, text, parser_path)
|
||||||
local buf ---@type integer
|
local buf ---@type integer
|
||||||
if type(fname) == 'string' then
|
if text then
|
||||||
|
vim.cmd('split new') -- Text contents.
|
||||||
|
vim.api.nvim_put(vim.split(text, '\n'), '', false, false)
|
||||||
|
vim.cmd('setfiletype help')
|
||||||
|
-- vim.treesitter.language.add('vimdoc')
|
||||||
|
buf = vim.api.nvim_get_current_buf()
|
||||||
|
elseif type(fname) == 'string' then
|
||||||
vim.cmd('split ' .. vim.fn.fnameescape(fname)) -- Filename.
|
vim.cmd('split ' .. vim.fn.fnameescape(fname)) -- Filename.
|
||||||
buf = vim.api.nvim_get_current_buf()
|
buf = vim.api.nvim_get_current_buf()
|
||||||
else
|
else
|
||||||
@ -801,7 +816,7 @@ local function validate_one(fname, parser_path)
|
|||||||
local stats = {
|
local stats = {
|
||||||
parse_errors = {},
|
parse_errors = {},
|
||||||
}
|
}
|
||||||
local lang_tree, buf = parse_buf(fname, parser_path)
|
local lang_tree, buf = parse_buf(fname, nil, parser_path)
|
||||||
for _, tree in ipairs(lang_tree:trees()) do
|
for _, tree in ipairs(lang_tree:trees()) do
|
||||||
visit_validate(tree:root(), 0, tree, { buf = buf, fname = fname }, stats)
|
visit_validate(tree:root(), 0, tree, { buf = buf, fname = fname }, stats)
|
||||||
end
|
end
|
||||||
@ -812,20 +827,21 @@ end
|
|||||||
|
|
||||||
--- Generates HTML from one :help file `fname` and writes the result to `to_fname`.
|
--- Generates HTML from one :help file `fname` and writes the result to `to_fname`.
|
||||||
---
|
---
|
||||||
--- @param fname string Source :help file
|
--- @param fname string Source :help file.
|
||||||
|
--- @param text string|nil Source :help file contents, or nil to read `fname`.
|
||||||
--- @param to_fname string Destination .html file
|
--- @param to_fname string Destination .html file
|
||||||
--- @param old boolean Preformat paragraphs (for old :help files which are full of arbitrary whitespace)
|
--- @param old boolean Preformat paragraphs (for old :help files which are full of arbitrary whitespace)
|
||||||
--- @param parser_path string? path to non-default vimdoc.so
|
--- @param parser_path string? path to non-default vimdoc.so
|
||||||
---
|
---
|
||||||
--- @return string html
|
--- @return string html
|
||||||
--- @return table stats
|
--- @return table stats
|
||||||
local function gen_one(fname, to_fname, old, commit, parser_path)
|
local function gen_one(fname, text, to_fname, old, commit, parser_path)
|
||||||
local stats = {
|
local stats = {
|
||||||
noise_lines = {},
|
noise_lines = {},
|
||||||
parse_errors = {},
|
parse_errors = {},
|
||||||
first_tags = {}, -- Track the first few tags in doc.
|
first_tags = {}, -- Track the first few tags in doc.
|
||||||
}
|
}
|
||||||
local lang_tree, buf = parse_buf(fname, parser_path)
|
local lang_tree, buf = parse_buf(fname, text, parser_path)
|
||||||
---@type nvim.gen_help_html.heading[]
|
---@type nvim.gen_help_html.heading[]
|
||||||
local headings = {} -- Headings (for ToC). 2-dimensional: h1 contains h2/h3.
|
local headings = {} -- Headings (for ToC). 2-dimensional: h1 contains h2/h3.
|
||||||
local title = to_titlecase(basename_noext(fname))
|
local title = to_titlecase(basename_noext(fname))
|
||||||
@ -1302,33 +1318,81 @@ function M.gen(help_dir, to_dir, include, commit, parser_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local err_count = 0
|
local err_count = 0
|
||||||
|
local redirects_count = 0
|
||||||
ensure_runtimepath()
|
ensure_runtimepath()
|
||||||
tagmap = get_helptags(vim.fs.normalize(help_dir))
|
tagmap = get_helptags(vim.fs.normalize(help_dir))
|
||||||
helpfiles = get_helpfiles(help_dir, include)
|
helpfiles = get_helpfiles(help_dir, include)
|
||||||
to_dir = vim.fs.normalize(to_dir)
|
to_dir = vim.fs.normalize(to_dir)
|
||||||
parser_path = parser_path and vim.fs.normalize(parser_path) or nil
|
parser_path = parser_path and vim.fs.normalize(parser_path) or nil
|
||||||
|
|
||||||
print(('output dir: %s'):format(to_dir))
|
print(('output dir: %s\n\n'):format(to_dir))
|
||||||
vim.fn.mkdir(to_dir, 'p')
|
vim.fn.mkdir(to_dir, 'p')
|
||||||
gen_css(('%s/help.css'):format(to_dir))
|
gen_css(('%s/help.css'):format(to_dir))
|
||||||
|
|
||||||
for _, f in ipairs(helpfiles) do
|
for _, f in ipairs(helpfiles) do
|
||||||
|
-- "foo.txt"
|
||||||
local helpfile = vim.fs.basename(f)
|
local helpfile = vim.fs.basename(f)
|
||||||
|
-- "to/dir/foo.html"
|
||||||
local to_fname = ('%s/%s'):format(to_dir, get_helppage(helpfile))
|
local to_fname = ('%s/%s'):format(to_dir, get_helppage(helpfile))
|
||||||
local html, stats = gen_one(f, to_fname, not new_layout[helpfile], commit or '?', parser_path)
|
local html, stats =
|
||||||
|
gen_one(f, nil, to_fname, not new_layout[helpfile], commit or '?', parser_path)
|
||||||
tofile(to_fname, html)
|
tofile(to_fname, html)
|
||||||
print(
|
print(
|
||||||
('generated (%-4s errors): %-15s => %s'):format(
|
('generated (%-2s errors): %-15s => %s'):format(
|
||||||
#stats.parse_errors,
|
#stats.parse_errors,
|
||||||
helpfile,
|
helpfile,
|
||||||
vim.fs.basename(to_fname)
|
vim.fs.basename(to_fname)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- Generate redirect pages for renamed help files.
|
||||||
|
local helpfile_tag = (helpfile:gsub('%.txt$', ''))
|
||||||
|
local redirect_from = redirects[helpfile_tag]
|
||||||
|
if redirect_from then
|
||||||
|
local redirect_text = ([[
|
||||||
|
*%s* Nvim
|
||||||
|
|
||||||
|
This document moved to: |%s|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
This document moved to: |%s|
|
||||||
|
|
||||||
|
This document moved to: |%s|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
vim:tw=78:ts=8:ft=help:norl:
|
||||||
|
]]):format(
|
||||||
|
redirect_from,
|
||||||
|
helpfile_tag,
|
||||||
|
helpfile_tag,
|
||||||
|
helpfile_tag,
|
||||||
|
helpfile_tag,
|
||||||
|
helpfile_tag
|
||||||
|
)
|
||||||
|
local redirect_to = ('%s/%s'):format(to_dir, get_helppage(redirect_from))
|
||||||
|
local redirect_html, _ =
|
||||||
|
gen_one(redirect_from, redirect_text, redirect_to, false, commit or '?', parser_path)
|
||||||
|
assert(redirect_html:find(helpfile_tag))
|
||||||
|
tofile(redirect_to, redirect_html)
|
||||||
|
|
||||||
|
print(
|
||||||
|
('generated (redirect) : %-15s => %s'):format(
|
||||||
|
redirect_from .. '.txt',
|
||||||
|
vim.fs.basename(to_fname)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
redirects_count = redirects_count + 1
|
||||||
|
end
|
||||||
|
|
||||||
err_count = err_count + #stats.parse_errors
|
err_count = err_count + #stats.parse_errors
|
||||||
end
|
end
|
||||||
print(('generated %d html pages'):format(#helpfiles))
|
|
||||||
|
print(('\ngenerated %d html pages'):format(#helpfiles + redirects_count))
|
||||||
print(('total errors: %d'):format(err_count))
|
print(('total errors: %d'):format(err_count))
|
||||||
print(('invalid tags:\n%s'):format(vim.inspect(invalid_links)))
|
print(('invalid tags: %s'):format(vim.inspect(invalid_links)))
|
||||||
|
assert(#(include or {}) > 0 or redirects_count == vim.tbl_count(redirects)) -- sanity check
|
||||||
|
print(('redirects: %d'):format(redirects_count))
|
||||||
|
print('\n')
|
||||||
|
|
||||||
--- @type nvim.gen_help_html.gen_result
|
--- @type nvim.gen_help_html.gen_result
|
||||||
return {
|
return {
|
||||||
|
@ -301,10 +301,6 @@ preprocess_patch() {
|
|||||||
LC_ALL=C sed -Ee 's/( [ab]\/runtime\/doc)\/sponsor\.txt/\1\/intro.txt/g' \
|
LC_ALL=C sed -Ee 's/( [ab]\/runtime\/doc)\/sponsor\.txt/\1\/intro.txt/g' \
|
||||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||||
|
|
||||||
# Rename terminal.txt to nvim_terminal_emulator.txt
|
|
||||||
LC_ALL=C sed -Ee 's/( [ab]\/runtime\/doc)\/terminal\.txt/\1\/nvim_terminal_emulator.txt/g' \
|
|
||||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
|
||||||
|
|
||||||
# Rename test_urls.vim to check_urls.vim
|
# Rename test_urls.vim to check_urls.vim
|
||||||
LC_ALL=C sed -Ee 's/( [ab])\/runtime\/doc\/test(_urls\.vim)/\1\/scripts\/check\2/g' \
|
LC_ALL=C sed -Ee 's/( [ab])\/runtime\/doc\/test(_urls\.vim)/\1\/scripts\/check\2/g' \
|
||||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||||
|
Loading…
Reference in New Issue
Block a user