Modify default rendering of a custom content type defined in a module
This is the way that I solved this problem:

/**
 * Implements hook_theme().
 */
function docbook_theme($existing, $type, $theme, $path) {
  return array (
    'node__docbook' =&gt; array(
      'template' =&gt; 'node--docbook',
    ),
    'node__docbook_section' =&gt; array(
      'template' =&gt; 'node--docbook-section' ,
    ),
    'field__field_dbw_author' =&gt; array(
    ),
  );
}

/**
 * Implements hook_preprocess_HOOK().
 */
function docbook_preprocess_node(&amp;$variables) {
  //krumo($variables);  //debug

  if ($variables['type'] == 'docbook') {
    $variables['variable1'] = 'hello1';
  }

  if ($variables['type'] == 'docbook_section') {
    $variables['variable2'] = 'hello2';
  }
}

/**
 * Implementing theme function theme_HOOK().
 */
function theme_field__field_dbw_author($variables) {
  //krumo($variables);  //debug

  $output = '';

  . . . . . . . . . . . . . . .

  return $output;
}


See more details on these commits:


https://github.com/dashohoxha/DocBookWiki/commit/0e15266fdfa9000bd32d2ddabce036b21fa55930
https://github.com/dashohoxha/DocBookWiki/commit/0fee64d261f66878166c215559234e01e185e6f1
https://github.com/dashohoxha/DocBookWiki/commit/0fb4ac1ca7da38067c647f362c22d167c62f5ae6
https://github.com/dashohoxha/DocBookWiki/commit/db15d8af013bfc91143029c84e7cd0134400af85
https://github.com/dashohoxha/DocBookWiki/commit/c9250ba89094fc2c8fa83945ffbee0be25d42d84


I would expect these solutions to work as well: 

function docbook_preprocess(&amp;$variables, $hook) { 
  if ($hook == 'node__docbook') { 
    $variables['my_new_variable'] = 'hello'; 
  } 
} 

function docbook_preprocess_node__docbook(&amp;$variables) { 
  $variables['my_new_variable'] = 'hello'; 
} 

function template_preprocess_node__docbook(&amp;$variables) { 
  $variables['my_new_variable'] = 'hello'; 
} 


But somehow they don't work. Either my understanding and expectations are wrong, or there is something wrong on the implementation of Drupal.