From 2708507e877f3255076bab2f5f074667dd25f8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Sat, 25 Feb 2023 16:35:45 +0100 Subject: [PATCH] docs: use build/bin/nvim instead of nvim in gen_vimdoc (#22398) Problem: `nvim` could point to stable release missing the `nvim -l` functionality. Solution: Require to build nvim first and use `build/bin/nvim` --- scripts/gen_vimdoc.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 8e1d6ef80a..b8c36dc35d 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -42,6 +42,7 @@ import subprocess import collections import msgpack import logging +from pathlib import Path from xml.dom import minidom @@ -55,19 +56,19 @@ if sys.version_info < MIN_PYTHON_VERSION: doxygen_version = tuple((int(i) for i in subprocess.check_output(["doxygen", "-v"], universal_newlines=True).split()[0].split('.'))) -# Until 0.9 is released, need this hacky way to check that "nvim -l foo.lua" works. -nvim_version = list(line for line in subprocess.check_output(['nvim', '-h'], universal_newlines=True).split('\n') - if '-l ' in line) - if doxygen_version < MIN_DOXYGEN_VERSION: print("\nRequires doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) print("Your doxygen version is {}.{}.{}\n".format(*doxygen_version)) sys.exit(1) -if len(nvim_version) == 0: - print("\nRequires 'nvim -l' feature, see https://github.com/neovim/neovim/pull/18706") + +# Need a `nvim` that supports `-l`, so use the local build +nvim = Path(__file__).parent / "../build/bin/nvim" +if not nvim.exists(): + print("\nYou need to build Neovim first to build the documentation.") sys.exit(1) + # DEBUG = ('DEBUG' in os.environ) INCLUDE_C_DECL = ('INCLUDE_C_DECL' in os.environ) INCLUDE_DEPRECATED = ('INCLUDE_DEPRECATED' in os.environ) @@ -1163,7 +1164,7 @@ def main(doxygen_config, args): def filter_source(filename): name, extension = os.path.splitext(filename) if extension == '.lua': - p = subprocess.run(['nvim', '-l', lua2dox, filename], stdout=subprocess.PIPE) + p = subprocess.run([str(nvim), '-l', lua2dox, filename], stdout=subprocess.PIPE) op = ('?' if 0 != p.returncode else p.stdout.decode('utf-8')) print(op) else: