Revise enum documentation autogeneration.

This adds a new subclass of EnumType, CommentedEnumType, and removes
any previous changes to EnumType that were done to support the
autodoc framework.

Dummy CommentedEnumType and ID's are constructed in parallel with the
real EnumType ID's during parsing and passed on to the autodoc framework.

This allows the generated documentation to track enum redefs, with
a special case being the "Notice" enum type.
This commit is contained in:
Jon Siwek 2011-03-15 14:51:50 -05:00
parent b1dc5d3a1c
commit f67c0892e5
7 changed files with 107 additions and 56 deletions

View file

@ -480,26 +480,18 @@ public:
// added that aren't likewise explicitly initalized.
void AddName(const string& module_name, const char* name, bro_int_t val, bool is_export);
void AddComment(const string& module_name, const char* name, const char* comment);
// -1 indicates not found.
bro_int_t Lookup(const string& module_name, const char* name);
const char* Lookup(bro_int_t value); // Returns 0 if not found
void DescribeReST(ODesc* d) const;
protected:
DECLARE_SERIAL(EnumType)
void AddNameInternal(const string& module_name, const char* name, bro_int_t val, bool is_export);
virtual void AddNameInternal(const string& module_name, const char* name, bro_int_t val, bool is_export);
typedef std::map< const char*, bro_int_t, ltstr > NameMap;
NameMap names;
// comments are only filled when in "documentation mode"
typedef std::map< const char*, const char*, ltstr > CommentMap;
CommentMap comments;
// The counter is initialized to 0 and incremented on every implicit
// auto-increment name that gets added (thus its > 0 if
// auto-increment is used). Once an explicit value has been
@ -509,6 +501,24 @@ protected:
bro_int_t counter;
};
class CommentedEnumType: public EnumType {
public:
CommentedEnumType() {}
~CommentedEnumType();
void DescribeReST(ODesc* d) const;
void AddComment(const string& module_name, const char* name, const char* comment);
protected:
// This overriden method does not install the given ID name into a
// scope and it also does not do any kind of checking that the provided
// name already exists.
void AddNameInternal(const string& module_name, const char* name, bro_int_t val, bool is_export);
// comments are only filled when in "documentation mode"
typedef std::map< const char*, const char*, ltstr > CommentMap;
CommentMap comments;
};
class VectorType : public BroType {
public:
VectorType(BroType* t);