Apitome sidebar disappears when included in a layout

63 Views Asked by At

I am using the rspec_api_documentation and apitome gems in a version 5.2 ruby on rails app.

This produces excellent documentation, and has a sidebar (div#sidebar) to allow quick access to the correct part of the documentation. When I choose the

config.layout = "layouts/application.html.erb"

option in the apitome.rb initializer, the documentation is rendered, but the sidebar has disappeared. Looking at the page source, the code for the sidebar is not being rendered, i.e. it is not a css problem, the html is not being put into the layout. To make sure it was not something unusual in my application.html.erb file, I simplified it to this

<!DOCTYPE html>
<html>
  <head>
  </head>

  <body>
        <%= yield %>
  </body>
</html>

This sidebar is very useful, so how do I render it in a layout?

1

There are 1 best solutions below

0
On BEST ANSWER

Based on the response to this issue, I was able to solve this.

I created a new layout at app/views/layouts.apidocs.html.erb which rendered apitome/docs/navigation. A simple example would be as follows

# app/views/layouts/apidocs.html.erb

<!DOCTYPE html>
<html>
  <head>
  </head>

  <body>
    <div class="container">
      <div class="row">
        <div class="col-md-4">
          <div id="sidebar" class="sidebar hidden-print" role="complementary">
            <%= render 'apitome/docs/navigation' %>
          </div>
        </div>
        <div class="col-md-8" role="main">
          <div class="docs-section">
            <%= yield %>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

I then configured this layout in the apitome initialiser.

# config/initializers/apitome
Apitome.setup do |config|
   ...
   config.layout = "layouts/apidocs.html.erb"
end

After some css tinkering, it all looked good.