Skip to content

Commit 0bdfb37

Browse files
committed
Rebuild RDoc markup documentation
1. README now has a better section about supported markup formats 2. RDoc markup related reference are now consolidated under `doc/markup_reference/rdoc.rdoc` 3. Markdown markup now has a more comprehensive reference in `doc/markup_reference/markdown.md`
1 parent b810f16 commit 0bdfb37

10 files changed

Lines changed: 1873 additions & 1591 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ exe/
220220

221221
### Documentation
222222

223-
- `README.md` - Basic usage guide
224-
- `ExampleRDoc.rdoc` - RDoc markup examples
225-
- `doc/rdoc/markup_reference.rb` - RDoc markup references
226-
- `ExampleMarkdown.md` - Markdown examples
223+
- `README.md` - Basic usage guide and markup format reference
224+
- `markup_reference/rdoc.rdoc` - Comprehensive RDoc markup syntax reference
225+
- `markup_reference/markdown.md` - Markdown syntax reference
226+
- `doc/rdoc/example.rb` - Ruby code examples for cross-references and directives
227227

228228
## Architecture Notes
229229

ExampleMarkdown.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

ExampleRDoc.rdoc

Lines changed: 0 additions & 222 deletions
This file was deleted.

README.md

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ You can specify the target files for document generation with `.document` file i
6060

6161
## Writing Documentation
6262

63-
To write documentation for RDoc place a comment above the class, module, method, constant, or attribute you want documented:
63+
To write documentation for RDoc, place a comment above the class, module, method, constant, or attribute you want documented:
6464

6565
```rb
6666
##
@@ -80,13 +80,79 @@ class Shape
8080
end
8181
```
8282

83-
The default comment markup format is the RDoc::Markup format. TomDoc, Markdown and RD format comments are also supported. You can set the default comment format for your entire project by creating a `.rdoc_options` file. See RDoc::Options@Saved+Options for instructions on creating one. You can also set the comment format for a single file through the `:markup:` directive, but this is only recommended if you wish to switch markup formats. See RDoc::Markup@Other+directives.
83+
### Markup Formats
8484

85-
Comments can contain directives that tell RDoc information that it cannot otherwise discover through parsing. See RDoc::Markup@Directives to control what is or is not documented, to define method arguments or to break up methods in a class by topic. See RDoc::Parser::Ruby for directives used to teach RDoc about metaprogrammed methods.
85+
RDoc supports multiple markup formats:
86+
87+
| Format | File Extensions | Default For |
88+
|--------|-----------------|-------------|
89+
| [RDoc](doc/markup_reference/rdoc.rdoc) | `.rdoc` | `.rb`, `.c` files |
90+
| [Markdown](doc/markup_reference/markdown.md) | `.md` | None |
91+
| RD | `.rd` | None |
92+
| TomDoc | N/A | None |
93+
94+
**RDoc markup** is currently the default format for Ruby and C files. However, we plan to retire it in favor of Markdown in the future.
95+
96+
**Markdown** support is actively being improved. Once it reaches feature parity with RDoc markup, it will become the default format.
97+
98+
For standalone documentation files, we recommend writing `.md` files instead of `.rdoc` files.
99+
100+
**RD** and **TomDoc** are legacy formats. We highly discourage their use in new projects.
101+
102+
### Specifying Markup Format
103+
104+
**Per-file:** Add a `:markup:` directive at the top of a Ruby file:
105+
106+
```ruby
107+
# :markup: markdown
108+
109+
# This class uses **Markdown** for documentation.
110+
class MyClass
111+
end
112+
```
113+
114+
**Per-project:** Create a `.rdoc_options` file in your project root:
115+
116+
```yaml
117+
markup: markdown
118+
```
119+
120+
**Command line:**
121+
122+
```bash
123+
rdoc --markup markdown
124+
```
125+
126+
### Feature Differences
127+
128+
| Feature | RDoc Markup | Markdown |
129+
|---------|-------------|----------|
130+
| Headings | `= Heading` | `# Heading` |
131+
| Bold | `*word*` | `**word**` |
132+
| Italic | `_word_` | `*word*` |
133+
| Monospace | `+word+` | `` `word` `` |
134+
| Links | `{text}[url]` | `[text](url)` |
135+
| Code blocks | Indent 2 spaces | Fenced with ``` |
136+
| Cross-references | Automatic | Automatic |
137+
| Directives (`:nodoc:`, etc.) | Supported | Supported |
138+
| Tables | Not supported | Supported |
139+
| Strikethrough | Not supported | Supported |
140+
| Footnotes | Not supported | Supported |
141+
142+
For complete syntax documentation, see:
143+
144+
- [RDoc Markup Reference](doc/markup_reference/rdoc.rdoc)
145+
- [Markdown Reference](doc/markup_reference/markdown.md)
146+
147+
### Directives
148+
149+
Comments can contain directives that tell RDoc information that it cannot otherwise discover through parsing. See RDoc::Markup@Directives to control what is or is not documented, to define method arguments or to break up methods in a class by topic. See RDoc::Parser::Ruby for directives used to teach RDoc about metaprogrammed methods.
86150

87151
See RDoc::Parser::C for documenting C extensions with RDoc.
88152

89-
To determine how well your project is documented run `rdoc -C lib` to get a documentation coverage report. `rdoc -C1 lib` includes parameter names in the documentation coverage report.
153+
### Documentation Coverage
154+
155+
To determine how well your project is documented run `rdoc -C lib` to get a documentation coverage report. `rdoc -C1 lib` includes parameter names in the documentation coverage report.
90156

91157
## Theme Options
92158

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require 'bundler/setup'
44
require 'rdoc'
55

66
# This is the easy way to prepare various kinds of RDoc objects.
7-
require_relative '../doc/rdoc/markup_reference'
7+
require_relative '../doc/rdoc/example'
88

99
require 'irb'
1010
IRB.start(__FILE__)

0 commit comments

Comments
 (0)