create helpdb entries for all plugins

even those that have no commands and are not enableable
develop
myk002 2022-07-26 22:22:31 -07:00
parent 671f10e5d8
commit 10f8417cc2
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 8 additions and 31 deletions

@ -3164,21 +3164,6 @@ static int internal_getCommandDescription(lua_State *L)
return 1;
}
static int internal_isPluginEnableable(lua_State *L)
{
auto plugins = Core::getInstance().getPluginManager();
const char *name = luaL_checkstring(L, 1);
auto plugin = plugins->getPluginByName(name);
if (plugin)
lua_pushboolean(L, plugin->can_be_enabled());
else
lua_pushnil(L);
return 1;
}
static int internal_threadid(lua_State *L)
{
std::stringstream ss;
@ -3255,7 +3240,6 @@ static const luaL_Reg dfhack_internal_funcs[] = {
{ "listCommands", internal_listCommands },
{ "getCommandHelp", internal_getCommandHelp },
{ "getCommandDescription", internal_getCommandDescription },
{ "isPluginEnableable", internal_isPluginEnableable },
{ "threadid", internal_threadid },
{ "md5File", internal_md5file },
{ NULL, NULL }

@ -273,13 +273,11 @@ local function update_db(old_db, entry_name, text_entry, help_source, kwargs)
-- already in db (e.g. from a higher-priority script dir); skip
return
end
if not kwargs.text_entry_only then
entrydb[entry_name] = {
entry_types=kwargs.entry_types,
short_help=kwargs.short_help,
text_entry=text_entry
}
end
if entry_name ~= text_entry then
return
end
@ -317,7 +315,7 @@ local function scan_plugins(old_db)
local plugin_names = dfhack.internal.listPlugins()
for _,plugin in ipairs(plugin_names) do
local commands = dfhack.internal.listCommands(plugin)
local includes_plugin, has_commands = false, false
local includes_plugin = false
for _,command in ipairs(commands) do
local kwargs = {entry_types={[ENTRY_TYPES.COMMAND]=true}}
if command == plugin then
@ -329,18 +327,13 @@ local function scan_plugins(old_db)
has_rendered_help(plugin) and
HELP_SOURCES.RENDERED or HELP_SOURCES.PLUGIN,
kwargs)
has_commands = true
end
if includes_plugin then goto continue end
local is_enableable = dfhack.internal.isPluginEnableable(plugin)
if has_commands or is_enableable then
if not includes_plugin then
update_db(old_db, plugin, plugin,
has_rendered_help(plugin) and
HELP_SOURCES.RENDERED or HELP_SOURCES.STUB,
{entry_types={[ENTRY_TYPES.PLUGIN]=true},
text_entry_only=not is_enableable})
{entry_types={[ENTRY_TYPES.PLUGIN]=true}})
end
::continue::
end
end