ldoc icon indicating copy to clipboard operation
ldoc copied to clipboard

Multiple modules with submodules do not work

Open juw opened this issue 10 years ago • 0 comments
trafficstars

A one can get a simple testcase for that, by extending the submodule test like this:

diff --git a/tests/submodule/config.ld b/tests/submodule/config.ld
index 598ee06a8c91..42f7ed19e40a 100644
--- a/tests/submodule/config.ld
+++ b/tests/submodule/config.ld
@@ -1,2 +1,2 @@
-file = {'mylib/init.lua','mylib/extra.lua'}
+file = {'mylib/init.lua','mylib/extra.lua', 'mylib2/init.lua','mylib2/extra.lua'}^M
 if foo then print 'foo' end
diff --git a/tests/submodule/mylib2/extra.lua b/tests/submodule/mylib2/extra.lua
new file mode 100644
index 000000000000..cb5d691043ad
--- /dev/null
+++ b/tests/submodule/mylib2/extra.lua
@@ -0,0 +1,13 @@
+-----------
+-- Extra module
+-- @submodule mylib2
+
+--- will appear in mylib2's docs!
+function E ()
+
+end
+
+--- ditto
+function F ()
+
+end
diff --git a/tests/submodule/mylib2/init.lua b/tests/submodule/mylib2/init.lua
new file mode 100644
index 000000000000..8ee196bac8cc
--- /dev/null
+++ b/tests/submodule/mylib2/init.lua
@@ -0,0 +1,35 @@
+-----------
+-- Main module.
+-- This contains four functions, two of which are in
+-- another section implicitly specified using the 'within' tag.
+-- (This allows functions placed together to be classified
+-- separately)
+--
+-- Furthermore, the 'mylib2.extra' functions will be added
+-- as their own section, allowing you to document a logical module
+-- spanning several files
+--
+-- @module mylib2
+
+--- first.
+function A ()
+
+end
+
+--- second, within its own section.
+-- @within Utilities
+function B ()
+
+end
+
+--- third.
+function C ()
+
+end
+
+--- fourth, together with second.
+-- @within Utilities
+function D ()
+
+end
+

If one then runs the test, one gets:

reading configuration from config.ld
module(...) name deduction failed: base /usr/local/src/lua-ldoc/tests/submodule/mylib/ /usr/local/src/lua-ldoc/tests/submodule/mylib2/extra.lua

A simple but quite ugly fix, that may or may not break other things would be

diff --git a/ldoc.lua b/ldoc.lua
index e32472c1074e..9ad6d5c4d635
--- a/ldoc.lua
+++ b/ldoc.lua
@@ -402,6 +402,8 @@ local function process_file (f, flist)
    local ftype = file_types[ext]
    if ftype then
       if args.verbose then print(f) end
+      -- FIXME: dirty hack, so that multiple modules with submodules work
+      args.package = path.splitpath(f)
       ftype.extra = ldoc.parse_extra or {}
       local F,err = parse.file(f,ftype,args)
       if err then

Do you have a better suggestion on how to fix the problem?

Cheers.

juw avatar Dec 28 '14 23:12 juw