summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texdoc/texdoc.tlu
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf/scripts/texdoc/texdoc.tlu')
-rwxr-xr-xMaster/texmf/scripts/texdoc/texdoc.tlu95
1 files changed, 3 insertions, 92 deletions
diff --git a/Master/texmf/scripts/texdoc/texdoc.tlu b/Master/texmf/scripts/texdoc/texdoc.tlu
index 875450ff8ff..919e381ec33 100755
--- a/Master/texmf/scripts/texdoc/texdoc.tlu
+++ b/Master/texmf/scripts/texdoc/texdoc.tlu
@@ -1,96 +1,7 @@
#!/usr/bin/env texlua
---[[
-Copyright 2008, 2009 Manuel Pégourié-Gonnard.
-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
-Foundation, either version 3 of the License, or (at your option) any later
-version.
+-- texdoc.tlu: small wrapper around main.tlu
+-- (makes it easier to install a new version of texdoc in TEXMFHOME)
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program. If not, see <http://www.gnu.org/licenses/>.
-
-Previous work in the public domain:
-- Contributions from Reinhard Kotucha (2008).
-- First texlua versions by Frank Küster (2007).
-- Original shell script by Thomas Esser, David Aspinall, and Simon Wilkinson.
---]]
-
----------------------- functions handling submodules -----------------------
-
--- texdoc is divided in submodules (files).
--- Most submodules use a private environment: that is, the functions and
--- variables defined in a file won't be globally visible, unless explicitly
--- exported at the end of the file.
--- Also, symbols from the global environment (hence from other submodules)
--- aren't imported in the local environment, except if explicitly requested and
--- a few default symbols.
-
--- load a local environment, importing symbols from (this function's) _G
--- usage: local L = {} load_env(L, {'a', 'b'})
-function load_env(l, symbols)
- local default = {
- 'export_symbols',
- 'string', 'table', 'pairs', 'ipairs', 'tonumber', 'tostring', 'next',
- 'assert', 'error', 'err_print', 'deb_print',
- 'C',
- }
- for _, symb in ipairs(default) do
- l[symb] = _G[symb]
- end
- local _, symb
- for _, symb in ipairs(symbols) do
- assert(_G[symb] ~= nil,
- 'Internal error: trying to import undefined symbol '..symb..'.')
- l[symb] = _G[symb]
- end
- setfenv(2, l)
-end
-
--- export symbols from a local environment to (this fonction's) _G
-function export_symbols(l, symbols)
- local _, symb
- for _, symb in ipairs(symbols) do
- assert(l[symb] ~= nil,
- 'Internal error: trying to export undefined symbol '..symb..'.')
- assert(_G[symb] == nil,
- 'Internal error: trying to export existing symbol '..symb..'.')
- _G[symb] = l[symb]
- end
-end
-
--- execute a submodule of texdoc
-function texdoc_do(name)
- local f = kpse.find_file(name..'.tlu', 'texmfscripts')
- assert(f, 'Internal error: unable to find texdoc module '..name..'.')
- dofile(f)
-end
-
------------------------- initilisation & main code -------------------------
-
--- initialize kpathsea
kpse.set_program_name(arg[-1], 'texdoc')
-
--- declare global variables;
--- they will be made read-only as soon as they are set
-C = {} -- constants
-config = {} -- configuration settings
-
--- actually load the submodules now
-texdoc_do('constants')
-texdoc_do('functions')
-texdoc_do('alias')
-texdoc_do('score')
-texdoc_do('config')
-texdoc_do('search')
-texdoc_do('view')
-
--- execute main()
-texdoc_do('main')
-
--- the end
-os.exit(C.exit_ok)
+require('texdoc.main')