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 endyou must compile yard documentation before can output this. don't want
docfolder right? let's omit that.yardoc --no-output test.rbthis update documentation inside
.yardocfolder hidden.docfolder 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 coolthis output get. can yard documentation class/method using
yard displaycommand.but hey, output sucks! let's create template it. create following
templatesfolder 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') | endall
setup.rbfiles must have same contentdef init, super, sections t('docstring'), end. maketextoutput display documentation, without fancy headers , stuff.now run same
yard displaycommand, let's use our custom templates:> yard display foo --template-path ./templates class cool > yard display "foo#meth" --template-path ./templates method coolthat's it. may find
yard docmay have of leading/trailing new lines in output, can use other standard linuxhead/tailcommands fix that.
Comments
Post a Comment