# this macro generates 2 files for a given module ${_name}
# ${_name}.dox file which contains the actual doxygen documentation
# ${_name}.dot file which defines the local dependency as graph
# which will be then processed by dot

macro( itk_module_doxygen _name )

  # _content defines the content of the ${_name}.dox file
  set( _content "/**\n" )
  set( _content "${_content} \\defgroup ${_name} ${_name} \n" )
  set( _content "${_content} ${ITK_MODULE_${_name}_DESCRIPTION} \n" )

  set( _content "${_content} \\par Dependencies:\n" )

  # _dotcontent defines the content of the ${_name}.dot
  set( _dotcontent "graph \"${_name}\" { \n")

  foreach( d ${ITK_MODULE_${_name}_DEPENDS} )
    set( _content "${_content} \\li \\ref ${d} \n" )
    set( _dotcontent "${_dotcontent} \"${_name}\" -- \"${d}\"; \n" )
  endforeach()

  # add the image that will be generated by dot based on the defined graph
  # here
  set( _content "${_content} \\image html ${_name}_dependencies.png \n" )
  set( _content "${_content} */\n" )
  set( _dotcontent "${_dotcontent} }")

  configure_file(
    "${ITK_SOURCE_DIR}/Utilities/Doxygen/Module.dot.in"
    "${ITK_BINARY_DIR}/Utilities/Doxygen/Modules/${_name}.dot"
    @ONLY
    )

  configure_file(
    "${ITK_SOURCE_DIR}/Utilities/Doxygen/Module.dox.in"
    "${ITK_BINARY_DIR}/Utilities/Doxygen/Modules/${_name}.dox"
    @ONLY
    )

endmacro()
