From 2ec8a6a4eb98d0d1852d02653577a46a7574b886 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 10 Mar 2024 20:06:52 +0000 Subject: texdoc (10mar24) git-svn-id: svn://tug.org/texlive/trunk@70559 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/man/man1/texdoc.1 | 2 +- Master/texmf-dist/doc/man/man1/texdoc.man1.pdf | Bin 25459 -> 25530 bytes Master/texmf-dist/doc/support/texdoc/NEWS | 7 ++ Master/texmf-dist/doc/support/texdoc/README.md | 2 +- Master/texmf-dist/doc/support/texdoc/texdoc.pdf | Bin 89528 -> 89531 bytes Master/texmf-dist/doc/support/texdoc/texdoc.tex | 4 +- .../texmf-dist/scripts/texdoc/texdoclib-config.tlu | 2 +- .../texmf-dist/scripts/texdoc/texdoclib-const.tlu | 4 +- .../texmf-dist/scripts/texdoc/texdoclib-score.tlu | 12 +- .../texmf-dist/scripts/texdoc/texdoclib-view.tlu | 138 ++++++++++++--------- Master/texmf-dist/scripts/texdoc/texdoclib.tlu | 2 +- Master/texmf-dist/texdoc/texdoc.cnf | 5 +- 12 files changed, 111 insertions(+), 67 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/man/man1/texdoc.1 b/Master/texmf-dist/doc/man/man1/texdoc.1 index a1fc051ce2b..afebf84286a 100644 --- a/Master/texmf-dist/doc/man/man1/texdoc.1 +++ b/Master/texmf-dist/doc/man/man1/texdoc.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "TEXDOC" "1" "February 2024" "Texdoc 4.0.2" "Texdoc manual" +.TH "TEXDOC" "1" "March 2024" "Texdoc 4.1" "Texdoc manual" . .SH "NAME" \fBtexdoc\fR \- find & view documentation in TeX Live diff --git a/Master/texmf-dist/doc/man/man1/texdoc.man1.pdf b/Master/texmf-dist/doc/man/man1/texdoc.man1.pdf index 96fc6380d6c..3344fabe1e5 100644 Binary files a/Master/texmf-dist/doc/man/man1/texdoc.man1.pdf and b/Master/texmf-dist/doc/man/man1/texdoc.man1.pdf differ diff --git a/Master/texmf-dist/doc/support/texdoc/NEWS b/Master/texmf-dist/doc/support/texdoc/NEWS index 6690f09e0e8..89f7036ae59 100644 --- a/Master/texmf-dist/doc/support/texdoc/NEWS +++ b/Master/texmf-dist/doc/support/texdoc/NEWS @@ -2,6 +2,13 @@ NEWS for Texdoc =============== (This file public domain.) +Version 4.1 (2024-03-10) +======================== +Release for TeX Live 2024. +- CLI update: 10 results (configurable via "max_lines") are displayed even if there are many results +- Some bug fixes and improvements +- Scoring adjustments + Version 4.0.2 (2024-02-02) -------------------------- - Improve the option parser diff --git a/Master/texmf-dist/doc/support/texdoc/README.md b/Master/texmf-dist/doc/support/texdoc/README.md index 57fa31a485e..c52807387be 100644 --- a/Master/texmf-dist/doc/support/texdoc/README.md +++ b/Master/texmf-dist/doc/support/texdoc/README.md @@ -104,7 +104,7 @@ More specific information, such as the TODO list of this project and some inform ## Copyright and License -Copyright 2008-2023 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. +Copyright 2008-2024 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. This package is distributed under the terms of the GNU General Public License as published by the Free Software Foundation, either [version 3](./COPYING) of the License, or (at your option) any later version. diff --git a/Master/texmf-dist/doc/support/texdoc/texdoc.pdf b/Master/texmf-dist/doc/support/texdoc/texdoc.pdf index 619e62907ed..a9459182acc 100644 Binary files a/Master/texmf-dist/doc/support/texdoc/texdoc.pdf and b/Master/texmf-dist/doc/support/texdoc/texdoc.pdf differ diff --git a/Master/texmf-dist/doc/support/texdoc/texdoc.tex b/Master/texmf-dist/doc/support/texdoc/texdoc.tex index 56b5b40b112..ec9e0270bab 100644 --- a/Master/texmf-dist/doc/support/texdoc/texdoc.tex +++ b/Master/texmf-dist/doc/support/texdoc/texdoc.tex @@ -8,7 +8,7 @@ \subtitle{Find \& view documentation in \TL} \pkgurl{https://tug.org/texdoc/} \author{Manuel Pégourié-Gonnard\and Takuto Asakura} -\date{v4.0.2\quad \today} +\date{v4.1\quad \today} \begin{document} @@ -673,7 +673,7 @@ and |all| to activate all of these. Implies |--verbose|. Debug information are printed on standard error. \end{confitem} -\begin{confitem}{max\_lines}{\meta{number}}[default: \code{20}] +\begin{confitem}{max\_lines}{\meta{number}}[default: \code{10}] Set the maximum number of results to be printed without confirmation in list, mixed or showall mode. This setting has no effect if interaction is disabled. \end{confitem} diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu index ad9f852ea70..881a5568051 100755 --- a/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib-config.tlu @@ -592,7 +592,7 @@ local function setup_config_from_defaults() suffix_list = '', verbosity_level = C.def_verbosity, debug_list = '', - max_lines = '20', + max_lines = '10', fuzzy_level = '3', online_url = 'https://texdoc.org/serve/PKGNAME/0', } diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib-const.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib-const.tlu index 1088c25e5e7..5a6b8256d3b 100755 --- a/Master/texmf-dist/scripts/texdoc/texdoclib-const.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib-const.tlu @@ -22,8 +22,8 @@ end -- progname and version fullname = kpse.find_file('texdoc/texdoclib', 'lua') progname = 'Texdoc' -version = '4.0.2' -release_date = '2024-02-02' +version = '4.1' +release_date = '2024-03-10' -- make sure to update setup_config_from_cl() accordingly -- and set a default value in setup_config_from_defaults() if relevant diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib-score.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib-score.tlu index 11befc7ed90..3fcccf8788e 100755 --- a/Master/texmf-dist/scripts/texdoc/texdoclib-score.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib-score.tlu @@ -213,8 +213,15 @@ local function set_score(df, original_kw) -- bonus for locale local config_lang = texdoc.config.get_value('lang') if not is_alias then - local file_lang = df.lang + local file_lang + -- from its catalogue + if df.lang then + -- take first two letters; it may have country codes + file_lang = df.lang:sub(1, 2) + end + + -- from its filename if not file_lang then _, file_lang, _ = parse(name) file_lang = texdoc.const.lang_codes[file_lang] @@ -225,7 +232,8 @@ local function set_score(df, original_kw) dbg_score('Locale match bonus: +1.0') elseif file_lang ~= nil and file_lang ~= 'en' then -- normally, english documents do not have file_lang, - -- but sometimes the catalog includes en info (e.g., geometry) + -- but sometimes catalogue includes en info (e.g., geometry) + -- we want to treat both cases similar score = score - 0.1 dbg_score('Locale unmatch: -0.1') end diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib-view.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib-view.tlu index 3bf6860a35f..15fd5c940b0 100755 --- a/Master/texmf-dist/scripts/texdoc/texdoclib-view.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib-view.tlu @@ -161,76 +161,101 @@ end ----------------------------- display results ----------------------------- +-- length of the list to be shown +local function count_list_length(doclist, showall) + local res = 0 + for _, doc in pairs(doclist) do + if doc:get_quality() == 'good' or + (showall and doc:get_quality() ~= 'killed') then + res = res + 1 + end + end + return res +end + +-- parse user response and view the file +local function view_selected_doc(doclist, num_str, last_i) + -- That returns the empty string on an empty line, nil on EOF. + -- We only want to default to viewing 1 on an empty line. + -- Use Lua's faked ternary operator for fun and brevity: + num = (num_str == '' and 1 or tonumber(num_str)) + if num and doclist[num] and num <= last_i then + view_doc(doclist[num]) + end +end + -- print a list of docfile objects (see texdoclib-search.tlu) as a menu -- if showall is false, stop as soon as a bad result is encountered -local function print_menu(name, doclist, showall) +local function print_doclist(name, doclist, showall) local max_lines = tonumber(texdoc.config.get_value('max_lines')) - if texdoc.config.get_value('interact_switch') and doclist[max_lines + 1] then - -- there may be too many lines, count them - local n = 0 - for _, doc in pairs(doclist) do - if doc:get_quality() == 'good' or - (showall and doc:get_quality() ~= 'killed') then - n = n + 1 - end - end + local interact = texdoc.config.get_value('interact_switch') + + local last_i = 0 + local prompt_more = false + + local len = count_list_length(doclist, showall) + if interact and len > max_lines then + local msg = '%d results. Only the top %d are shown below.' + print(msg:format(len, max_lines)) + prompt_more = true + elseif len == 0 then -- nothing to show + return last_i + end - if n > max_lines then - io.write(n, ' results. Display them all? (y/N) ') - local ans = io.read('*line') - if not ((ans == 'y') or (ans == 'Y') - -- io.read had a bug wrt windows eol on some versions of texlua - or (ans == '\ry') or (ans == '\rY')) then - return + for i, doc in ipairs(doclist) do + if doc:get_quality() == 'killed' then break end + if doc:get_quality() ~= 'good' and not showall then break end + + last_i = i -- save for testing + if texdoc.config.get_value('machine_switch') == true then + -- for machine-readable output, list all results in a certain format + print(name, doc.score, texdoc.util.w32_path(doc.realpath), + doc.lang or '', doc.details or '') + else + print(string.format('%2d %s', i, texdoc.util.w32_path(doc.realpath))) + if doc.details or doc.lang then + local line = ' = ' + if doc.lang then line = line .. '[' .. doc.lang .. '] ' end + if doc.details then line = line .. doc.details end + print(line) end - end - end - local last_i - while true do - for i, doc in ipairs(doclist) do - if doc:get_quality() == 'killed' then break end - if doc:get_quality() ~= 'good' and not showall then break end - - last_i = i -- save for test below - if texdoc.config.get_value('machine_switch') == true then - print(name, doc.score, texdoc.util.w32_path(doc.realpath), - doc.lang or '', doc.details or '') - else - print(string.format('%2d %s', i, texdoc.util.w32_path(doc.realpath))) - if doc.details or doc.lang then - local line = ' = ' - if doc.lang then line = line .. '[' .. doc.lang .. '] ' end - if doc.details then line = line .. doc.details end - print(line) + + if i >= max_lines and prompt_more then + io.write('Enter number of file to view, RET to view 1, S to show all results, ' .. + 'or any other key to exit: ') + local ans = io.read('*line') + if ans == 'S' then + prompt_more = false -- and continue this loop + else + view_selected_doc(doclist, ans, last_i) + return last_i -- which should be always positive end end end + end - if last_i or showall then - break - else - err_print('warning', 'No good result found, showing all results.') - showall = true - end + if interact then + io.write('Enter number of file to view, RET to view 1, anything else to skip: ') + view_selected_doc(doclist, io.read('*line'), last_i) + end + + return last_i +end + +-- wrapper function for print_doclist(): we could call it twice +local function print_list_menu(name, doclist, showall) + local last_i = print_doclist(name, doclist, showall) + + if not showall and last_i == 0 then + err_print('warning', 'No good result found, showing all results.') + last_i = print_doclist(name, doclist, true) end - if not last_i then + if last_i == 0 then local msg = string.gsub(C.notfound_msg, C.notfound_msg_ph, name) io.stderr:write(msg .. '\n') -- get rid of gsub's 2nd value os.exit(C.exit_notfound) end - - if texdoc.config.get_value('interact_switch') then - io.write('Enter number of file to view, RET to view 1, anything else to skip: ') - local num_str = io.read('*line') - -- That returns the empty string on an empty line, nil on EOF. - -- We only want to default to viewing 1 on an empty line. - -- Use Lua's faked ternary operator for fun and brevity: - num = (num_str == '' and 1 or tonumber(num_str)) - if num and doclist[num] and num <= last_i then - view_doc(doclist[num]) - end - end end local function search_online(name, doclist) @@ -296,6 +321,7 @@ function M.deliver_results(name, doclist, many) io.stderr:write(msg .. '\n') -- get rid of gsub's 2nd value os.exit(C.exit_notfound) end + -- shall we show all of them or only the "good" ones? local mode = texdoc.config.get_value('mode') @@ -310,7 +336,7 @@ function M.deliver_results(name, doclist, many) if many and not texdoc.config.get_value('machine_switch') then print('*** Results for: ' .. name .. ' ***') end - print_menu(name, doclist, mode == 'showall') + print_list_menu(name, doclist, mode == 'showall') else search_online(name, doclist) end diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib.tlu index 83c300833e8..d2c7d8996ab 100644 --- a/Master/texmf-dist/scripts/texdoc/texdoclib.tlu +++ b/Master/texmf-dist/scripts/texdoc/texdoclib.tlu @@ -1,7 +1,7 @@ -- texdoclib.tlu: the texdoc library --[[ -Copyright 2008-2023 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. +Copyright 2008-2024 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software diff --git a/Master/texmf-dist/texdoc/texdoc.cnf b/Master/texmf-dist/texdoc/texdoc.cnf index 980cb2dbf63..af409250d27 100644 --- a/Master/texmf-dist/texdoc/texdoc.cnf +++ b/Master/texmf-dist/texdoc/texdoc.cnf @@ -330,6 +330,7 @@ alias fontenc = source2e alias textcomp = source2e alias tracefnt = source2e alias structuredlog = ltfilehook-doc +alias xparse = usrguide # TODO: try to avoid the huge amount of false positives for `doc' itself. # latex-dev instruction @@ -408,8 +409,10 @@ alias(5) mp = mpintro # latex3 and friends alias latex3 = ltx3info -alias(3) expl3 = interface3 +alias expl3 = interface3 alias(3) expl3 = source3 +alias l3 = interface3 +alias(9) l3 = source3 alias l3bootstrap = interface3 alias l3names = interface3 alias l3basics = interface3 -- cgit v1.2.3