From b2002199670ce2c2d0f3d55af603ee54190b9d67 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 20 Jul 2020 23:04:23 -0700 Subject: [PATCH 1/3] support for splitting lua scripts into parts without polluting the output of #DFHack ls --- docs/changelog.txt | 1 + library/Core.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 5f3510ed9..c949115f1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -56,6 +56,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Lua - Added a ``ref_target`` field to primitive field references, corresponding to the ``ref-target`` XML attribute +- Support for splitting scripts into multiple files without polluting the output of '#DFHack ls'. Scripts that end in '-internal.lua' will not be listed, but but they can still be 'require'd from other scripts. ## Ruby - Updated ``item_find`` and ``building_find`` to use centralized logic that works on more screens diff --git a/library/Core.cpp b/library/Core.cpp index 20d9c994b..9192d5772 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -301,7 +301,7 @@ static void listScripts(PluginManager *plug_mgr, std::map &pset, path += '/'; for (size_t i = 0; i < files.size(); i++) { - if (hasEnding(files[i], ".lua")) + if (hasEnding(files[i], ".lua") && !hasEnding(files[i], "-internal.lua")) { string help = getScriptHelp(path + files[i], "--"); string key = prefix + files[i].substr(0, files[i].size()-4); From 48d4013bcb8102a683545d3e63797a086bc68f44 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 24 Jul 2020 22:07:16 -0700 Subject: [PATCH 2/3] don't list subdirectories named 'internal' instead of just specifically for lua files with a '-internal.lua' suffix --- docs/changelog.txt | 2 +- library/Core.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 19209ca60..949e8fe56 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -56,7 +56,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Lua - Added a ``ref_target`` field to primitive field references, corresponding to the ``ref-target`` XML attribute -- Support for splitting scripts into multiple files without polluting the output of '#DFHack ls'. Scripts that end in '-internal.lua' will not be listed, but but they can still be 'require'd from other scripts. +- Support for splitting scripts into multiple files without polluting the output of ``#DFHack ls``. Scripts can now add internal files to an ``scripts/internal`` folder. ## Ruby - Updated ``item_find`` and ``building_find`` to use centralized logic that works on more screens diff --git a/library/Core.cpp b/library/Core.cpp index 9192d5772..c6ce9ea48 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -301,7 +301,7 @@ static void listScripts(PluginManager *plug_mgr, std::map &pset, path += '/'; for (size_t i = 0; i < files.size(); i++) { - if (hasEnding(files[i], ".lua") && !hasEnding(files[i], "-internal.lua")) + if (hasEnding(files[i], ".lua")) { string help = getScriptHelp(path + files[i], "--"); string key = prefix + files[i].substr(0, files[i].size()-4); @@ -317,7 +317,7 @@ static void listScripts(PluginManager *plug_mgr, std::map &pset, pset[key] = help; } } - else if (all && !files[i].empty() && files[i][0] != '.') + else if (all && !files[i].empty() && files[i][0] != '.' && files[i] != "internal") { listScripts(plug_mgr, pset, path+files[i]+"/", all, prefix+files[i]+"/"); } From e614e28beb2ae4d2979b4a94fe32ae3b8df79a51 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 24 Jul 2020 23:40:27 -0700 Subject: [PATCH 3/3] exempt scripts under 'internal' from docstring req --- travis/script-docs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/travis/script-docs.py b/travis/script-docs.py index b2c8063bf..a102ae35b 100755 --- a/travis/script-docs.py +++ b/travis/script-docs.py @@ -81,7 +81,9 @@ def check_file(fname): def main(): """Check that all DFHack scripts include documentation""" err = 0 - for root, _, files in os.walk(SCRIPT_PATH): + exclude = set(['internal']) + for root, dirs, files in os.walk(SCRIPT_PATH, topdown=True): + dirs[:] = [d for d in dirs if d not in exclude] for f in files: if f[-3:] in {'.rb', 'lua'}: err += check_file(join(root, f))