             href = $(this).attr 'href'
             if href[0] is '#'
               context.run "docs '#{decodeURI href[1..]}'"
-          $result.append $docs
+          @div $docs
         unless function_docs? or parameter_docs?
           @text 'Documentation not found'
       else

      @add_renderable finder

    fn 'find', 'Finds Graphite metrics', (query) ->
      @value @async ->
        $result = @output()
        promise = graphite.find query
        promise.clicks = new Bacon.Bus

        @renderable promise, ->
          promise.done ({query, result}) =>
            query_parts = query.split '.'
            $ul = $ '<ul class="find-results"/>'
            for node in result
              $li = $ '<li class="cm-string"/>'
              $li.data 'node', node
              text = node.path
              text += '*' unless node.is_leaf
              node_parts = text.split '.'
              for part, i in node_parts
                if i > 0
                  $li.append '.'
                $span = $ '<span>'
                $span.addClass 'light' if part == query_parts[i]
                $span.text part
                $li.append $span

              promise.clicks.plug $li.asEventStream('click').map (e) -> $(e.target).closest('li').data('node')

              $ul.append $li
            $result.append $ul

    context_vars: -> dsl.define_functions {}, function_names


      $a.text url
      $pre = $ '<pre>'
      $pre.append $a
      @add_rendered $pre

    fn 'img', 'Renders a Graphite graph image', (args...) ->
      params = args_to_params @, args
      url = graphite.render_url params
      @async ->
        $img = $ "<img src='#{url}'/>"
        @div $img
        deferred = Q.defer()
        $img.on 'load', deferred.resolve
        $img.on 'error', deferred.reject

        promise = deferred.promise
        promise.fail (args...) =>
          @error 'Failed to load image'
        promise

    fn 'table', 'Displays Graphite data in a table', (args...) ->
      params = args_to_params @, args
      @async ->
        $result = @div()
        promise = graphite.get_data params
        promise.done (response) =>
          for series in response
            $header = $ '<h3>'
            $header.text series.target
            $result.append $header
            $table = $ '<table>'
            for [value, timestamp] in series.datapoints
              time = moment(timestamp * 1000)
              $table.append "<tr><th>#{time.format('MMMM Do YYYY, h:mm:ss a')}</th><td class='cm-number number'>#{value?.toFixed(3) or '(none)'}</td></tr>"
            $result.append $table
        promise.fail @keeping_context (error) =>
          @error error
        promise

    fn 'graph', 'Graphs Graphite data', (args...) ->
      params = Bacon.constant(args).map(args_to_params, @)
