Changes to make generated script docs understand new policy/ hierarchy.

Added an arg to the search_for_files() util function that can return
the subpath of BROPATH's policy/ dir in which the loaded file is found.
This subpath is then used in both the the reST file's document title
(so that script's named e.g. "base.bro" actually have some context) and
in figuring out how to interlink with other generated docs of other
scripts that are found in @load directives.

I still need to overhaul things so the loading of "packages" is
documented in a meaningful way and that the CMake targets are able
to generate indexes for packages.
This commit is contained in:
Jon Siwek 2011-06-30 11:37:15 -05:00
parent f307a3f408
commit fe5f4b8e53
12 changed files with 262 additions and 148 deletions

View file

@ -348,7 +348,7 @@ when return TOK_WHEN;
// All we have to do is pretend we've already scanned it.
const char* full_filename;
FILE* f = search_for_file(new_file, "bro", &full_filename, true);
FILE* f = search_for_file(new_file, "bro", &full_filename, true, 0);
if ( f )
{
@ -537,6 +537,7 @@ static int load_files_with_prefix(const char* orig_file)
const char* prefix = prefixes[i];
const char* full_filename = "<internal error>";
const char* bropath_subpath = "<internal error>";
FILE* f;
if ( streq(orig_file, "-") )
@ -561,7 +562,7 @@ static int load_files_with_prefix(const char* orig_file)
else
strcpy(new_filename, orig_file);
f = search_for_file(new_filename, "bro", &full_filename, true);
f = search_for_file(new_filename, "bro", &full_filename, true, &bropath_subpath);
delete [] new_filename;
}
@ -576,6 +577,7 @@ static int load_files_with_prefix(const char* orig_file)
{
fclose(f);
delete [] full_filename;
delete [] bropath_subpath;
return 0;
}
}
@ -621,10 +623,12 @@ static int load_files_with_prefix(const char* orig_file)
if ( generate_documentation )
{
current_reST_doc = new BroDoc(orig_file, full_filename);
current_reST_doc = new BroDoc(bropath_subpath, full_filename);
docs_generated.push_back(current_reST_doc);
}
delete [] bropath_subpath;
// "orig_file", could be an alias for yytext, which is ephemeral
// and will be zapped after the yy_switch_to_buffer() below.
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));