Open skycaptain opened 4 years ago
I expected this to be the case although, the issue is the namespacing of Matlab, which is used here. In the end, doctest calls help
on each file. However, when being called on a file its path (src/matlab/+myPackage/getVersion.m
) gets passed to extract_docstring
; when being called on a folder, only the function name (getVersion
) is being passed. When using namespaces help expects the full namespace path, i.e. myPackage.getVersion
. Also, stupid help
does not raise an error when being called on an unknown function; it just returns an empty char array.
Nice sleuthing! As far as I know, no one has thought about how doctest interacts with +namespace
directories.
Namespaces are also now supported on Octave as well so probably there are related or even the same bugs in Octave.
I think doctest +apkg
should test
+apkg/Contents.m
(help apkg
)+apkg/
.+apkg/+subpkg
, perhaps depending on -nonrecursive
flag.+pkg/private
(?)doctest apkg
does not precisely need to be the same as doctest +apkg
: this is like #196 and #197.I'm not sure about what should happen with +apkg/subdir/...
: I don't see anything about that in Matlab's docs. Maybe we should just traverse whatever Matlab gives us from what('+apkg')
and not mess around with dir +apkg
?
I'd be happy to review PRs about this. My rough thoughts:
type = 'package'
detected at the top of doctest_collect
.% Deal with directories
if (strcmp(type, 'dir'))
Calling
doctest
directly on a file works fine:However, when being called on a parent folder
doctest
suddenly does not find the tests:I'm using Matlab and the latest
octave-doctest
from master: