diff --git a/src/BroDoc.cc b/src/BroDoc.cc index e6b01c3c3a..2aa949e440 100644 --- a/src/BroDoc.cc +++ b/src/BroDoc.cc @@ -152,6 +152,7 @@ void BroDoc::WriteDocFile() const WriteBroDocObjList(redefs, true, "Redefinitions", '~'); WriteSectionHeading("Private Interface", '-'); + WriteBroDocObjList(options, false, "Options", '~'); WriteBroDocObjList(state_vars, false, "State Variables", '~'); WriteBroDocObjList(types, false, "Types", '~'); WriteBroDocObjList(events, false, "Events", '~'); @@ -177,7 +178,7 @@ void BroDoc::WriteStringList(const char* format, } void BroDoc::WriteBroDocObjList(const std::list& l, - bool exportCond, + bool wantPublic, const char* heading, char underline) const { @@ -185,18 +186,12 @@ void BroDoc::WriteBroDocObjList(const std::list& l, std::list::const_iterator it; for ( it = l.begin(); it != l.end(); ++it ) { - if ( exportCond ) - { - // write out only those in an export section + if ( wantPublic ) if ( (*it)->IsPublicAPI() ) (*it)->WriteReST(reST_file); - } else - { - // write out only those that have comments and are not exported - if ( !(*it)->IsPublicAPI() && (*it)->HasDocumentation() ) + if ( ! (*it)->IsPublicAPI() ) (*it)->WriteReST(reST_file); - } } } diff --git a/src/BroDoc.h b/src/BroDoc.h index de950083ea..7cee9faf1a 100644 --- a/src/BroDoc.h +++ b/src/BroDoc.h @@ -198,15 +198,15 @@ protected: /** * Writes out a list of BroDocObj objects to the reST document * @param l A list of BroDocObj pointers - * @param exportCond If true, filter out objects that are not in an - * export section. If false, filter out those that are in - * an export section. + * @param wantPublic If true, filter out objects that are not declared + * in the global scope. If false, filter out those that are in + * the global scope. * @param heading The title of the section to create in the reST doc. * @param underline The character to use to underline the reST * section heading. */ void WriteBroDocObjList(const std::list& l, - bool exportCond, + bool wantPublic, const char* heading, char underline) const; diff --git a/src/BroDocObj.h b/src/BroDocObj.h index e3fd30518b..601d5f148b 100644 --- a/src/BroDocObj.h +++ b/src/BroDocObj.h @@ -37,11 +37,13 @@ public: void WriteReST(FILE* file) const; /** - * Check whether this documentation is part of the public API - * (The declaration was while in an export section). + * Check whether this documentation is part of the public API. In + * 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 */ - bool IsPublicAPI() const { return broID->IsExport(); } + bool IsPublicAPI() const { return broID->IsGlobal(); } /** * Return whether this object has documentation (## comments) diff --git a/src/parse.y b/src/parse.y index 1d2d4f277f..d561fa8e06 100644 --- a/src/parse.y +++ b/src/parse.y @@ -157,13 +157,12 @@ static void add_enum_comment (std::list* comments) cur_enum_type_doc->AddComment(current_module, cur_enum_elem_id, comments); } -static ID* create_dummy_id (const char* name, BroType* type) +static ID* create_dummy_id (const ID* id, BroType* type) { - // normally, install_ID() figures out the right IDScope - // but it doesn't matter for the dummy ID so use SCOPE_GLOBAL - ID* fake_id = new ID(copy_string(name), SCOPE_GLOBAL, is_export); + ID* fake_id = new ID(copy_string(id->Name()), (IDScope) id->Scope(), + is_export); fake_id->SetType(type); - type->SetTypeID(copy_string(name)); + type->SetTypeID(copy_string(id->Name())); fake_id->MakeType(); return fake_id; } @@ -1009,7 +1008,7 @@ decl: do_doc_token_stop(); if ( generate_documentation ) { - ID* fake_id = create_dummy_id($3->Name(), cur_enum_type_doc); + ID* fake_id = create_dummy_id($3, cur_enum_type_doc); cur_enum_type_doc = 0; BroDocObj* o = new BroDocObj(fake_id, reST_doc_comments, true); o->SetRole(true); @@ -1028,7 +1027,7 @@ decl: TypeTag t = $2->AsType()->Tag(); if ( t == TYPE_ENUM && cur_enum_type_doc ) { - ID* fake = create_dummy_id($2->Name(), cur_enum_type_doc); + ID* fake = create_dummy_id($2, cur_enum_type_doc); cur_enum_type_doc = 0; current_reST_doc->AddType( new BroDocObj(fake, reST_doc_comments, true)); @@ -1036,7 +1035,7 @@ decl: else if ( t == TYPE_RECORD && fake_type_decl_list ) { BroType* fake_record = new RecordType(fake_type_decl_list); - ID* fake = create_dummy_id($2->Name(), fake_record); + ID* fake = create_dummy_id($2, fake_record); fake_type_decl_list = 0; current_reST_doc->AddType( new BroDocObj(fake, reST_doc_comments, true));