mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
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:
parent
2e88c5100c
commit
2490878656
4 changed files with 31 additions and 12 deletions
|
@ -112,8 +112,11 @@ void BroDoc::WriteDocFile() const
|
|||
WriteSectionHeading("Summary", '-');
|
||||
WriteStringList("%s\n", "%s\n\n", summary);
|
||||
|
||||
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 )
|
||||
if ( (*it)->IsPublicAPI() )
|
||||
(*it)->WriteReST(reST_file);
|
||||
f_ptr = IsPublicAPI;
|
||||
else
|
||||
if ( ! (*it)->IsPublicAPI() )
|
||||
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() )
|
||||
{
|
||||
(*it)->WriteReST(reST_file);
|
||||
it = find_if(++it, l.end(), f_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,6 +242,9 @@ private:
|
|||
* @param a reference to a list of BroDocObj pointers
|
||||
*/
|
||||
void FreeBroDocObjPtrList(std::list<const BroDocObj*>& l);
|
||||
|
||||
static bool IsPublicAPI(const BroDocObj* o) { return o->IsPublicAPI(); }
|
||||
static bool IsPrivateAPI(const BroDocObj* o) { return ! o->IsPublicAPI(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,3 +44,9 @@ void BroDocObj::WriteReST(FILE* file) const
|
|||
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
|
||||
bool BroDocObj::IsPublicAPI() const
|
||||
{
|
||||
return (broID->Scope() == SCOPE_GLOBAL) ||
|
||||
(broID->Scope() == SCOPE_MODULE && broID->IsExport());
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
* other words, this means that the identifier is declared as part of
|
||||
* the global scope (has GLOBAL namespace or is exported from another
|
||||
* namespace).
|
||||
* @return true if the ID was declared in an export section, else false
|
||||
* @return true if the identifier is part of the script's public API
|
||||
*/
|
||||
bool IsPublicAPI() const { return broID->IsGlobal(); }
|
||||
bool IsPublicAPI() const;
|
||||
|
||||
/**
|
||||
* Return whether this object has documentation (## comments)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue