apitome.rb 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Apitome.setup do |config|
  # This determines where the Apitome routes will be mounted. Changing this to '/api/documentation' for instance would
  # allow you to browse to http://localhost:3000/api/documentation to see your api documentation. Set to nil and mount
  # it yourself if you need to.
  config.mount_at = "/api"

  # This defaults to Rails.root if left nil. If you're providing documentation for an engine using a dummy application
  # it can be useful to set this to your engines root.. E.g. Application::Engine.root
  config.root = nil

  # This is where rspec_api_documentation outputs the JSON files. This is configurable within RAD, and so is
  # configurable here.
  config.doc_path = "doc/api"

  # Set a parent controller that Apitome::DocsController inherits from. Useful if you want to use a custom
  # `before_action`.
  config.parent_controller = "ActionController::Base"

  # The title of the documentation -- If your project has a name, you'll want to put it here.
  config.title = "SRCT Schedules API"

  # The main layout view for all documentation pages. By default this is pretty basic, but you may want to use your own
  # application layout.
  config.layout = "apitome/application"

  # We're using highlight.js (https://github.com/isagalaev/highlight.js) for code highlighting, and it comes with some
  # great themes. You can check http://softwaremaniacs.org/media/soft/highlight/test.html for themes, and enter the
  # theme as lowercase/underscore.
  config.code_theme = "default"

  # This allows you to override the css manually. You typically want to require `apitome/application` within the
  # override, but if you want to override it entirely you can do so.
  config.css_override = nil

  # This allows you to override the javascript manually. You typically want to require `apitome/application` within the
  # override, but if you want to override it entirely you can do so.
  config.js_override = nil

  # You can provide a 'README' style markdown file for the documentation, which is a useful place to include general
  # information. This path is relative to your doc_path configuration.
  config.readme = "../api.md"

  # Apitome can render the documentation into a single page that uses scrollspy, or it can render the documentation on
  # individual pages on demand. This allows you to specify which one you want, as a single page may impact performance.
  config.single_page = true

  # You can specify how urls are formatted using a Proc or other callable object.
  # Your proc will be called with a resource name or link, giving you the opportunity to modify it as necessary for in the documentation url.
Zac Wood's avatar
Zac Wood committed
49
  config.url_formatter = ->(str) { str.gsub(/\.json$/, '').underscore.gsub(/[^0-9a-z\:]+/i, '-') }
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

  # You can setup the docs to be loaded from a remote URL if they are
  # not available in the application environment. This defaults to
  # false.
  config.remote_docs = false

  # If the remote_docs is set to true, this URL is used as the base for
  # the doc location. This should be the root of the doc location, where
  # the readme is located. It uses the doc_path setting to build the
  # URLs for the API documentation. This defaults to nil.
  config.remote_url = nil

  # If you would like to precompile your own assets, you can disable auto-compilation.
  # This defaults to true
  config.precompile_assets = true
end