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: ");
|
WriteToDoc(":Namespaces: ");
|
||||||
WriteStringList("`%s`, ", "`%s`\n", modules);
|
WriteStringList("`%s`, ", "`%s`\n", modules);
|
||||||
|
|
||||||
WriteToDoc(":Imports:\n");
|
WriteToDoc(":Imports: ");
|
||||||
WriteStringList("\t:bro:script: `%s`\n",
|
WriteStringList(":doc:`%s`, ", ":doc:`%s`\n\n", imports);
|
||||||
"\t:bro:script: `%s`\n\n", imports);
|
|
||||||
|
|
||||||
WriteSectionHeading("Notices", '-');
|
WriteSectionHeading("Notices", '-');
|
||||||
if ( notices )
|
if ( notices )
|
||||||
|
|
|
@ -22,17 +22,18 @@ BroDocObj::~BroDocObj()
|
||||||
void BroDocObj::WriteReST(FILE* file) const
|
void BroDocObj::WriteReST(FILE* file) const
|
||||||
{
|
{
|
||||||
ODesc desc;
|
ODesc desc;
|
||||||
|
desc.SetIndentSpaces(4);
|
||||||
desc.SetQuotes(1);
|
desc.SetQuotes(1);
|
||||||
broID->DescribeReST(&desc);
|
broID->DescribeReST(&desc);
|
||||||
fprintf(file, "%s\n", desc.Description());
|
fprintf(file, "%s\n", desc.Description());
|
||||||
|
|
||||||
if ( HasDocumentation() )
|
if ( HasDocumentation() )
|
||||||
{
|
{
|
||||||
fprintf(file, "\t.. bro:comment::\n");
|
fprintf(file, "\n");
|
||||||
std::list<std::string>::const_iterator it;
|
std::list<std::string>::const_iterator it;
|
||||||
for ( it = reST_doc_strings->begin();
|
for ( it = reST_doc_strings->begin();
|
||||||
it != reST_doc_strings->end(); ++it)
|
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");
|
fprintf(file, "\n");
|
||||||
|
|
|
@ -41,6 +41,7 @@ ODesc::ODesc(desc_type t, BroFile* arg_f)
|
||||||
want_quotes = 0;
|
want_quotes = 0;
|
||||||
do_flush = 1;
|
do_flush = 1;
|
||||||
include_stats = 0;
|
include_stats = 0;
|
||||||
|
indent_with_spaces = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ODesc::~ODesc()
|
ODesc::~ODesc()
|
||||||
|
@ -179,6 +180,11 @@ void ODesc::AddBytes(const BroString* s)
|
||||||
|
|
||||||
void ODesc::Indent()
|
void ODesc::Indent()
|
||||||
{
|
{
|
||||||
|
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 )
|
for ( int i = 0; i < indent_level; ++i )
|
||||||
Add("\t", 0);
|
Add("\t", 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@ public:
|
||||||
void PopIndent();
|
void PopIndent();
|
||||||
int GetIndentLevel() const { return indent_level; }
|
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 Add(const char* s, int do_indent=1);
|
||||||
void AddN(const char* s, int len) { AddBytes(s, len); }
|
void AddN(const char* s, int len) { AddBytes(s, len); }
|
||||||
void Add(int i);
|
void Add(int i);
|
||||||
|
@ -135,6 +138,7 @@ protected:
|
||||||
int want_quotes;
|
int want_quotes;
|
||||||
int do_flush;
|
int do_flush;
|
||||||
int include_stats;
|
int include_stats;
|
||||||
|
int indent_with_spaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -908,6 +908,7 @@ static void check_capture_filter_changes()
|
||||||
if ( capture_filters )
|
if ( capture_filters )
|
||||||
{
|
{
|
||||||
ODesc desc;
|
ODesc desc;
|
||||||
|
desc.SetIndentSpaces(4);
|
||||||
capture_filters->ID_Val()->Describe(&desc);
|
capture_filters->ID_Val()->Describe(&desc);
|
||||||
last_reST_doc->SetPacketFilter(desc.Description());
|
last_reST_doc->SetPacketFilter(desc.Description());
|
||||||
capture_filters->ID_Val()->AsTableVal()->RemoveAll();
|
capture_filters->ID_Val()->AsTableVal()->RemoveAll();
|
||||||
|
@ -937,6 +938,7 @@ static void check_dpd_config_changes()
|
||||||
|
|
||||||
int tag = key->AsListVal()->Index(0)->AsCount();
|
int tag = key->AsListVal()->Index(0)->AsCount();
|
||||||
ODesc valdesc;
|
ODesc valdesc;
|
||||||
|
valdesc.SetIndentSpaces(4);
|
||||||
valdesc.PushIndent();
|
valdesc.PushIndent();
|
||||||
v->Describe(&valdesc);
|
v->Describe(&valdesc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue