   Html = require 'html'
   Documentation = require 'documentation'
 
-  graphite = modules.create 'graphite', ({fn, component_fn, cmd, settings}) ->
+  graphite = modules.create 'graphite', ({fn, component_fn, cmd, settings, doc}) ->
     build_function_doc = (ctx, doc) ->
       FunctionDocsComponent {ctx, docs: docs.function_docs[doc.function_name]}
 

        @add_component React.DOM.h3 {}, 'Parameters'
        @help 'graphite_parameters'

    fn 'params', 'Generates the parameters for a Graphite render call', (args...) ->
      result = args_to_params @, args
      @value result

    component_fn 'url', 'Generates a URL for a Graphite image', (args...) ->
      params = args_to_params @, args
      url = graphite.render_url params
      React.DOM.pre {}, React.DOM.a {href: url, target: 'blank'}, url

    fn 'img', 'Renders a Graphite graph image', (args...) ->
      params = args_to_params @, args
      url = graphite.render_url params
      @async ->


    default_target_command = 'img'

    doc 'q',
      'Escapes a metric query'
      """
      Use `q` to reference a metric name in the DSL.

      The Graphite API uses unquoted strings to specify metric names and patterns.
      The string argument to `q` will be passed directly to the API.

      For example, `sumSeries(q('twitter.*.tweetcount'))` will be sent as `sumSeries(twitter.*.tweetcount)`.
      """

    fn 'q', (targets...) ->
      for t in targets
        unless _.isString t
          throw new TypeError "#{t} is not a string"
