国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

directory search
Ruby用戶指南 3、開始 4、簡單的例子 5、字符串 6、正則表達式 7、數(shù)組 8、回到那些簡單的例子 9、流程控制 10、迭代器 11、面向?qū)ο笏季S 12、方法 13、類 14、繼承 15、重載方法 16、訪問控制 17、單態(tài)方法 18、模塊 19、過程對象 20、變量 21、全局變量 22、實變量 23、局部變量 24、類常量 25、異常處理:rescue 26、異常處理:ensure 27、存取器 28、對象的初始化 29、雜項 RGSS入門教程 1、什么是RGSS 2、開始:最簡單的腳本 3、數(shù)據(jù)類型:數(shù)字 4、數(shù)據(jù)類型:常量與變量 5、數(shù)據(jù)類型:字符串 6、控制語句:條件分歧語句 7、控制語句:循環(huán) 8、函數(shù) 9、對象與類 10、顯示圖片 11、數(shù)組 12、哈希表(關(guān)聯(lián)數(shù)組) 13、類 14、數(shù)據(jù)庫 15、游戲?qū)ο?/a> 16、精靈的管理 17、窗口的管理 18、活動指令 19、場景類 Programming Ruby的翻譯 Programming Ruby: The Pragmatic Programmer's Guide 前言 Roadmap Ruby.new 類,對象和變量 容器Containers,塊Blocks和迭代Iterators 標準類型 深入方法 表達式Expressions 異常,捕捉和拋出(已經(jīng)開始,by jellen) 模塊 基本輸入輸出 線程和進程 當遭遇挫折 Ruby和它的世界 Ruby和Web開發(fā) Ruby Tk Ruby 和微軟的 Windows 擴展Ruby Ruby語言 (by jellen) 類和對象 (by jellen) Ruby安全 反射Reflection 內(nèi)建類和方法 標準庫 OO設(shè)計 網(wǎng)絡(luò)和Web庫 Windows支持 內(nèi)嵌文檔 交互式Ruby Shell 支持 Ruby參考手冊 Ruby首頁 卷首語 Ruby的啟動 環(huán)境變量 對象 執(zhí)行 結(jié)束時的相關(guān)處理 線程 安全模型 正則表達式 字句構(gòu)造 程序 變量和常數(shù) 字面值 操作符表達式 控制結(jié)構(gòu) 方法調(diào)用 類/方法的定義 內(nèi)部函數(shù) 內(nèi)部變量 內(nèi)部常數(shù) 內(nèi)部類/模塊/異常類 附加庫 Ruby變更記錄 ruby 1.6 特性 ruby 1.7 特性 Ruby術(shù)語集 Ruby的運行平臺 pack模板字符串 sprintf格式 Marshal格式 Ruby FAQ Ruby的陷阱
characters

Embedded Documentation



Figure not available...

Figure not available...

So you've written a masterpiece, a class in a class of its own, and you'd like to share it with the world. But, being a responsible developer, you feel the need to document your creation. What do you do? The simplest solution is to use Ruby's built-in documentation format, RD, and rdtool, a Ruby utility suite that converts this documentation into a variety of output formats.

rdtool scans a file for =begin and =end{=begin...=end@{=begin pairs, and extracts the text between them all. This text is assumed to be documentation in RD format. The text is then processed according to a simple set of rules:

  • Lines of text flush to the left margin are converted to paragraphs.
  • Lines starting with one to four equals signs are headings. ``='' is a first-level heading, ``=='' a second-level heading, and so on. ``+'' and ``++'' can be used to signal fifth- and sixth-level headings if you really want to go that deep.

    =?Top?Level?Heading
    ==?Second?Level?Heading
    ...
    
  • Lines in which the first nonspace is an asterisk indicate the beginnings of bullet lists. Continuation lines for each bullet item should line up with the text on the first line. Lists may be nested.

    This?is?normal?text
    *?start?of?a
    ??multiline?bullet?item
    *?and?another
    ??*?nested?item
    ??*?second?nested
    *?third?item?at?top?level
    
  • Lines where the first nonspace characters are digits between parentheses indicate numbered lists. The actual digits used are ignored. Again, lists may be nested.

    (1)?A?numbered?item
    ????*?subitem?in?a?bulleted?list
    ????*?subitem
    (2)?Second?numbered?item
    (9)?This?will?actually?be?labeled?'3.'
    
  • Lines starting with a colon indicate labeled lists. The text on the colon line is the label. The immediately following text (which may not be indented less than the label) is the descriptive text. Again, each type of list may be nested.

    :?red
    ??when?the?light?is?red,?you
    ??must?stop
    :?amber
    ??the?amber?light?means?that?things?are?about?to?change.?Either:
    ??*?step?on?the?gas,?or
    ??*?slam?on?the?brakes
    :?green
    ??green?means?GO
    
  • Lines starting with three minus signs are a special kind of labeled list, when the labels are method names and signatures. The source in Figure A.1 on page 512 shows a handful of these in action.

Indented text that isn't part of a list is set verbatim (such as the stuff under ``Synopsis'' in Figures A.1 and A.2).

Inline Formatting

Within blocks of text and headings, you can use special inline sequences to control text formatting. All sequences are nested within a set of double parentheses.

Sequence Example Intended Use
((*emphasis*)) emphasis Emphasis (normally italic)
(({code stuff})) code stuff Code
((|variable|)) variable Variable name
((%type me%)) type me Keyboard input
((:index term:)) index term Something to be indexed
((<reference>)) reference Hyperlink reference
((-footnote-)) text.4 Footnote text. A reference is placed inline, and the text of the footnote appears at the bottom of the page.
(('verb')) verb Verbatim text

Cross References

The content of headings, the labels of labeled lists, and the names of methods are automatically made into potential cross reference targets. You make links to these targets from elsewhere in the document by citing their contents in the ((<...>)) construct.

=?Synopsis
...
See?((<Return?Codes>))?for?details.
..
==?Instance?Methods

---?Tempfile.open(?filename?) ????Opens?the?file...

==?Return?Codes .. The?method?((<Tempfile.open>))?raises?an?(({IOException}))...

If a reference starts with ``URL:'', rdtool attempts to format it as an external hyperlink.

The reference ((<display part|label>)) generates a link to label but places the text ``display part'' in the output document. This is used in the description section of the example in Figure A.1 on page 512 to generate references to the method names:

perspective,?apart?from?the?unusual?((<(({new}))|Tempfile.new>)),
...

This construct displays the word ``new'' in code font but uses it as a hyperlink to the method Tempfile.new.

Method Names

rdtool makes certain assumptions about the format of method names. Class or module methods should appear as Class.method, instance methods as Class#method, and class or module constants as Class::Const.

---?Tempfile::IOWRITE
????Open?the?file?write-only.
????...
---?Tempfile.new(?filename?)
????Constructs?a?temporary?file?in?the?given?directory.?The?file
????...
---?Tempfile#open
????Reopens?((|aTempfile|))?using?mode?``r+'',?which?allows?reading
????..

Including Other Files

The contents of filename will be inserted wherever the document contains

<<< filename

If the file is specified with an .rd or .rb extension, it will be interpreted as RD documentation.

If the filename has no extension, rdtool will look for a file with an extension that matches the type of output being produced (.html for HTML files, .man for man files, and so on) and interpolate that file's contents in the output stream. Thus, a line such as:

<<<?header

could be used to add an output-dependent header to a document.

Using rdtool

RD documentation can be included directly in a Ruby source program or written into a separate file (which by convention will have the extension .rd). These files are processed using the rd2 command to produce appropriately formatted output.

rd2  [
            options
            ]  inputfile   [ >outputfile ]

Some common options include:

-r format Select an output format. -rrd/rd2html-lib.rb produces HTML output (the default). -rrd/rd2man-lib.rb produces Unix man page output.
-o name Set the base part of the output filename.
--help List the full set of options.

Mandatory Disclaimer

As we are writing this, RD and rdtool are undergoing continuous development. It is likely that some of the details we give here will be out of date (or just plain wrong) by the time you read this.

Included with the rdtool distribution is the file README.rd. We suggest you do so, as it will give you the current scoop on producing Ruby documentation.


Extracted from the book "Programming Ruby - The Pragmatic Programmer's Guide"
Copyright
Previous article: Next article: