Extending NaturalDocs with custom Perl modules does not work
Multi-language source code documentation tool
Brought to you by:
gregvalure
Languages.txt has a comment:
# Perl Package: [perl package]
# Specifies the Perl package used to fine-tune the language behavior in ways
# too complex to do in this file.
I have added following lines to my Languages.txt:
Language: SomeLang
Extension: sl
Perl Package: SomeLang
But NaturalDocs issues an error:
NaturalDocs:.../Languages.txt:132: could not create NaturalDocs::Languages::Test object
Natural Docs encountered the following error and was stopped:
There is an error in .../Languages.txt
Investigation shows that problem is in Languages.pm:
478 elsif ($keyword eq 'perl package')
479 {
480 eval
481 {
482 $language = $value->New($languageName);
483 };
484 if ($::EVAL_ERROR)
485 {
486 NaturalDocs::ConfigFile->AddError('Could not create ' . $value . ' object.', $lineNumber);
487 return;
488 };
489 };
490 };
All the modules shipped with NaturalDocs are "use"d at the top of the file, so $value->New($languageName) works ok. But custom module is not loaded. NaturalDocs should load a module before calling its New method:
478 elsif ($keyword eq 'perl package')
479 {
+++ eval "require $value;" and # NOTE THIS LINE
480 eval
481 {
482 $language = $value->New($languageName);
483 };
484 if ($::EVAL_ERROR)
485 {
486 NaturalDocs::ConfigFile->AddError('Could not create ' . $value . ' object.', $lineNumber);
487 return;
488 };
489 };
490 };
The patch is attached.