|
| 1 | +# \RDoc Sources |
| 2 | + |
| 3 | +\RDoc derives Ruby documentation from files |
| 4 | +that are selected by \RDoc defaults and by user specifications. |
| 5 | + |
| 6 | +\RDoc reads files and directories specified as arguments |
| 7 | +on the `rdoc` command line; |
| 8 | +if no arguments are given, \RDoc reads `'.'` (the current working directory): |
| 9 | + |
| 10 | +- For each given file path \RDoc reads the file. |
| 11 | +- For each given directory path, |
| 12 | + \RDoc (by default) recursively reads all directories and files in the directory tree. |
| 13 | + You can restrict the and directories and files to be read by creating |
| 14 | + [.document files][document files]. |
| 15 | + |
| 16 | +## File Types |
| 17 | + |
| 18 | +Based on the file extension of a file name, |
| 19 | +\RDoc assumes its content to be one of these: |
| 20 | + |
| 21 | +- `.rb`: Ruby code. |
| 22 | +- `.c`, `.h`, `.C`, `.H`: C code. |
| 23 | +- `.rdoc`: Text file in `rdoc` (markup) format. |
| 24 | +- `.md`: Text file in `markdown` format. |
| 25 | +- `.rd`: Text file in `rd` format. |
| 26 | + |
| 27 | +In Ruby or C code, documentation is derived from the code itself, |
| 28 | +and may also be derived from the text of comments; |
| 29 | +that text may be in any of these formats |
| 30 | +(see [directive :markup:][directive markup]). |
| 31 | + |
| 32 | +- `rdoc` (markup); |
| 33 | + see RDoc::MarkupReference. |
| 34 | +- `markdown`; |
| 35 | + see RDoc::Markdown. |
| 36 | +- `rd`; |
| 37 | + see [RD Working Draft][rd working draft]. |
| 38 | +- `tomdoc`; |
| 39 | + see [Tomdoc for Ruby][tomdoc for ruby]. |
| 40 | + |
| 41 | +## `.document` Files |
| 42 | + |
| 43 | +When \RDoc reads a directory, |
| 44 | +it first looks for a file named `.document`: |
| 45 | + |
| 46 | +- If the file does not exist, |
| 47 | + \RDoc reads all files in the directory, |
| 48 | + and reads its subdirectories. |
| 49 | +- It the file exists, |
| 50 | + \RDoc reads only the files and subdirectories specified there. |
| 51 | + |
| 52 | +The format of the `.document` file is simple: |
| 53 | + |
| 54 | +- Each line may contain a _pattern_, which may be: |
| 55 | + |
| 56 | + - A file path. |
| 57 | + - A directory path. |
| 58 | + - A file glob, such as `*.rb` or `C*`. |
| 59 | + |
| 60 | +- A line may contain only one pattern (no whitespace- or comma-separated multiple patterns). |
| 61 | +- A pattern may be followed (on the same line) by a comment (beginning with `'#'`). |
| 62 | +- An entire line may be a comment (beginning with `'#'`). |
| 63 | +- A line may be blank (empty). |
| 64 | + |
| 65 | +Any directory in the filetree may contain a `.document`file. |
| 66 | + |
| 67 | +[document files]: rdoc-ref:[email protected]+Files |
| 68 | +[directive markup]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-3Amarkup-3A |
| 69 | +[rd working draft]: https://github.com/uwabami/rdtool/blob/master/doc/rd-draft.rd |
| 70 | +[tomdoc for ruby]: http://tomdoc.org |
0 commit comments