diff options
Diffstat (limited to 'support/texdoc')
-rw-r--r-- | support/texdoc/NEWS | 6 | ||||
-rw-r--r-- | support/texdoc/doc/texdoc.1 | 4 | ||||
-rw-r--r-- | support/texdoc/doc/texdoc.pdf | bin | 84310 -> 84307 bytes | |||
-rw-r--r-- | support/texdoc/doc/texdoc.tex | 6 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-cli.tlu | 4 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-config.tlu | 8 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-const.tlu | 33 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-score.tlu | 107 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-search.tlu | 56 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib-util.tlu | 40 | ||||
-rw-r--r-- | support/texdoc/script/texdoclib.tlu | 2 | ||||
-rw-r--r-- | support/texdoc/texdoc.cnf | 16 |
12 files changed, 191 insertions, 91 deletions
diff --git a/support/texdoc/NEWS b/support/texdoc/NEWS index c08e6c862d..0c5b6b4e8a 100644 --- a/support/texdoc/NEWS +++ b/support/texdoc/NEWS @@ -2,6 +2,12 @@ NEWS for texdoc =============== (This file public domain.) +Version 3.4 (TeX Live 2022) +=========================== +- Make Data.tlpdb.lua reproducible +- Better locale handling in scoring +- Alias adjustments + Version 3.3.1 ------------- - Support non-ascii username on Windows (patch by A. Kakuto) diff --git a/support/texdoc/doc/texdoc.1 b/support/texdoc/doc/texdoc.1 index 63ee8e31e5..c92bd7ccb2 100644 --- a/support/texdoc/doc/texdoc.1 +++ b/support/texdoc/doc/texdoc.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "TEXDOC" "1" "May 2021" "Texdoc 3.3.1" "Texdoc manual" +.TH "TEXDOC" "1" "March 2022" "Texdoc 3.4" "Texdoc manual" . .SH "NAME" \fBtexdoc\fR \- find & view documentation in TeX Live @@ -156,7 +156,7 @@ Texdoc home page: \fIhttp://tug\.org/texdoc/\fR Source: \fIhttps://github\.com/TeX\-Live/texdoc\fR . .SH "COPYRIGHT" -Copyright 2008\-2021 Manuel Pe\'gourie\'\-Gonnard, Takuto Asakura, the TeX Live Team\. +Copyright 2008\-2022 Manuel Pe\'gourie\'\-Gonnard, Takuto Asakura, the TeX Live Team\. . .br License: GNU GPL version 3 or later \fIhttp://gnu\.org/licenses/gpl\.html\fR\. diff --git a/support/texdoc/doc/texdoc.pdf b/support/texdoc/doc/texdoc.pdf Binary files differindex b5e9b6bcc3..8e6f1ecc7c 100644 --- a/support/texdoc/doc/texdoc.pdf +++ b/support/texdoc/doc/texdoc.pdf diff --git a/support/texdoc/doc/texdoc.tex b/support/texdoc/doc/texdoc.tex index 528eda1898..8346c80193 100644 --- a/support/texdoc/doc/texdoc.tex +++ b/support/texdoc/doc/texdoc.tex @@ -1,6 +1,6 @@ %#!xelatex % Texdoc user manual -% Copyright 2008-2021 Manuel Pégourié-Gonnard and Takuto Asakura +% Copyright 2008-2022 Manuel Pégourié-Gonnard and Takuto Asakura % distributed under the terms of GPL v3 or later \documentclass{texdoc-doc} @@ -8,7 +8,7 @@ \subtitle{Find \& view documentation in \TL} \pkgurl{https://tug.org/texdoc/} \author{Manuel Pégourié-Gonnard\and Takuto Asakura} -\date{v3.3.1\quad \today} +\date{v3.4\quad \today} \begin{document} @@ -731,7 +731,7 @@ Texdoc within a {\TL}-based {\TeX} distribution which does not ship \label{sec:licence} The current version of Texdoc program and its documentation are copyright -2008--2021 Manuel Pégourié-Gonnard, Takuto Asakura, the {\TL} Team. +2008--2022 Manuel Pégourié-Gonnard, Takuto Asakura, the {\TL} Team. They are 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/support/texdoc/script/texdoclib-cli.tlu b/support/texdoc/script/texdoclib-cli.tlu index 95a43b7ddd..5818af7f18 100644 --- a/support/texdoc/script/texdoclib-cli.tlu +++ b/support/texdoc/script/texdoclib-cli.tlu @@ -1,4 +1,4 @@ --- texdoclib-cli.tlu: command line interfaces for texdoc +-- texdoclib-cli.tlu: command-line interfaces for texdoc -- -- The TeX Live Team, GPLv3, see texdoclib.tlu for details @@ -200,7 +200,7 @@ end -------------------------- the main function -------------------------- function M.exec() - -- parsing command line options + -- parsing command-line options local ok, action, cl_config = parse_options() if not ok then diff --git a/support/texdoc/script/texdoclib-config.tlu b/support/texdoc/script/texdoclib-config.tlu index 2fc0c99cdf..3f2dddb34a 100644 --- a/support/texdoc/script/texdoclib-config.tlu +++ b/support/texdoc/script/texdoclib-config.tlu @@ -50,7 +50,7 @@ function M.get_value(key) return config[key] end local function context_to_string(context) if not context then return '(no context)' end if context.src == 'cl' then - return 'from command line option "' .. context.name .. '"' + return 'from command-line option "' .. context.name .. '"' elseif context.src == 'env' then return 'from environment variable "' .. context.name .. '"' elseif context.src == 'loc' then @@ -169,9 +169,9 @@ local function set_config_list(conf, context) end end ------------------------- config from command line ------------------------ +------------------------ config from command-line ------------------------ --- set config from the command line +-- set config from the command-line -- Note: Make sure to set a default value in setup_config_from_defaults() -- if relevant. local function setup_config_from_cl(cl_config) @@ -450,7 +450,7 @@ function M.get_default_viewers() -- Use 'start' to get file associations. -- We need to quote the filenames, but the first quoted argument -- is considered as the title by start, so we provide a dummy title. - -- Also, since the command line parser removes quotes if there + -- Also, since the command-line parser removes quotes if there -- is no space inside, the dummy title must contain spaces. viewer_dvi = 'start "texdoc dvi viewer"', viewer_html = 'start "texdoc html viewer"', diff --git a/support/texdoc/script/texdoclib-const.tlu b/support/texdoc/script/texdoclib-const.tlu index 7da64d394b..d6def02f74 100644 --- a/support/texdoc/script/texdoclib-const.tlu +++ b/support/texdoc/script/texdoclib-const.tlu @@ -22,8 +22,8 @@ end -- progname and version fullname = kpse.find_file('texdoc/texdoclib', 'lua') progname = 'Texdoc' -version = '3.3.1' -release_date = '2021-05-20' +version = '3.4' +release_date = '2022-03-03' -- make sure to update setup_config_from_cl() accordingly -- and set a default value in setup_config_from_defaults() if relevant @@ -64,7 +64,7 @@ Repository: <https://github.com/TeX-Live/texdoc> Please email bugs to <texdoc@tug.org>.]] copyright_msg = [[ -Copyright 2008-2021 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. +Copyright 2008-2022 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it.]] @@ -104,7 +104,7 @@ notfound_msg_ph = 'PKGNAME' -- exit codes exit_ok = 0 -exit_error = 1 -- apparently hard-coded in Lua +exit_error = 1 -- apparently hard-coded in Lua exit_usage = 2 exit_notfound = 3 @@ -129,14 +129,35 @@ known_debugs = { } -- various cache or non-cache files -cache_name = 'texdoc/cache-tlpdb.lua' -- relative to TEXMFVAR +cache_name = 'texdoc/cache-tlpdb.lua' -- relative to TEXMFVAR data_tlpdb_name = 'texdoc/Data.tlpdb.lua' -place_holder = '%%s' -- used for viewer commands +place_holder = '%%s' -- used for viewer commands -- kpse path separator kpse_sep = (os.type == 'windows') and ';' or ':' +-- language codes +-- Note: corrected with `find $TEXMFDIST/doc/ | awk 'match( +-- $0, /(.*)-(\w{2}).pdf/, a){print a[2]}'` +lang_codes = { + cn = 'zh', -- Chinese (alias) + cz = 'cz', -- Chech/Slovak + de = 'de', -- German + ee = 'et', -- Estonian + en = 'en', -- English + es = 'es', -- Spanish + fr = 'fr', -- French + it = 'it', -- Italian + ja = 'ja', -- Japanese + nl = 'nl', -- Dutch + pl = 'pl', -- Polish + ro = 'ro', -- Romanian + ru = 'ru', -- Russian + sr = 'sr', -- Serbian + zh = 'zh', -- Chinese +} + -- END constants -- get our previous environment back diff --git a/support/texdoc/script/texdoclib-score.tlu b/support/texdoc/script/texdoclib-score.tlu index 01c3818e37..5aca28ef73 100644 --- a/support/texdoc/script/texdoclib-score.tlu +++ b/support/texdoc/script/texdoclib-score.tlu @@ -5,6 +5,7 @@ -- dependencies local md5 = require 'md5' local texdoc = { + const = require 'texdoclib-const', util = require 'texdoclib-util', config = require 'texdoclib-config', } @@ -49,6 +50,26 @@ end ---------------------------- score computation ----------------------------- +-- parse filename into <base>, <lang>, <ext> +local function parse(filename) + local base, lang, ext + ext = texdoc.util.get_ext(filename) + if ext ~= nil and ext ~= '' then + base = filename:sub(1, -#ext - 2) + else + base = filename + end + + for lc, _ in pairs(texdoc.const.lang_codes) do + local hyph_lc = '-' .. lc + if base:sub(-#hyph_lc) == hyph_lc then + return base:sub(1, -#hyph_lc - 1), lc, ext + end + end + + return base, lang, ext +end + -- says if pat is a "subword" of str local function is_subword(str, pat) local function is_delim(str, i) @@ -72,8 +93,8 @@ local function has_bad_basename(file) return false end --- compute a heuristic score -10 <= s < 10 -local function heuristic_score(file, pat, dbg_score) +-- compute a pattern score -10 <= s < 10 +local function pattern_score(name, pat, dbg_score) dbg_score('Start heuristic scoring with pattern: ' .. pat) -- score management @@ -84,42 +105,40 @@ local function heuristic_score(file, pat, dbg_score) dbg_score('New heuristic score: %.1f. Reason: %s', s, reason) end end - local slash = not not string.find(pat, '/', 1, true) -- look for exact or subword match - if M.is_exact_locale(file, pat) then - upscore(5, 'exact match with correct locale') - elseif M.is_exact(file, pat) then + if M.is_exact(name, pat) then upscore(4, 'exact match') - elseif is_subword(file, pat) then + elseif is_subword(name, pat) then upscore(1, 'subword match') end -- try derivatives unless pat contains a slash + local slash = not not string.find(pat, '/', 1, true) if not slash then for _, suffix in ipairs(texdoc.config.get_value('suffix_list')) do local deriv = pat .. suffix - if M.is_exact(file, deriv) then + if M.is_exact(name, deriv) then upscore(4.5, 'exact match for derived pattern: ' .. deriv) - elseif is_subword(file, deriv) then + elseif is_subword(name, deriv) then upscore(3.5, 'subword match for derived pattern: ' .. deriv) end end end -- if extension is bad, score becomes an epsilon - local ext = texdoc.config.get_value('ext_list')[M.ext_pos(file)] + local ext = texdoc.config.get_value('ext_list')[M.ext_pos(name)] if ext and texdoc.config.get_value('badext_list_inv')[ext] and score > 0 then upscore(0.1, 'bad extension', true) end -- if basename is bad, score becomes an epsilon - if has_bad_basename(file) and score > 0 then + if has_bad_basename(name) and score > 0 then upscore(0.1, 'bad basename', true) end -- bonus for being in the right directory - if string.find('/' .. file, '/' .. pat .. '/', 1, true) and not slash then + if string.find('/' .. name, '/' .. pat .. '/', 1, true) and not slash then upscore(score + 1.5, 'directory bonus') end @@ -146,12 +165,18 @@ local function set_score(df, original_kw) -- get score from patterns local score = -10 + local is_alias = false for _, pat in ipairs(df.matches) do local s = -10 local p = string.lower(pat.name) if pat.original then -- non-alias - s = df.tree > -1 and heuristic_score(name, p, dbg_score) or 1 + if df.tree > -1 then + s = pattern_score(name, p, dbg_score) + else + s = 1 + end elseif M.is_exact(name, p) then -- alias + is_alias = true local bonus, note = 0, '' if pat.locale then bonus, note = 5, ', (language-based)' @@ -185,6 +210,22 @@ local function set_score(df, original_kw) end end + -- bonus for locale + if not is_alias then + local config_lang = texdoc.config.get_value('lang') + local file_lang = df.lang + + if not file_lang then + _, file_lang, _ = parse(name) + file_lang = texdoc.const.lang_codes[file_lang] + end + + if config_lang == file_lang then + score = score + 1 + dbg_score('Locale match bonus: +1.0') + end + end + -- adjust from keyword-specific tables if df.tree > -1 and spec_adjscore[original_kw] then for pat, val in pairs(spec_adjscore[original_kw]) do @@ -218,33 +259,29 @@ local function set_list_scores(list, original_kw) end end --- says if file is an exact match for pat -function M.is_exact(file, pat) - file = texdoc.util.parse_zip(file) - local slashes = string.gsub(pat, '[^/]+', '[^/]+') - basename = string.match(file, slashes .. '$') - if not basename then return nil end - if basename == pat then return true end - for _, ext in ipairs(texdoc.config.get_value('ext_list')) do - if ext ~= '' and ext ~= '*' and basename == pat .. '.' .. ext then - return true - end +-- says if filename is an exact match for pat +function M.is_exact(filename, pattern) + local f_base, f_lang, f_ext = parse(filename) + local p_base, p_lang, p_ext = parse(pattern) + + -- if the pattern contains lang, check if identical + if p_lang ~= nil and f_lang ~= p_lang then + return false end - return false -end --- says if file is an exact match for pat and the current locale -function M.is_exact_locale(file, pat) - if string.match(pat, '%-%l%l%l?$') then - -- don't match if the pattern appears to include a language code + -- if the pattern contains ext, check if identical + if p_ext ~= nil and p_ext ~= '' and f_ext ~= p_ext then return false end - local lang = texdoc.config.get_value('lang') - if lang then - return M.is_exact(file, pat .. '-' .. lang) - or M.is_exact(file, lang .. '-' .. pat) + + -- finally check the bases + if (f_base == p_base + or (f_base:sub(-#p_base) == p_base + and f_base:sub(-#p_base - 1, -#p_base - 1) == '/')) then + return true + else + return false end - return false end -- compare two docfile's: (see texdoclib-search.tlu for structure) diff --git a/support/texdoc/script/texdoclib-search.tlu b/support/texdoc/script/texdoclib-search.tlu index af04a2a3ee..b560626b43 100644 --- a/support/texdoc/script/texdoclib-search.tlu +++ b/support/texdoc/script/texdoclib-search.tlu @@ -39,22 +39,9 @@ end -- (or known basename according to basename_list) local function check_ext(file) file = file:lower() - -- remove zipext if applicable - file = texdoc.util.parse_zip(file) - -- then do the normal thing - for _, e in ipairs(texdoc.config.get_value('ext_list')) do - if e == '*' then - return true - elseif (e == '') then - if not file:find('.', 1, true) then - return true - end - else - local dot_e = '.' .. e - if file:sub(-#dot_e) == dot_e then - return true - end - end + -- has a known extention? + if texdoc.util.get_ext(file) ~= nil then + return true end -- is the basename good? for _, b in ipairs(texdoc.config.get_value('basename_list')) do @@ -443,6 +430,33 @@ end -- tlpdb means TeX Live Package DataBase and tlp means TeX Live Package +-- return an iterator that ouputs the keys in order +local function opairs(t) + local tkeys = {} + + -- use the counter len to avoid the cost of table.insert and to save the + -- length of tkeys for later use in the iterator + local len = 0 + for k, _ in pairs(t) do + len = len + 1 + tkeys[len] = k + end + + table.sort(tkeys) + + local i = 0 + local function iterator() + i = i + 1 + if i > len then + return nil + else + return tkeys[i], t[tkeys[i]] + end + end + + return iterator +end + -- return true if cache exists and is newer than original, false otherwise local function good_cache(cache, ori) local cache_date = lfs.attributes(cache, 'modification') @@ -556,25 +570,25 @@ print_out_tlpinfo = function(filename) -- s_meta printf('local s_meta = {\n') - for k, v in pairs(s_meta) do + for k, v in opairs(s_meta) do printf(' [%q] = {', k) - for i, j in pairs(v) do printf('[%q] = %q, ', i, j) end + for i, j in opairs(v) do printf('[%q] = %q, ', i, j) end printf('},\n') end printf('}\n') -- tlp_from_runfile printf('local tlp_from_runfile = {\n') - for k, v in pairs(tlp_from_runfile) do + for k, v in opairs(tlp_from_runfile) do printf(' [%q] = {', k) - for f in pairs(v) do printf('[%q]=true,', f) end + for f in opairs(v) do printf('[%q]=true,', f) end printf('},\n') end printf('}\n') -- tlp_doclist printf('local tlp_doclist = {\n') - for k, v in pairs(tlp_doclist) do + for k, v in opairs(tlp_doclist) do printf(' [%q] = {\n', k) for _, f in ipairs(v) do printf(' %q,\n', f) end printf(' },\n') diff --git a/support/texdoc/script/texdoclib-util.tlu b/support/texdoc/script/texdoclib-util.tlu index 81627c823e..db043b150e 100644 --- a/support/texdoc/script/texdoclib-util.tlu +++ b/support/texdoc/script/texdoclib-util.tlu @@ -4,8 +4,8 @@ -- dependencies local texdoc = { - const = require('texdoclib-const'), - config = require('texdoclib-config'), + const = require 'texdoclib-const', + config = require 'texdoclib-config', } -- shortcuts @@ -103,18 +103,42 @@ end end -- end scope of active_debugs --- if file is base .. '.' .. zip with zip in zipext_list, return: base, zip --- otherwise, return: file, nil -function M.parse_zip(file) +-- if filename is base .. '.' .. zip with zip in zipext_list, return: base, zip +-- otherwise, return: filename, nil +function M.parse_zip(filename) local zip for _, zip in ipairs(texdoc.config.get_value('zipext_list')) do local l = #zip + 1 - if string.sub(file, -l, -1) == '.' .. zip then - return string.sub(file, 1, -l - 1), zip + if string.sub(filename, -l, -1) == '.' .. zip then + return string.sub(filename, 1, -l - 1), zip end end + return filename, nil +end - return file, nil +-- take a known extension according to ext_list +function M.get_ext(filename) + filename = M.parse_zip(filename) + + for _, e in ipairs(texdoc.config.get_value('ext_list')) do + if e == '*' then + local dot = filename:find('.', 1, true) + if not dot then + return '' + else + return filename:sub(-dot + 1) + end + elseif (e == '') then + if not filename:find('.', 1, true) then + return '' + end + else + local dot_e = '.' .. e + if filename:sub(-#dot_e) == dot_e then + return dot_e:sub(2) + end + end + end end -- print a usage message diff --git a/support/texdoc/script/texdoclib.tlu b/support/texdoc/script/texdoclib.tlu index f7d4f06055..3c0f66c1d2 100644 --- a/support/texdoc/script/texdoclib.tlu +++ b/support/texdoc/script/texdoclib.tlu @@ -1,7 +1,7 @@ -- texdoclib.tlu: the texdoc library --[[ -Copyright 2008-2021 Manuel Pégourié-Gonnard, Takuto Asakura, the TeX Live Team. +Copyright 2008-2022 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/support/texdoc/texdoc.cnf b/support/texdoc/texdoc.cnf index b5ad9ecbdb..d5e7d7afd1 100644 --- a/support/texdoc/texdoc.cnf +++ b/support/texdoc/texdoc.cnf @@ -84,15 +84,15 @@ # basename_list = readme, 00readme # badbasename_list = readme, 00readme +# Known suffixes for documentation +suffix_list = doc, -doc, _doc, .doc, /doc, manual, /manual, -manual, userguide, /user_guide, -guide, -user, man, -man, notes, -info, ref + ## Fuzzy search # Built-in defaults (for reference): # # fuzzy_level = 3 -# Known suffixes for documentation -suffix_list = doc, -doc, _doc, .doc, /doc, manual, /manual, -manual, userguide, /user_guide, -guide, -user, -man, notes, -info, ref - # Score adjustments # ================= @@ -183,6 +183,7 @@ adjscore(beamer) beamer-tut-pt/tutorialbeamer = +10 adjscore(beamer) beamer-FUBerlin = -3 adjscore(beamer) beamer-tut-pt = -10 adjscore(beamer) presentations = -10 +adjscore(beamerarticle) bsp-beamerarticle = -10 # misc adjscore(context) circuitikz = -10 @@ -384,10 +385,6 @@ alias typearea-de = scrguide # tugboat package and classes alias tugboat = ltubguid -# caption -alias caption = caption-eng -alias caption-dev = caption-eng - # metapost by various names alias metapost = mpman alias(5) metapost = mpgraph @@ -444,11 +441,13 @@ alias cm-super = cm-super/README alias cmsuper = cm-super/README alias(5) cmsuper = cm-super/FAQ alias croatian = babel -alias cweb = cwebman # XXX: is in 'cweb' dir, should win alias cyrillic = cyrillic/README alias dtk = dtk/doc/beispiel.pdf alias einfuehrung = einfuehrung/README # tl should get "readme" tag alias elsarticle = elsdoc +alias feynmp = fmfman +alias flowfram = ffuserguide +alias flowfram-dev = flowfram.pdf alias(0.1) fontinst = fontinstallationguide alias hyperref-dev = hyperref.pdf alias iso = isoman @@ -499,7 +498,6 @@ alias ofs = ofsdoc-e alias akletter = akletter/lettereng alias arydshln = arydshln-man alias cv = curve/curve -alias datenumber-de = datenumber/docgerman alias labels(1) = envlab/elguide alias expressg = expeg alias flcards = flashcards |