Another revision for autodoc tracking of public vs private interfaces

A script's public API wasn't simply definable as identifiers
for which ID::IsGlobal() is true, e.g. an unexported identifier with
SCOPE_MODULE will still pass that test and (incorrectly) be considered
public API.

Also, generated reST now omits empty interface sections.
This commit is contained in:
Jon Siwek 2011-03-24 14:04:30 -05:00
parent 2e88c5100c
commit 2490878656
4 changed files with 31 additions and 12 deletions

View file

@ -112,8 +112,11 @@ void BroDoc::WriteDocFile() const
WriteSectionHeading("Summary", '-');
WriteStringList("%s\n", "%s\n\n", summary);
WriteToDoc(":Imports: ");
WriteStringList(":doc:`%s`, ", ":doc:`%s`\n", imports);
if ( ! imports.empty() )
{
WriteToDoc(":Imports: ");
WriteStringList(":doc:`%s`, ", ":doc:`%s`\n", imports);
}
WriteToDoc("\n");
@ -182,16 +185,23 @@ void BroDoc::WriteBroDocObjList(const std::list<const BroDocObj*>& l,
const char* heading,
char underline) const
{
WriteSectionHeading(heading, underline);
if ( l.empty() ) return;
std::list<const BroDocObj*>::const_iterator it;
for ( it = l.begin(); it != l.end(); ++it )
bool (*f_ptr)(const BroDocObj* o) = 0;
if ( wantPublic )
f_ptr = IsPublicAPI;
else
f_ptr = IsPrivateAPI;
it = std::find_if(l.begin(), l.end(), f_ptr);
if ( it == l.end() ) return;
WriteSectionHeading(heading, underline);
while ( it != l.end() )
{
if ( wantPublic )
if ( (*it)->IsPublicAPI() )
(*it)->WriteReST(reST_file);
else
if ( ! (*it)->IsPublicAPI() )
(*it)->WriteReST(reST_file);
(*it)->WriteReST(reST_file);
it = find_if(++it, l.end(), f_ptr);
}
}