Understanding theme hooks and template preprocessors In hook_theme for the poll module in drupal 7 the following is defined:

function poll_theme() {
  $theme_hooks = array(
    'poll_vote' =&gt; array(
      'template' =&gt; 'poll-vote',
      'render element' =&gt; 'form',
    ),
    'poll_choices' =&gt; array(
      'render element' =&gt; 'form',
    ),
    'poll_results' =&gt; array(
      'template' =&gt; 'poll-results',
      'variables' =&gt; array('raw_title' =&gt; NULL, 'results' =&gt; NULL, 'votes' =&gt; NULL, 'raw_links' =&gt; NULL, 'block' =&gt; NULL, 'nid' =&gt; NULL, 'vote' =&gt; NULL),
    ),
    'poll_bar' =&gt; array(
      'template' =&gt; 'poll-bar',
      'variables' =&gt; array('title' =&gt; NULL, 'votes' =&gt; NULL, 'total_votes' =&gt; NULL, 'vote' =&gt; NULL, 'block' =&gt; NULL),
    ),
  );
  // The theme system automatically discovers the theme's functions and
  // templates that implement more targeted "suggestions" of generic theme
  // hooks. But suggestions implemented by a module must be explicitly
  // registered.
  $theme_hooks += array(
    'poll_results__block' =&gt; array(
      'template' =&gt; 'poll-results--block',
      'variables' =&gt; $theme_hooks['poll_results']['variables'],
    ),
    'poll_bar__block' =&gt; array(
      'template' =&gt; 'poll-bar--block',
      'variables' =&gt; $theme_hooks['poll_bar']['variables'],
    ),
  );
  return $theme_hooks;
}


In function poll_view_voting($form, &amp;$form_state, $node, $block = FALSE) { there is $form['#theme'] = 'poll_vote'; 

How does this work and what does this to?

Also there is this function:

function template_preprocess_poll_vote(&amp;$variables) {
  $form = $variables['form'];
  $variables['choice'] = drupal_render($form['choice']);
  $variables['title'] = check_plain($form['#node']-&gt;title);
  $variables['vote'] = drupal_render($form['vote']);
  $variables['rest'] = drupal_render_children($form);
  $variables['block'] = $form['#block'];
  if ($variables['block']) {
    $variables['theme_hook_suggestions'][] = 'poll_vote__block';
  }
}


I was able to create a function theme_preprocess_poll_vote(&amp;$variables) which I was able to change the output. Is their a document that explains how this all works?
I'd suggest you read everything you can in the Theming guide.  It looks like you're specifically looking for this part of it though.