mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Bro doc mode now tracks record redefs that extend its field list.
This commit is contained in:
parent
aec63df90f
commit
cf0a542f7c
5 changed files with 142 additions and 6 deletions
|
@ -107,6 +107,11 @@ export {
|
||||||
field2: bool; ##< toggles something
|
field2: bool; ##< toggles something
|
||||||
};
|
};
|
||||||
|
|
||||||
|
## document the record extension redef here
|
||||||
|
redef record SimpleRecord += {
|
||||||
|
## document the extending field here
|
||||||
|
field_ext: string &optional; ##< (or here)
|
||||||
|
};
|
||||||
|
|
||||||
## general documentation for a type "ComplexRecord" goes here
|
## general documentation for a type "ComplexRecord" goes here
|
||||||
type ComplexRecord: record {
|
type ComplexRecord: record {
|
||||||
|
|
25
src/parse.y
25
src/parse.y
|
@ -1067,8 +1067,9 @@ decl:
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_REDEF TOK_RECORD global_id TOK_ADD_TO
|
| TOK_REDEF TOK_RECORD global_id TOK_ADD_TO
|
||||||
'{' type_decl_list '}' opt_attr ';'
|
'{' { do_doc_token_start(); } type_decl_list '}' opt_attr ';'
|
||||||
{
|
{
|
||||||
|
do_doc_token_stop();
|
||||||
if ( ! $3->Type() )
|
if ( ! $3->Type() )
|
||||||
$3->Error("unknown identifier");
|
$3->Error("unknown identifier");
|
||||||
else
|
else
|
||||||
|
@ -1078,9 +1079,27 @@ decl:
|
||||||
$3->Error("not a record type");
|
$3->Error("not a record type");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* error = add_to->AddFields($6, $8);
|
const char* error = add_to->AddFields($7, $9);
|
||||||
if ( error )
|
if ( error )
|
||||||
$3->Error(error);
|
$3->Error(error);
|
||||||
|
else if ( generate_documentation )
|
||||||
|
{
|
||||||
|
if ( fake_type_decl_list )
|
||||||
|
{
|
||||||
|
BroType* fake_record =
|
||||||
|
new RecordType(fake_type_decl_list);
|
||||||
|
ID* fake = create_dummy_id($3, fake_record);
|
||||||
|
fake_type_decl_list = 0;
|
||||||
|
current_reST_doc->AddRedef(
|
||||||
|
new BroDocObj(fake, reST_doc_comments, true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Warning: doc mode did not process "
|
||||||
|
"record extension for '%s', CommentedTypeDecl"
|
||||||
|
"list unavailable.\n", $3->Name());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,11 @@ Functions
|
||||||
|
|
||||||
Redefinitions
|
Redefinitions
|
||||||
#############
|
#############
|
||||||
================================================= ====================================
|
===================================================== ========================================
|
||||||
:bro:type:`Example::SimpleEnum`: :bro:type:`enum` document the "SimpleEnum" redef here
|
:bro:type:`Example::SimpleEnum`: :bro:type:`enum` document the "SimpleEnum" redef here
|
||||||
================================================= ====================================
|
|
||||||
|
:bro:type:`Example::SimpleRecord`: :bro:type:`record` document the record extension redef here
|
||||||
|
===================================================== ========================================
|
||||||
|
|
||||||
Namespaces
|
Namespaces
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
@ -227,6 +229,16 @@ Redefinitions
|
||||||
|
|
||||||
document the "SimpleEnum" redef here
|
document the "SimpleEnum" redef here
|
||||||
|
|
||||||
|
.. bro:type:: Example::SimpleRecord
|
||||||
|
|
||||||
|
:Type: :bro:type:`record`
|
||||||
|
|
||||||
|
field_ext: :bro:type:`string` :bro:attr:`&optional`
|
||||||
|
document the extending field here
|
||||||
|
(or here)
|
||||||
|
|
||||||
|
document the record extension redef here
|
||||||
|
|
||||||
Port Analysis
|
Port Analysis
|
||||||
-------------
|
-------------
|
||||||
:ref:`More Information <common_port_analysis_doc>`
|
:ref:`More Information <common_port_analysis_doc>`
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
.. Automatically generated. Do not edit.
|
||||||
|
|
||||||
|
autogen-reST-record-add.bro
|
||||||
|
===========================
|
||||||
|
|
||||||
|
:download:`Original Source File <autogen-reST-record-add.bro>`
|
||||||
|
|
||||||
|
Overview
|
||||||
|
--------
|
||||||
|
|
||||||
|
|
||||||
|
Summary
|
||||||
|
~~~~~~~
|
||||||
|
State Variables
|
||||||
|
###############
|
||||||
|
===================================== =
|
||||||
|
:bro:id:`a`: :bro:type:`my_record`
|
||||||
|
|
||||||
|
:bro:id:`b`: :bro:type:`super_record`
|
||||||
|
===================================== =
|
||||||
|
|
||||||
|
Types
|
||||||
|
#####
|
||||||
|
============================================ =
|
||||||
|
:bro:type:`my_record`: :bro:type:`record`
|
||||||
|
|
||||||
|
:bro:type:`super_record`: :bro:type:`record`
|
||||||
|
============================================ =
|
||||||
|
|
||||||
|
Functions
|
||||||
|
#########
|
||||||
|
===================================== =
|
||||||
|
:bro:id:`test_func`: :bro:type:`func`
|
||||||
|
===================================== =
|
||||||
|
|
||||||
|
Redefinitions
|
||||||
|
#############
|
||||||
|
========================================= =
|
||||||
|
:bro:type:`my_record`: :bro:type:`record`
|
||||||
|
========================================= =
|
||||||
|
|
||||||
|
Public Interface
|
||||||
|
----------------
|
||||||
|
State Variables
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
.. bro:id:: a
|
||||||
|
|
||||||
|
:Type: :bro:type:`my_record`
|
||||||
|
:Default:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
{
|
||||||
|
field1=<uninitialized>
|
||||||
|
field2=<uninitialized>
|
||||||
|
field3=<uninitialized>
|
||||||
|
}
|
||||||
|
|
||||||
|
.. bro:id:: b
|
||||||
|
|
||||||
|
:Type: :bro:type:`super_record`
|
||||||
|
:Default:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
{
|
||||||
|
rec=[field1=<uninitialized>, field2=<uninitialized>, field3=<uninitialized>]
|
||||||
|
}
|
||||||
|
|
||||||
|
Types
|
||||||
|
~~~~~
|
||||||
|
.. bro:type:: my_record
|
||||||
|
|
||||||
|
:Type: :bro:type:`record`
|
||||||
|
|
||||||
|
field1: :bro:type:`bool`
|
||||||
|
|
||||||
|
field2: :bro:type:`string`
|
||||||
|
|
||||||
|
.. bro:type:: super_record
|
||||||
|
|
||||||
|
:Type: :bro:type:`record`
|
||||||
|
|
||||||
|
rec: :bro:type:`my_record`
|
||||||
|
|
||||||
|
Functions
|
||||||
|
~~~~~~~~~
|
||||||
|
.. bro:id:: test_func
|
||||||
|
|
||||||
|
:Type: :bro:type:`function` () : :bro:type:`void`
|
||||||
|
|
||||||
|
Redefinitions
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
.. bro:type:: my_record
|
||||||
|
|
||||||
|
:Type: :bro:type:`record`
|
||||||
|
|
||||||
|
field3: :bro:type:`count` :bro:attr:`&optional`
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# @TEST-EXEC: bro --doc-scripts %INPUT
|
# @TEST-EXEC: bro --doc-scripts %INPUT
|
||||||
|
# @TEST-EXEC: btest-diff autogen-reST-record-add.rst
|
||||||
|
|
||||||
# When in doc mode, bro will clone declared types (see add_type() in Var.cc)
|
# When in doc mode, bro will clone declared types (see add_type() in Var.cc)
|
||||||
# in order to keep track of the identifier name associated with the new type.
|
# in order to keep track of the identifier name associated with the new type.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue