You are here

function hook_styleguide in Style Guide 7

Same name and namespace in other branches
  1. 6 styleguide.api.php \hook_styleguide()

Register a style guide element for display.

hook_styleguide() defines an array of items to render for theme testing. Each item is rendered as an element on the style guide page.

Each item should be keyed with a unique identifier. This value will be used to create a named anchor link on the Style Guide page.

Options: -- 'title' (required). A string indicating the element name. -- 'description' (optional). A short description of the item. -- 'theme' (optional). A string indicating the theme function to invoke. If used, you must return a 'variables' array element. Otherwise, you must return a 'content' string. -- 'variables' (optional). An array of named vairables to pass to the theme function. This structure is designed to let you test your theme functions for syntax. -- 'content' (optional). A string or renderable array of content to present. May be used in conjunction with a 'tag' element, or used instead of a theme callback. -- 'tag' (optional). A string indicating a valid HTML tag (wihout <>). This tag will be wrapped around the content. In Drupal 7, this element is deprecated in favor of theme_html_tag(). -- 'attributes' (optional). An array of attributes to apply to a tag element. -- 'group' (optional). A string indicating the context of this element. Groups are organized within the preview interface. If no group is provided, the item will be assigned to the 'Common' group.

Return value

$items An array of items to render.

9 functions implement hook_styleguide()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_styleguide in modules/aggregator.inc
Implements hook_styleguide().
book_styleguide in modules/book.inc
Implements hook_styleguide().
comment_styleguide in modules/comment.inc
Implements hook_styleguide().
filter_styleguide in modules/filter.inc
Implements hook_styleguide().
forum_styleguide in modules/forum.inc
Implements hook_styleguide().

... See full list

1 invocation of hook_styleguide()
styleguide_page in ./styleguide.module
The styleguide page.

File

./styleguide.api.php, line 35

Code

function hook_styleguide() {
  $items['ul'] = array(
    'title' => t('Unordered list'),
    'theme' => 'item_list',
    'variables' => array(
      'items' => styleguide_list(),
      'type' => 'ul',
    ),
    'group' => t('Common'),
  );
  $items['text'] = array(
    'title' => t('Text block'),
    'content' => styleguide_paragraph(3),
    'group' => t('Text'),
    'description' => t('A block of three paragraphs'),
  );
  $items['h1'] = array(
    'title' => t('Text block'),
    'tag' => 'h1',
    'content' => styleguide_word(3),
    'group' => t('Text'),
  );
  $items['div-format'] = array(
    'title' => t('Div special'),
    'description' => t('Add the "format" class to emphasize an entire section.'),
    'tag' => 'div',
    'attributes' => array(
      'class' => 'format',
    ),
    'content' => styleguide_paragraph(1),
  );
  return $items;
}