From 67bbedb4c81f9ddea9c78d2b0a717f7d5cde3140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 26 Jan 2022 17:43:48 +0100 Subject: [PATCH] Allow redefining kernel help_links with ILUA_HELP_LINKS environment variable The ILUA_HELP_LINKS variable can be set in kernel.json file like this: { "argv": [ "python", "-m", "ilua.app", "-c", "{connection_file}", "-i", "rpmlua" ], "display_name": "RPM Lua", "language": "lua", "interrupt_mode": "message", "env": { "ILUA_HELP_LINKS": "[{\"text\": \"Lua in RPM\", \"url\": \"https://rpm-software-management.github.io/rpm/manual/lua.html\"}]" } } The nested json in json syntax is a bit hard to read, but OTOH json works well for serializing a list of dictionaries to an environment variable. Fixes https://github.com/guysv/ilua/issues/15 --- ilua/kernel.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ilua/kernel.py b/ilua/kernel.py index 2dde31f..297aa12 100644 --- a/ilua/kernel.py +++ b/ilua/kernel.py @@ -11,6 +11,7 @@ stuff """ +import json import os import re @@ -57,6 +58,10 @@ class ILuaKernel(KernelBase): "url": "https://www.lua.org/manual/"} ] + # Allow kernel definitions to override the help links + if "ILUA_HELP_LINKS" in os.environ: + help_links = json.loads(os.environ["ILUA_HELP_LINKS"]) + def __init__(self, *args, **kwargs): super(ILuaKernel, self).__init__(*args, **kwargs) self.inspector = Inspector()