Skip to content

Commit 4d82c45

Browse files
committed
Implement hybrid rdoc/markdown markup renderer
1 parent fbad6e6 commit 4d82c45

14 files changed

Lines changed: 7296 additions & 61 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# main
22

33
- Add support for Ruby .rbs files (docstrings included)
4+
- Add built-in hybrid RDoc/Markdown renderer (`HybridMarkdown`) requiring no external gems
45
- Add support for `#-` as a comment-block separator. See Getting Started Guide.
56
- Fix false self-referential mixin when bare name matches ancestor namespace (#1672)
67
- Fix bracket/brace map corruption from Ruby 3.0+ pattern matching deconstruction (#1671)

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ summary of some of YARD's notable features.
1919

2020
## Feature List
2121

22-
**1. RDoc/SimpleMarkup Formatting Compatibility**: YARD is made to be compatible
23-
with RDoc formatting. In fact, YARD does no processing on RDoc documentation
24-
strings, and leaves this up to the output generation tool to decide how to
25-
render the documentation.
22+
**1. Builtin RDoc/Markdown Hybrid Support**: YARD ships with a builtin markup
23+
renderer that supports both RDoc and Markdown formatting out of the box—no
24+
external gem required. You can freely mix RDoc-style and Markdown-style
25+
documentation without installing any additional libraries.
2626

2727
**2. Yardoc Meta-tag Formatting Like Python, Java, Objective-C and other
2828
languages**: YARD uses a '@tag' style definition syntax for meta tags alongside
@@ -114,20 +114,17 @@ $ gem install yard
114114
Alternatively, if you've checked the source out directly, you can call
115115
`rake install` from the root project directory.
116116

117-
**Important Note for Debian/Ubuntu users:** there's a possible chance your Ruby
118-
install lacks RDoc, which is occasionally used by YARD to convert markup to
119-
HTML. If running `which rdoc` turns up empty, install RDoc by issuing:
117+
### Markup rendering
120118

121-
```sh
122-
$ sudo apt-get install rdoc
123-
```
124-
125-
### Markdown parser
119+
YARD includes a builtin renderer that handles both RDoc and Markdown markup
120+
types without any external dependencies. To switch the default markup type,
121+
pass `-m markdown` (or `-m rdoc`) to `yard doc`, or add it to your `.yardopts`
122+
file.
126123

127-
When rendering markdown, yard will use one of several possible markdown providers,
128-
[in order of priority](https://github.com/lsegal/yard/blob/e833aac7a01510245dd4ae1d1d18b046c8293c2d/lib/yard/templates/helpers/markup_helper.rb#L26-L33).
129-
If you are experiencing rendering bugs (example [1](https://github.com/lsegal/yard/issues/1410) [2](https://github.com/lsegal/yard/issues/1543)), try adding one of the
130-
gems further up in the list to your Gemfile.
124+
For optional extra rendering features (e.g. GitHub-Flavoured Markdown fenced
125+
code blocks, tables, or specific Markdown extensions), you can install an
126+
additional provider gem such as `redcarpet`, `commonmarker`, or `kramdown` and
127+
select it explicitly with `-M PROVIDER` (e.g. `yard doc -m markdown -M redcarpet`).
131128

132129
## Usage
133130

docs/GettingStarted.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ YARD treats it as a normal comment line and it remains part of the docstring.
8585

8686
## Which Markup Format?
8787

88-
YARD does not impose a specific markup. The above example uses standard RDoc
89-
markup formatting, but YARD also supports textile and markdown via the
90-
command-line switch or `.yardopts` file (see below). This means that you are
91-
free to use whatever formatting you like. This guide is actually written
92-
using markdown. YARD, however, does add a few important syntaxes that are
93-
processed no matter which markup formatting you use, such as tag support
94-
and inter-document linking. These syntaxes are discussed below.
88+
YARD does not impose a specific markup format. YARD ships with a builtin
89+
renderer that supports both RDoc and Markdown out of the box—no external gem
90+
required. You can use either format (or switch between them) without installing
91+
anything extra. YARD also supports textile, asciidoc, and other formats via
92+
optional gems.
93+
94+
To select a markup format, use the command-line switch `-m FORMAT` or add
95+
`--markup FORMAT` to your `.yardopts` file. This guide is written in Markdown.
96+
YARD adds a few important syntaxes that are processed regardless of which
97+
markup format you choose, such as tag support and inter-document linking.
98+
These syntaxes are discussed below.
9599

96100
## Adding Tags to Documentation
97101

docs/WhatsNew.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66

77
YARD now supports parsing Ruby signature files (.rbs) with full docstring support. This means you can write your documentation in `.rbs` files and have it show up in generated documentation, and use `.rbs` files alongside `.rb` sources to supplement type and API information.
88

9+
## New built-in Markdown renderer (0.9.40)
10+
11+
YARD now ships with a built-in Markdown renderer (`YARD::Templates::Helpers::Markup::HybridMarkdown`)
12+
that requires **no external gems**. It supports a practical subset of GitHub Flavored Markdown (GFM)
13+
as well as common RDoc markup forms, including:
14+
15+
- ATX and setext headings (`#`, `=`)
16+
- Fenced code blocks (`` ``` `` and `~~~`) as well as RDoc formatted `+text+` blocks.
17+
- Tables, blockquotes, and thematic breaks
18+
- Ordered and unordered lists (including RDoc-style)
19+
- Inline emphasis, code, links, and images
20+
- HTML passthrough blocks
21+
22+
This renderer is the **default** for both the `rdoc` and `markdown` markup types—no gem
23+
installation required. If an optional provider gem (e.g. `redcarpet`, `kramdown`,
24+
`commonmarker`) is installed and selected, YARD will use it instead for extra features such
25+
as custom extensions or stricter spec compliance.
26+
927
## `#-` comment block separators (0.9.40)
1028

1129
YARD now recognizes a trailing `#-` line as a separator between comment

lib/yard/autoload.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ module Tags # Namespace for Tag components
287287
module Templates
288288
module Helpers # Namespace for template helpers
289289
module Markup # Namespace for markup providers
290+
autoload :HybridMarkdown, __p('templates/helpers/markup/hybrid_markdown')
290291
autoload :RDocMarkup, __p('templates/helpers/markup/rdoc_markup')
291292
autoload :RDocMarkdown, __p('templates/helpers/markup/rdoc_markdown')
292293
end

0 commit comments

Comments
 (0)