Module: Sinatra::DocDsl

Defined in:
lib/docdsl.rb

Defined Under Namespace

Classes: DocEntry, PageDoc

Instance Method Summary collapse

Instance Method Details

#doc_endpoint(path) ⇒ Object



404
405
406
407
408
409
410
411
412
413
# File 'lib/docdsl.rb', line 404

def doc_endpoint(path) 
  page_doc=@page_doc
  get path do     
    begin
      page_doc.render
    rescue Exception=>e
      [500,"#{e.message} #{e.backtrace.inspect}"]
    end
  end      
end

#documentation(description, &block) ⇒ Object



419
420
421
422
423
# File 'lib/docdsl.rb', line 419

def documentation(description,&block)
  @page_doc ||= PageDoc.new
  @last_doc=DocEntry.new(description,&block)
  (@page_doc.entries ||= []) << @last_doc
end

#method_added(method) ⇒ Object



425
426
427
428
429
430
431
432
# File 'lib/docdsl.rb', line 425

def method_added(method)
  # document the method and nullify last_doc so that a new one gets created for the next method
  if @last_doc
    @last_doc << method
    @last_doc = nil
  end
  super
end

#page(&block) ⇒ Object



415
416
417
# File 'lib/docdsl.rb', line 415

def page(&block)
  @page_doc ||= PageDoc.new(&block)
end