Fix auto-generated reST :doc: references to strip .bro file suffixes.

It's allowed for a script to "@load example.bro", but Sphinx doesn't want
that file extension for the purposes of generating cross-referencing links
to other documentation.
This commit is contained in:
Jon Siwek 2011-03-23 16:59:41 -05:00
parent 037a6906af
commit 8b79971e21
2 changed files with 18 additions and 1 deletions

View file

@ -56,6 +56,22 @@ BroDoc::~BroDoc()
FreeBroDocObjPtrList(redefs); FreeBroDocObjPtrList(redefs);
} }
void BroDoc::AddImport(const std::string& s)
{
size_t ext_pos = s.find_last_of('.');
if ( ext_pos == std::string::npos )
imports.push_back(s);
else
{
if ( s.substr(ext_pos + 1) == "bro" )
imports.push_back(s.substr(0, ext_pos));
else
fprintf(stderr, "Warning: skipped documenting @load of file "
"without .bro extension: %s\n", s.c_str());
}
}
void BroDoc::SetPacketFilter(const std::string& s) void BroDoc::SetPacketFilter(const std::string& s)
{ {
packet_filter = s; packet_filter = s;

View file

@ -52,10 +52,11 @@ public:
/** /**
* Schedules an import (@load) to be documented. * Schedules an import (@load) to be documented.
* If the script being loaded has a .bro suffix, it is internally stripped.
* This should be called whenever the scanner sees an @load. * This should be called whenever the scanner sees an @load.
* @param s The name of the imported script. * @param s The name of the imported script.
*/ */
void AddImport(const std::string& s) { imports.push_back(s); } void AddImport(const std::string& s);
/** /**
* Schedules a namespace (module) to be documented. * Schedules a namespace (module) to be documented.