ruby - How to get Yardoc to output to STDOUT? -


i've looked templates come gem (i can find default html outputter), i've searched , online docs switch redirect stdout. can't find on how might approach this.

is there easy way (perhaps shell command?) or have wade through source code?

  • create following file test.rb:

    # class cool class test   # method cool   def foo   end end 
  • you must compile yard documentation before can output this. don't want doc folder right? let's omit that.

    yardoc --no-output test.rb 

    this update documentation inside .yardoc folder hidden. doc folder not generated.

  • now can see documentation specific objects in few ways:

    > yard display "test" # outputs: ------------------------------------------ class: foo < object      class cool    --------------------------------------------------------------  > yard display "test#foo" # outputs: ------------------------------------------ method: #meth (foo)                                           (defined in: foo.rb)      foo.meth -> object --------------------------------------------------------------      method cool 

    this output get. can yard documentation class/method using yard display command.

  • but hey, output sucks! let's create template it. create following templates folder few files:

    + app   + templates     + default       + class       | + text       |   + setup.rb       |       def init       |         super       |         sections t('docstring')       |       end       + method       | + text       |   + setup.rb       |       def init       |         super       |         sections t('docstring')       |       end       + method_details       | + text       |   + setup.rb       |       def init       |         super       |         sections t('docstring')       |       end 

    all setup.rb files must have same content def init, super, sections t('docstring'), end. make text output display documentation, without fancy headers , stuff.

  • now run same yard display command, let's use our custom templates:

    > yard display foo --template-path ./templates  class cool  > yard display "foo#meth" --template-path ./templates  method cool 
  • that's it. may find yard doc may have of leading/trailing new lines in output, can use other standard linux head/tail commands fix that.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -