From 1b60b5ec94001f18b70dbebf6c232c33209f11b5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 25 Sep 2022 13:45:41 +0200 Subject: fix(gen_vimdoc.py): handle missing luajit --- scripts/lua2dox_filter | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts/lua2dox_filter') diff --git a/scripts/lua2dox_filter b/scripts/lua2dox_filter index 22484a807f..0b9f59b6ac 100755 --- a/scripts/lua2dox_filter +++ b/scripts/lua2dox_filter @@ -36,6 +36,10 @@ test_executable(){ ##! \brief sets the lua interpreter set_lua(){ + if test -z "${EXE}"; then + test_executable '.deps/usr/bin/luajit' + fi + if test -z "${EXE}"; then test_executable 'luajit' fi @@ -73,7 +77,8 @@ do_readlink(){ set_lua if test -z "${EXE}" then - echo "no lua interpreter available" + echo "no lua interpreter found" + exit 1 else BASENAME=`basename "$0"` do_readlink "$0" -- cgit From 3b6c7f9c7f2df493e24990c47a338ef8b46dfe8a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 10 Oct 2022 12:21:40 +0100 Subject: refactor(lua2dox_filter): format --- scripts/lua2dox_filter | 105 ++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 54 deletions(-) (limited to 'scripts/lua2dox_filter') diff --git a/scripts/lua2dox_filter b/scripts/lua2dox_filter index 0b9f59b6ac..e3fa95d0cf 100755 --- a/scripts/lua2dox_filter +++ b/scripts/lua2dox_filter @@ -22,72 +22,69 @@ LANG="" ##! \brief test executable to see if it exists -test_executable(){ - P_EXE="$1" - ######### - WHICH=`which ${P_EXE}` - if test -z "${WHICH}" - then - echo "not found \"${P_EXE}\"" - else - EXE="${P_EXE}" - fi - } +test_executable() { + P_EXE="$1" + ######### + WHICH=$(which "$P_EXE") + if test -z "${WHICH}"; then + echo "not found \"${P_EXE}\"" + else + EXE="${P_EXE}" + fi +} ##! \brief sets the lua interpreter -set_lua(){ - if test -z "${EXE}"; then - test_executable '.deps/usr/bin/luajit' - fi +set_lua() { + if test -z "${EXE}"; then + test_executable '.deps/usr/bin/luajit' + fi - if test -z "${EXE}"; then - test_executable 'luajit' - fi + if test -z "${EXE}"; then + test_executable 'luajit' + fi - if test -z "${EXE}"; then - test_executable 'lua' - fi + if test -z "${EXE}"; then + test_executable 'lua' + fi } ##! \brief makes canonical name of file -##! +##! ##! Note that "readlink -f" doesn't work in MacOSX -##! -do_readlink(){ - pushd . > /dev/null - TARGET_FILE=$1 - - cd `dirname $TARGET_FILE` - TARGET_FILE=`basename $TARGET_FILE` - - # Iterate down a (possible) chain of symlinks - while [ -L "$TARGET_FILE" ] - do - TARGET_FILE=`readlink $TARGET_FILE` - cd `dirname $TARGET_FILE` - TARGET_FILE=`basename $TARGET_FILE` - done - - PHYS_DIR=`pwd -P` - RESULT=$PHYS_DIR - popd > /dev/null - } +##! +do_readlink() { + pushd . > /dev/null + TARGET_FILE=$1 + + cd "$(dirname $TARGET_FILE)" + TARGET_FILE=$(basename "$TARGET_FILE") + + # Iterate down a (possible) chain of symlinks + while [ -L "$TARGET_FILE" ]; do + TARGET_FILE=$(readlink "$TARGET_FILE") + cd $(dirname "$TARGET_FILE") + TARGET_FILE=$(basename "$TARGET_FILE") + done + + PHYS_DIR=$(pwd -P) + RESULT=$PHYS_DIR + popd > /dev/null +} ##main set_lua -if test -z "${EXE}" -then - echo "no lua interpreter found" - exit 1 +if test -z "${EXE}"; then + echo "no lua interpreter found" + exit 1 else - BASENAME=`basename "$0"` - do_readlink "$0" - DIRNAME="${RESULT}" - - LUASCRIPT="${DIRNAME}/lua2dox.lua ${BASENAME}" - #echo "lua[${LUASCRIPT}]" + BASENAME=$(basename "$0") + do_readlink "$0" + DIRNAME="${RESULT}" + + LUASCRIPT="${DIRNAME}/lua2dox.lua ${BASENAME}" + #echo "lua[${LUASCRIPT}]" - ${EXE} ${LUASCRIPT} $@ + ${EXE} ${LUASCRIPT} $@ fi -# + ##eof -- cgit From 7c94bcd2d77e2e54b8836ab8325460a367b79eae Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 20 Sep 2021 19:00:50 -0700 Subject: feat(lua)!: execute Lua with "nvim -l" Problem: Nvim has Lua but the "nvim" CLI can't easily be used to execute Lua scripts, especially scripts that take arguments or produce output. Solution: - support "nvim -l [args...]" for running scripts. closes #15749 - exit without +q - remove lua2dox_filter - remove Doxyfile. This wasn't used anyway, because the doxygen config is inlined in gen_vimdoc.py (`Doxyfile` variable). - use "nvim -l" in docs-gen CI job Examples: $ nvim -l scripts/lua2dox.lua --help Lua2DoX (0.2 20130128) ... $ echo "print(vim.inspect(_G.arg))" | nvim -l - --arg1 --arg2 $ echo 'print(vim.inspect(vim.api.nvim_buf_get_text(1,0,0,-1,-1,{})))' | nvim +"put ='text'" -l - TODO? -e executes Lua code -l loads a module -i enters REPL _after running the other arguments_. --- scripts/lua2dox_filter | 90 -------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100755 scripts/lua2dox_filter (limited to 'scripts/lua2dox_filter') diff --git a/scripts/lua2dox_filter b/scripts/lua2dox_filter deleted file mode 100755 index e3fa95d0cf..0000000000 --- a/scripts/lua2dox_filter +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash - -########################################################################### -# Copyright (C) 2012 by Simon Dales # -# simon@purrsoft.co.uk # -# # -# 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 2 of the License, or # -# (at your option) any later version. # -# # -# 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, write to the # -# Free Software Foundation, Inc., # -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -########################################################################### -LANG="" - -##! \brief test executable to see if it exists -test_executable() { - P_EXE="$1" - ######### - WHICH=$(which "$P_EXE") - if test -z "${WHICH}"; then - echo "not found \"${P_EXE}\"" - else - EXE="${P_EXE}" - fi -} - -##! \brief sets the lua interpreter -set_lua() { - if test -z "${EXE}"; then - test_executable '.deps/usr/bin/luajit' - fi - - if test -z "${EXE}"; then - test_executable 'luajit' - fi - - if test -z "${EXE}"; then - test_executable 'lua' - fi -} - -##! \brief makes canonical name of file -##! -##! Note that "readlink -f" doesn't work in MacOSX -##! -do_readlink() { - pushd . > /dev/null - TARGET_FILE=$1 - - cd "$(dirname $TARGET_FILE)" - TARGET_FILE=$(basename "$TARGET_FILE") - - # Iterate down a (possible) chain of symlinks - while [ -L "$TARGET_FILE" ]; do - TARGET_FILE=$(readlink "$TARGET_FILE") - cd $(dirname "$TARGET_FILE") - TARGET_FILE=$(basename "$TARGET_FILE") - done - - PHYS_DIR=$(pwd -P) - RESULT=$PHYS_DIR - popd > /dev/null -} - -##main -set_lua -if test -z "${EXE}"; then - echo "no lua interpreter found" - exit 1 -else - BASENAME=$(basename "$0") - do_readlink "$0" - DIRNAME="${RESULT}" - - LUASCRIPT="${DIRNAME}/lua2dox.lua ${BASENAME}" - #echo "lua[${LUASCRIPT}]" - - ${EXE} ${LUASCRIPT} $@ -fi - -##eof -- cgit