The code is structured into these files:

  utils.mli, utils.ml

    String functions and other small utility functions.  This is
    included directly into virt_top.ml.

  types.mli, types.ml

    Various internally used types and functions operating on those
    types.

  collect.mli, collect.ml

    Stats information is collected in these functions.

  screen.mli, screen.ml

    Various useful functions for drawing to the curses screen.

  redraw.mli, redraw.ml

    Redraw the main display.

  csv_output.mli, csv_output.ml

    Functions which implement --csv mode.

  stream_output.mli, stream_output.ml

    Functions which implement --stream mode.

  top.mli, top.ml

    This is the virt-top program.

    'start_up' handles all start-up stuff, eg. command line arguments,
    connecting to the hypervisor, enabling curses.

    The function 'main_loop' runs the main loop and has sub-functions
    to deal with keypresses, help screens and so on.

  opt_gettext.ml
    A generated file which adds gettext support if ocaml-gettext
    was found at configure time, or else stubs it out.

  opt_xml.ml

    Any code which needs the optional xml-light library goes
    in here.  Mainly for parsing domain XML descriptions to get
    the list of block devices and network interfaces.

    The reason for having it in a separate file is so that we
    don't depend on xml-light.

  opt_csv.ml

    Any code which needs the optional ocaml-csv library goes
    in here.

  opt_calendar.ml

    Any code which needs the optional ocaml-calendar library
    (v2) goes in here.  This implements the --end-time command
    line option.

  main.ml

    This is just a small bit of code to glue the modules together
    Top + Opt_xml? + Opt_csv? + Opt_calendar?

The man-page is generated from the single file:

  virt-top.pod

which generates (using perldoc) the following:

  virt-top.1
  virt-top.txt
