mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Teach Desc class how to (optionally) use spaces for indentation.
And (to be consistent with current conventions for reST documentation) update places in the auto-documentation-generation framework where tabs were used in the generated reST.
This commit is contained in:
parent
e491caeeb7
commit
5fbcde7344
5 changed files with 19 additions and 7 deletions
|
@ -90,9 +90,8 @@ void BroDoc::WriteDocFile() const
|
|||
WriteToDoc(":Namespaces: ");
|
||||
WriteStringList("`%s`, ", "`%s`\n", modules);
|
||||
|
||||
WriteToDoc(":Imports:\n");
|
||||
WriteStringList("\t:bro:script: `%s`\n",
|
||||
"\t:bro:script: `%s`\n\n", imports);
|
||||
WriteToDoc(":Imports: ");
|
||||
WriteStringList(":doc:`%s`, ", ":doc:`%s`\n\n", imports);
|
||||
|
||||
WriteSectionHeading("Notices", '-');
|
||||
if ( notices )
|
||||
|
|
|
@ -22,17 +22,18 @@ BroDocObj::~BroDocObj()
|
|||
void BroDocObj::WriteReST(FILE* file) const
|
||||
{
|
||||
ODesc desc;
|
||||
desc.SetIndentSpaces(4);
|
||||
desc.SetQuotes(1);
|
||||
broID->DescribeReST(&desc);
|
||||
fprintf(file, "%s\n", desc.Description());
|
||||
|
||||
if ( HasDocumentation() )
|
||||
{
|
||||
fprintf(file, "\t.. bro:comment::\n");
|
||||
fprintf(file, "\n");
|
||||
std::list<std::string>::const_iterator it;
|
||||
for ( it = reST_doc_strings->begin();
|
||||
it != reST_doc_strings->end(); ++it)
|
||||
fprintf(file, "\t\t%s\n", it->c_str());
|
||||
fprintf(file, " %s\n", it->c_str());
|
||||
}
|
||||
|
||||
fprintf(file, "\n");
|
||||
|
|
10
src/Desc.cc
10
src/Desc.cc
|
@ -41,6 +41,7 @@ ODesc::ODesc(desc_type t, BroFile* arg_f)
|
|||
want_quotes = 0;
|
||||
do_flush = 1;
|
||||
include_stats = 0;
|
||||
indent_with_spaces = 0;
|
||||
}
|
||||
|
||||
ODesc::~ODesc()
|
||||
|
@ -179,8 +180,13 @@ void ODesc::AddBytes(const BroString* s)
|
|||
|
||||
void ODesc::Indent()
|
||||
{
|
||||
for ( int i = 0; i < indent_level; ++i )
|
||||
Add("\t", 0);
|
||||
if ( indent_with_spaces > 0 )
|
||||
for ( int i = 0; i < indent_level; ++i )
|
||||
for ( int j = 0; j < indent_with_spaces; ++j )
|
||||
Add(" ", 0);
|
||||
else
|
||||
for ( int i = 0; i < indent_level; ++i )
|
||||
Add("\t", 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
void PopIndent();
|
||||
int GetIndentLevel() const { return indent_level; }
|
||||
|
||||
int IndentSpaces() const { return indent_with_spaces; }
|
||||
void SetIndentSpaces(int i) { indent_with_spaces = i; }
|
||||
|
||||
void Add(const char* s, int do_indent=1);
|
||||
void AddN(const char* s, int len) { AddBytes(s, len); }
|
||||
void Add(int i);
|
||||
|
@ -135,6 +138,7 @@ protected:
|
|||
int want_quotes;
|
||||
int do_flush;
|
||||
int include_stats;
|
||||
int indent_with_spaces;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -908,6 +908,7 @@ static void check_capture_filter_changes()
|
|||
if ( capture_filters )
|
||||
{
|
||||
ODesc desc;
|
||||
desc.SetIndentSpaces(4);
|
||||
capture_filters->ID_Val()->Describe(&desc);
|
||||
last_reST_doc->SetPacketFilter(desc.Description());
|
||||
capture_filters->ID_Val()->AsTableVal()->RemoveAll();
|
||||
|
@ -937,6 +938,7 @@ static void check_dpd_config_changes()
|
|||
|
||||
int tag = key->AsListVal()->Index(0)->AsCount();
|
||||
ODesc valdesc;
|
||||
valdesc.SetIndentSpaces(4);
|
||||
valdesc.PushIndent();
|
||||
v->Describe(&valdesc);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue