RDOC说明文档Word文档格式.docx
- 文档编号:18595707
- 上传时间:2022-12-29
- 格式:DOCX
- 页数:18
- 大小:368.78KB
RDOC说明文档Word文档格式.docx
《RDOC说明文档Word文档格式.docx》由会员分享,可在线阅读,更多相关《RDOC说明文档Word文档格式.docx(18页珍藏版)》请在冰豆网上搜索。
of
animal
4.
[+dog+]
also
pet
5.
=
leval
one
6.
==
two
7.
and
so
on
8.
----
9.
how
about
this
10.
11.
def
foo(name)
12.
@name
name
13.
end
14.
15.
16.
Extract
the
age
calculate
17.
date-of-birth.
18.
#--
19.
FIXME:
fails
if
birthday
falls
20.
February
29th
21.
#++
22.
The
DOB
is
returned
as
Time
object.
23.
24.
get_dob(person)
25.
26.
27.end
效果
classDemo
PublicInstanceMethods
foo(name)
∙测试
cat
akindofanimal
dog
alsoapet
levalone
∙levaltwo
andsoon
howaboutthis
∙
get_dob(person)
Extracttheageandcalculatethedate-of-birth.TheDOBisreturnedasaTimeobject.
通常使用rdoc命令来为ruby程序生成文档
eg:
rdoctest.rb
如果要对整个项目的rb文件生成文档只需在rdoc命令后不带文件名
rdoc
如果有类和方法不想生成doc
defno_doc#:
nodoc:
end
或
classNoDocClass#:
all
部分注释不想生成doc
#--
#该行不会生成doc
#++
#该行会生成doc
rdoc命令:
--all:
rdoc默认只将共有方法生成doc,使用--all会将所有方法生成doc
--fmt<
xml,yaml,chm,pdf>
用指定格式生成文档
--help:
--inline-source:
将代码显示在文档中
--main<
name>
设置主索引页面的名字
--one-file:
将rdoc所有文档内容放在一个文件中
--op<
目录名>
设置输出目录的目录名
RDOC-RubyDocumentationSystem
ThispackagecontainsRdocandSimpleMarkup.RdocisanapplicationthatproducesdocumentationforoneormoreRubysourcefiles.WeworksimilarlytoJavaDoc,parsingthesource,andextractingthedefinitionforclasses,modules,andmethods(alongwithincludesandrequires).Weassociatewiththeseoptionaldocumentationcontainedintheimmediatelyprecedingcommentblock,andthenrendertheresultusingapluggableoutputformatter.(Currently,HTMListheonlysupportedformat.Markupisalibrarythatconvertsplaintextintovariousoutputformats.TheMarkuplibraryisusedtointerpretthecommentblocksthatRdocusestodocumentmethods,classes,andsoon.
Installation
Thisdistributioncontainstwopackages,rdocitselfandatextmarkuplibrary,'
markup'
.Youcaninstallthembothusingthesinglecommand
%rubyinstall.rb
inthisdirectory.Ifyoujustwanttoinstall'
changetothemarkupdirectoryandruntheinstall.rbscriptthere.
Roadmap
∙IfyouwanttouseRdoctocreatedocumentationforyourRubysourcefiles,readon.
∙IfyouwanttoincludeextensionswritteninC,see
rdoc/parsers/parse_c.rb.
∙Forinformationonthevariousmarkupsavailableincommentblocks,see
markup/simple_markup.rb.
∙IfyouwanttodriveRdocprogramatically,see
RDoc:
RDoc.
∙IfyouwanttousethelibrarytoformattextblocksintoHTML,havealookat
SM:
SimpleMarkup.
∙IfyouwanttotrywritingyourownHTMLoutputtemplate,see
Page.
Summary
Onceinstalled,youcancreatedocumentationusingthe'
rdoc'
command(thecommandis'
rdoc.rb'
underWindows)
%rdoc[options][names...]
Type"
rdoc--help"
foranup-to-dateoptionsummary.
AtypicalusemightbetogeneratedocumentationforapackageofRubysource(suchasrdocitself).
%rdoc
ThiscommandgeneratesdocumentationforalltheRubyandCsourcefilesinandbelowthecurrentdirectory.Thesewillbestoredinadocumentationtreestartinginthesubdirectory'
doc'
.
Youcanmakethisslightlymoreusefulforyourreadersbyhavingtheindexpagecontainthedocumentationfortheprimaryfile.Inourcase,wecouldtype
%rdoc--mainrdoc/rdoc.rb
You'
llfindinformationonthevariousformattingtricksyoucanuseincommentblocksinthedocumentationthisgenerates.
RDoc
usesfileextensionstodeterminehowtoprocesseachfile.Filenamesending
.rb
.rbw
areassumedtobeRubysource.Filesending
.c
areparsedasCfiles.AllotherfilesareassumedtocontainjustSimpleMarkup-stylemarkup(withorwithoutleading'
#'
commentmarkers).Ifdirectorynamesarepassedto
RDoc,theyarescannedrecursivelyforCandRubysourcefilesonly.
Credits
∙TheRubyparserinrdoc/parse.rbisbasedheavilyontheoutstandingworkofKeijuISHITSUKAofNipponRationalInc,whoproducedtheRubyparserforirbandthertagspackage.
∙CodetodiagramclassesandmoduleswaswrittenbySergeyAYanovitsky(Jah)ofEnticla.
∙CharsetpatchfromMoonWolf.
∙RichKilmerwrotethekilmer.rboutputtemplate.
∙DanBrickleyledthedesignoftheRDFformat.
License
isCopyright(c)2001-2003DaveThomas,ThePragmaticProgrammers.Itisfreesoftware,andmayberedistributedunderthetermsspecifiedinthe
README
fileoftheRubydistribution.
Support
TheRdochomepageis
.Thereyou'
llfindlinksfordownloadingtheRdocpackage,andinstructionsonhowtogetthestill-quiveringsourcesfromCVS.I'
malsousingSourceforgetotrackbugsandmanagefeaturerequests.Ifyousubmitpatches,itwouldhelpiftheywereinline(notattachments)andgeneratedusing"
diff-u"
.Idon'
thaveaccesstoawidevarietyofbrowsers,soreportsthatoutputlooksfunnyunderBrowserXYZaren'
ttoohelpful:
farbetteraresuggestedchangestothegeneratedHTMLthatfixtheproblem.
Forotherinformation,feelfreetoaskontheruby-talkmailinglist(whichismirroredtocomp.lang.ruby)orcontact
dave@.
Usage
isinvokedfromthecommandlineusing:
%rdoc<
options>
[name...]
Filesareparsed,andtheinformationtheycontaincollected,beforeanyoutputisproduced.Thisallowscrossreferencesbetweenallfilestoberesolved.Ifanameisadirectory,itistraversed.Ifnonamesarespecified,allRubyfilesinthecurrentdirectory(andsubdirectories)areprocessed.
Optionsare:
--all
includeprotectedandprivatemethodsintheoutput(bydefaultonlypublicmethodsareincluded)
--main
name
settheclass,module,orfiletoappearontheindexpage
--exclude
pattern
excludefilesanddirectoriesmatchingthispatternfromprocessing
--quiet
donotdisplayprogressmessages
--one-file
placealltheoutputintoasinglefile
--op
dir
settheoutputdirectoryto
dir
(thedefaultisthedirectory"
doc"
)
--opname
settheoutputname(hasnoeffectforHTML).
--charset
charset
SetthecharactersetforthegeneratedHTML.
--fmt
fmt
generateoutputinaparticularformat.
--include
dir,...
specifyoneormoredirectoriestobesearchedwhensatifyinggiven.Thedirectorycontainingthefilecurrentlybeingprocessedisalwayssearched.
--inline-source
Bydefault,thesourcecodeofmethodsisshowninapopup.Withthisoption,it'
sdisplayedinline.
--show-hash
Anameoftheformnameinacommentisapossiblehyperlinktoaninstancemethodname.Whendisplayed,the'
isremovedunlessthisoptionisspecified
--template
specifyanalternatetemplatetousewhengeneratingoutput(thedefaultis'
standard'
).Thistemplateshouldbeinadirectoryaccessiblevia$:
asrdoc/generators/xxxx_template,where'
xxxx'
dependsontheoutputformatter.
--diagram
includediagramsshowingmodulesandclasses.Thisiscurrentlyanexperimentalfeature,andmaynotbesupportedbyalloutputtemplates.YouneeddotV1.8.6orlatertousethe--diagramoptioncorrectly(
Example
AtypicalsmallRubyprogramcommentedusing
mightbeasfollows.YoucanseetheformattedresultinEXAMPLE.rband
Anagram.
#Theprogramtakesaninitialwordorphrasefrom
#thecommandline(orintheabsenceofa
#parameterfromthefirstlineofstandard
#input).Inthenreadssuccessivewordsor
#phrasesfromstandardinputandreportswhether
#theyareangramsofthefirstword.
#
#Author:
DaveThomas(mailto:
dave@x.y)
#Copyright:
Copyright(c)2002ThePragmaticProgrammers,LLC
#License:
DistributesunderthesametermsasRuby
#Thisclassholdsthelettersintheoriginal
#wordorphrase.Theis_anagram?
methodallowsus
#totestifsubsequentwordsorphrasesare
#anagramsoftheoriginal.
classAnagram
#Rememberthelettersintheinitialword
definitialize(text)
@initial_letters=letters_of(text)
end
#Testtoseeifanewwordcontainsthesame
#lettersastheoriginal
defis_anagram?
(text)
@initial_letters==letters_of(text)
#Determinethelettersinawordorphrase
#*alllettersareconvertedtolowercase
#*anythingnotaletterisstrippedout
#*thelettersareconvertedintoanarray
#*thearrayissorted
#*thelettersarejoinedbackintoastring
defletters_of(text)
text.downcase.delete('
^a-z'
).split('
'
).sort.join
tester=Anagram.new(ARGV.shift||gets)
ARGF.eachdo|text|
puts"
Anagram!
"
iftester.is_anagram?
text
Markup
Commentblockscanbewrittenfairlynaturally.
Paragraphsarelinesthatsharetheleftmargin.Textindentedpastthismarginareformattedverbatim.
1.Listsaretypedasindentedparagraphswith:
oa'
*'
or'
-'
(forbulletlists)
oadigitfollowedbyaperiodfornumberedlists
Forexample,theinputthatproducedtheaboveparagraphlookedlike
1.Listsaretypedasindented
paragraphswith:
*a'
*adigitfollowedbyaperiodfor
numberedlists
2.Labeledlists(sometimescalleddescriptionlists)aretypedusingsquarebracketsforthelabel.
3.[cat]smalldomesticanimal
4.[+cat+]commandtocopystandardinput
5.Labeledlistsmayalsobeproducedbyputtingadoublecolonafterthelabel.Thissetstheresultintabularform,sothedescriptionsalllineup.Thiswasusedtocreatethe'
author'
blockatthebottomof
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- RDOC 说明 文档