Sha256: 68dff6846f35055508b777f303854893539cb8ba570ce645ee1909796700aa2b

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

# Hooks

_RSpec::Documentation_ provides hooks for inserting content into various places rendered _HTML_ documents for each page of your documentation.

To configure hooks, add the following to `rspec-documentation/spec_helper.rb`:

```ruby
RSpec::Documentation.configure do |config|
  config.hook(:after_head) { '<style>h1 { font-size: 10rem; }</style>' }
end
```

In practice you will most likely load content from a file using `File.read` or similar. You are free to store supplementary content anywhere in your project, e.g. you may want to create `rspec-documentation/assets` and create a hook such as:

```ruby
RSpec::Documentation.configure do |config|
  config.hook(:after_head) do
    "<script>#{File.read('rspec-documentation/assets/fontawesome.js')}</script>"
  end
end
```

## Available Hooks

| Hook | Description |
|-|-|
| `after_head` | Inserts content immediately before the closing `</head>` tag, after the default head content. Use this to override any styling or add `<script>` and `<link>` tags. |
| `after_header` | Inserts content immediately after the main document header. Use this to insert custom content underneath the header for each page. |
| `before_content` | Inserts content immediately before the main document content, between the navigation tree and each rendered documentation page. |
| `after_content` | Inserts content immediately after the main documentation content, before the footer. |
| `after_footer` | Inserts content immediately below the footer. |

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-documentation-0.0.11 rspec-documentation/pages/060-Configuration/Hooks.md
rspec-documentation-0.0.10 rspec-documentation/pages/060-Configuration/Hooks.md
rspec-documentation-0.0.9 rspec-documentation/pages/060-Configuration/Hooks.md
rspec-documentation-0.0.8 rspec-documentation/pages/060-Configuration/Hooks.md
rspec-documentation-0.0.7 rspec-documentation/pages/060-Configuration/040-Hooks.md
rspec-documentation-0.0.6 rspec-documentation/pages/060-Configuration/040-Hooks.md