Changes to Broxygen master script package index

- Now only lists packages as those directories in the script hierarchy
  that contain an __load__.bro file.
- Script packages (dirs with a __load__.bro file), can now include a
  README (in reST format) that will automatically be appended under
  the link to a specific package in the master package index.
This commit is contained in:
Jon Siwek 2011-12-02 13:59:33 -06:00
parent 14c1d2ae1f
commit a43ed633a4
3 changed files with 16 additions and 14 deletions

View file

@ -49,6 +49,7 @@ with open(group_list, 'r') as f_group_list:
if not os.path.exists(os.path.dirname(group_file)): if not os.path.exists(os.path.dirname(group_file)):
os.makedirs(os.path.dirname(group_file)) os.makedirs(os.path.dirname(group_file))
with open(group_file, 'w') as f_group_file: with open(group_file, 'w') as f_group_file:
f_group_file.write(":orphan:\n\n")
title = "Package Index: %s\n" % os.path.dirname(group) title = "Package Index: %s\n" % os.path.dirname(group)
f_group_file.write(title); f_group_file.write(title);
for n in range(len(title)): for n in range(len(title)):

View file

@ -73,12 +73,14 @@ macro(REST_TARGET srcDir broInput)
elseif (${extension} STREQUAL ".bif.bro") elseif (${extension} STREQUAL ".bif.bro")
set(group bifs) set(group bifs)
elseif (relDstDir) elseif (relDstDir)
set(pkgIndex ${relDstDir}/index) set(group ${relDstDir}/index)
set(group ${pkgIndex})
# add package index to master package list if not already in it # add package index to master package list if not already in it
list(FIND MASTER_PKG_LIST ${pkgIndex} _found) # and if a __load__.bro exists in the original script directory
list(FIND MASTER_PKG_LIST ${relDstDir} _found)
if (_found EQUAL -1) if (_found EQUAL -1)
list(APPEND MASTER_PKG_LIST ${pkgIndex}) if (EXISTS ${CMAKE_SOURCE_DIR}/scripts/${relDstDir}/__load__.bro)
list(APPEND MASTER_PKG_LIST ${relDstDir})
endif ()
endif () endif ()
else () else ()
set(group "") set(group "")
@ -137,11 +139,15 @@ file(WRITE ${MASTER_POLICY_INDEX} "${MASTER_POLICY_INDEX_TEXT}")
# policy/packages.rst file # policy/packages.rst file
set(MASTER_PKG_INDEX_TEXT "") set(MASTER_PKG_INDEX_TEXT "")
foreach (pkg ${MASTER_PKG_LIST}) foreach (pkg ${MASTER_PKG_LIST})
# strip of the trailing /index for the link name set(MASTER_PKG_INDEX_TEXT
get_filename_component(lnktxt ${pkg} PATH) "${MASTER_PKG_INDEX_TEXT}\n:doc:`${pkg} <${pkg}/index>`\n")
# pretty-up the link name by removing common scripts/ prefix if (EXISTS ${CMAKE_SOURCE_DIR}/scripts/${pkg}/README)
string(REPLACE "scripts/" "" lnktxt "${lnktxt}") file(STRINGS ${CMAKE_SOURCE_DIR}/scripts/${pkg}/README pkgreadme)
set(MASTER_PKG_INDEX_TEXT "${MASTER_PKG_INDEX_TEXT}\n ${lnktxt} <${pkg}>") foreach (line ${pkgreadme})
set(MASTER_PKG_INDEX_TEXT "${MASTER_PKG_INDEX_TEXT}\n ${line}")
endforeach ()
set(MASTER_PKG_INDEX_TEXT "${MASTER_PKG_INDEX_TEXT}\n")
endif ()
endforeach () endforeach ()
file(WRITE ${MASTER_PACKAGE_INDEX} "${MASTER_PKG_INDEX_TEXT}") file(WRITE ${MASTER_PACKAGE_INDEX} "${MASTER_PKG_INDEX_TEXT}")

View file

@ -10,8 +10,3 @@ script, it supports being loaded in mass as a whole directory for convenience.
Packages/scripts in the ``base/`` directory are all loaded by default, while Packages/scripts in the ``base/`` directory are all loaded by default, while
ones in ``policy/`` provide functionality and customization options that are ones in ``policy/`` provide functionality and customization options that are
more appropriate for users to decide whether they'd like to load it or not. more appropriate for users to decide whether they'd like to load it or not.
.. toctree::
:maxdepth: 1