Commit graph

139 commits

Author SHA1 Message Date
Stan Lo
03eb777c69 Sync RDoc 6.14.0 2025-05-22 15:04:47 -07:00
Nobuyoshi Nakada
fef8ecc708 [ruby/rdoc] Enable cross reference in code
(https://github.com/ruby/rdoc/pull/1240)

Some people like to mark up method names in MarkDown style block
quotes, like this: ruby/ruby#12333.
Currently, no links are created in the code in the RDoc, but such
words most likely refer to methods.
This PR makes a word a code cross-reference if the whole word can be
resolved as a reference.

7d7efb0709
2024-12-17 21:48:31 +00:00
Soutaro Matsumoto
408f536890 [ruby/rdoc] aligns may include :center
(https://github.com/ruby/rdoc/pull/1247)

cbbf04d6f8
2024-12-17 20:56:24 +00:00
Stan Lo
a6fd6cb72f [ruby/rdoc] Print warnings for rdoc-ref links that can't be resolved
(https://github.com/ruby/rdoc/pull/1241)

4a5206ae56
2024-12-16 19:35:00 +00:00
nicholas a. evans
dd43af3be7 [ruby/rdoc] Use distinct styles for note lists and label lists
(https://github.com/ruby/rdoc/pull/1209)

* Use the original `label` description list style

As a default for all description lists, the original "label" style is
more readable.

This is slightly different from the original `label` dl though:
* slightly increased left margin for `dd` (to 1em)
* removed right margin on `dd`
* removed `dt` bottom margin and `dd` top margin, to reduce the gap
  between the term and its description (to only the standard line-height
  gap).

* Add closing tags for description list terms

Without the closing tags, the dt elements contain whitespace after the
text.  This normally isn't a big deal, but does mess some things up,
e.g: using `::after` with `content: ", "` in stylesheets.

* Restore float:left style for note lists

Unlike the original note list styles, this version sets the line-height
for all `dt` elements to be the same as the `p` elements contained
inside the `dd`, so that the second line has the same indentation as all
subsequent lines.

* Add commas between note list terms

9e69ea6d75
2024-12-08 10:43:47 +00:00
Stan Lo
2ecd2fe0ed [ruby/rdoc] Deprecate main and title directives
(https://github.com/ruby/rdoc/pull/1218)

* Deprecate :main: directive

* Deprecate :title: direcive

* Update documentation

* Remove :main: directive's usage

* Update test cases

* Add '.rdoc_options' to suggested alternatives

e2d4ac9dad
2024-12-05 11:36:34 +00:00
tomoya ishida
218445bb1f [ruby/rdoc] Fix ToRdoc#accept_table
(https://github.com/ruby/rdoc/pull/1184)

7b68545094
2024-10-03 12:27:43 +00:00
tomoya ishida
16b0242808 [ruby/rdoc] Add new ruby parser that uses Prism
(https://github.com/ruby/rdoc/pull/1144)

* Add a new ruby parser RDoc::Parser::PrismRuby

* Add a new ruby parser testcase independent from parser's internal implementation

* unknown meta method

* Use MethodSignatureVisitor only to scan params, block_params and calls_super

* Add calls_super test

* Drop ruby 2.6. Prism requires ruby >= 2.7

* Remove duplicated documentation comment from prism_ruby.rb

* Add test for wrong argument passed to metaprogramming method

* Rename visit_call_[DSL_METHOD_NAME] to make it distinguishable from visit_[NODE_TYPE]_node

* Method receiver switch of true/false/nil to a case statement

* Extract common part of add_method(by def keyword) and add meta_comment method

* Reuse consecutive comments array when collecting comments

* Simplify DSL call_node handling

* Refactor extracting method visibility arguments

fde99f1be6
2024-07-31 20:50:00 +00:00
Stan Lo
239d54dfbc [ruby/rdoc] Improve rubocop setup
(https://github.com/ruby/rdoc/pull/1139)

* Rename rake rubocop to rake format_generated_files

* Add rubocop rules to ensure spaces are applied consistently

* Improve rubocop related CI workflows

27932d001c
2024-07-17 20:43:08 +00:00
Hartley McGuire
5ac6194c2b [ruby/rdoc] Fix ToRdoc generating incorrect {label,name}-lists
Previously, trying to round-trip label-list and name-lists with the
ToRdoc converter was not possible:

```ruby
doc = <<~RDOC
foo ::
bar ::
  hi
RDOC

markup = RDoc::Markup.parse(doc)
markup # => [doc: [list: NOTE [item: ["foo ", "bar"]; [para: "hi"]]]]

rt = RDoc::Markup::ToRdoc.new.convert(markup)
rt # => "foo\nbar:\n  hi\n\n"

rt_markup = RDoc::Markup.parse(rt)
rt_markup # => [doc: [para: "foo ", "bar:"], [verb: "hi\n"]]
```

This commit addresses the issue by fixing ToRdoc to generate output that
can be properly reparsed by RDoc. ToRdoc tests additionally needed to be
updated for the new output.

The old implementation of `accept_list_item_start` was copied to ToBs
because those tests did not pass with the new changes and I am
unfamiliar with the `backspace` format.

After:

```ruby
doc = <<~RDOC
foo ::
bar ::
  hi
RDOC

markup = RDoc::Markup.parse(doc)
markup # => [doc: [list: NOTE [item: ["foo ", "bar"]; [para: "hi"]]]]

rt = RDoc::Markup::ToRdoc.new.convert(markup)
rt # => "foo::\nbar::\n  hi\n\n"

rt_markup = RDoc::Markup.parse(rt)
rt_markup # => [doc: [list: NOTE [item: ["foo", "bar"]; [para: "hi"], blankline]]]
```

c6c51aa900
2024-03-09 03:50:09 +00:00
Hartley McGuire
4756eaf5aa [ruby/rdoc] Fix ToMarkdown missing newlines for label-lists
Previously, using ToMarkdown on a label-list would generate output that
could not be reparsed by the RDoc::Markdown parser:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(md)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit\nbanana\n: a yellow fruit"]]]]
```

The issue is that the [PHP Markdown Extra spec][1] requires a newline
after each definition list item, but ToMarkdown was not putting newlines
between label-list items.

This commit fixes the issue by properly appending a newline after each
label-list item so that the output of ToMarkdown can be reparsed by
RDoc::Markdown:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(mdoc)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\n\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]
```

[1]: https://michelf.ca/projects/php-markdown/extra/#def-list

c65266437c
2024-03-08 10:13:04 +00:00
Nobuyoshi Nakada
569a06aa2f [ruby/rdoc] Allow empty name rdoc-ref as a local link
914a6af137
2023-12-31 15:19:50 +00:00
Nobuyoshi Nakada
20f4f00764 [ruby/rdoc] [DOC] nodoc for probably internal methods
f7dd147a8c
2023-12-16 00:26:39 +09:00
Nobuyoshi Nakada
e15d690db1 [ruby/rdoc] [DOC] Add missing documents
e4c90340d0
2023-12-16 00:26:37 +09:00
Nobuyoshi Nakada
196c4aeb76 [ruby/rdoc] Place a space between certain character class letters only
1f568e049d
2023-11-27 15:58:31 +00:00
Nobuyoshi Nakada
9935512275 [ruby/rdoc] Fix TIDYLINK after braces
(https://github.com/ruby/rdoc/pull/1015)

TIDYLINK multi-word label should not include braces.

41ad3191e9
2023-11-14 07:59:56 +00:00
Benoit Daloze
df5330b04e [ruby/rdoc] Use a more portable way to check if code is parseable
* The same as used in irb: https://github.com/ruby/irb/pull/134/files
* This works on all Ruby implementations, unlike `return` in BEGIN which
  can be quite difficult to support.

d19f7c66fe
2023-07-29 15:31:48 +00:00
Petrik
0c55ef1150 [ruby/rdoc] Use flat_map for better performance
76192a280d
2023-06-14 23:47:25 +00:00
Vinicius Stock
a4d92475f6 [ruby/rdoc] Auto-correct trailing new lines
4b68c0728a
2023-06-03 01:42:29 +00:00
Nobuyoshi Nakada
32cc6301b3 [ruby/rdoc] [DOC] stop documenting fallback MatchData#match_length
Also empty document of `Object`.

ce32a3102b
2023-05-02 17:06:36 +00:00
Nobuyoshi Nakada
5b1db79129 [ruby/rdoc] Revert "Refactor RDoc::Markup::Parser#tokenize"
This reverts commit 41ceae93b3.

5d2c47e8b8
2022-11-27 19:46:12 +00:00
Nobuyoshi Nakada
21977b95e2 [ruby/rdoc] Refactor RDoc::Markup::Parser#tokenize
Make verbatims text or newline only, and simplify `build_verbatim`.

41ceae93b3
2022-11-27 17:24:38 +00:00
Nobuyoshi Nakada
511864d1a7 [ruby/rdoc] Refine regexp usages and reduce substring allocations
a976fb9d39
2022-11-27 16:35:08 +00:00
Nobuyoshi Nakada
586e18b946 [ruby/rdoc] Escape HYPERLINKs
ac35485be6
2022-10-07 12:09:22 +09:00
Nobuyoshi Nakada
9e3ab9da7f [ruby/rdoc] Escape RDOCLINKs
https://hackerone.com/reports/1187156

7cecf1efae
2022-10-07 12:09:21 +09:00
Nobuyoshi Nakada
deaa656608 [ruby/rdoc] Escape TIDYLINKs
https://hackerone.com/reports/1187156

1ad2dd3ca2
2022-10-07 12:09:20 +09:00
Nobuyoshi Nakada
75a53f6be0 [ruby/rdoc] Allow RDoc markups in table cells
b16d3f1727
2022-10-06 18:24:44 +09:00
Nobuyoshi Nakada
af265d73fb [ruby/rdoc] Fix blockquote with word in verbatim
75eee668a5
2022-07-30 11:04:11 +09:00
Nobuyoshi Nakada
f29f1d22c3 [ruby/rdoc] Fix formatting blockquote in verbatim
Reported at https://github.com/ruby/rdoc/pull/907#discussion_r932505816

86384ac7f9
2022-07-29 09:21:33 +09:00
Nobuyoshi Nakada
5397dd2e76 [ruby/rdoc] Apply matching word pairs to underscore-methods
Protected characters with `PROTECT_ATTR` should not have special
roles.

c318af0ea2
2022-04-14 16:37:14 +09:00
Peter Zhu
aaac279de0 [ruby/rdoc] Only parse valid URLs
Only valid characters for URLs should be used for generating URLs.

A list of valid characters can be found in sections 2.2 and 2.3 of IETF
RFC 3986 (https://www.ietf.org/rfc/rfc3986.txt).

2bd8fcdd4f
2022-04-13 22:25:33 +09:00
Yusuke Endoh
ae8a8b184e [ruby/rdoc] Prefer require 'cgi/util' instead of require 'cgi'
RDoc is using only CGI.escape, escapeHTML, and unescape.
We don't have to load the whole source code of cgi gem.

d096222cc2
2022-02-22 17:08:52 +09:00
Nobuyoshi Nakada
8013250136 [ruby/rdoc] Simplify attribute exclusiveness conditions
45e33c4b85
2022-02-09 22:22:46 +09:00
Mike Dalessio
7aec65add4 [ruby/rdoc] feat: add support for :category: on C functions
45c92005fe
2021-10-16 01:39:36 +09:00
Nobuyoshi Nakada
3dacc14fd3 [ruby/rdoc] Fix links without paths
424bd5db4d
2021-07-05 11:34:37 +09:00
Nobuyoshi Nakada
f88a9097a4 [ruby/rdoc] Fix for explicit http link
caf234665c
2021-07-05 11:34:35 +09:00
Nobuyoshi Nakada
7c8aa0a5d2 [ruby/rdoc] Allow a label in a link to another document text
85bb2d33bb
2021-07-05 11:34:33 +09:00
Nobuyoshi Nakada
64b991b0cd [ruby/rdoc] Links to document texts without "rdoc-ref:" prefix
While links to generated HTML from RDoc file needs to be prefixed
by "rdoc-ref:" currently, in case of explicit references this
seems just redundant.

Also GitHub RDoc support does not work with this prefix.

This patch lets links to such document texts (".rb", ".rdoc" and
".md" now) refer URLs generated by `RDoc::TopLevel#http_url`
without the prefix.

f18b27b69d
2021-04-03 01:22:09 +09:00
aycabta
61e1cf23ac [ruby/rdoc] Treat emphasis tags as excluding other notations
And exclusive notations don't exclude other exclusive notations.

b8baa9a435
2021-04-03 01:21:50 +09:00
aycabta
e84d275fe6 [ruby/rdoc] Treat other tags as word boundaries
8222f85a17
2021-04-03 01:21:38 +09:00
aycabta
54aa11efa8 [ruby/rdoc] Disable other notations in <code> tags
0cd3b55210
2021-04-03 01:21:12 +09:00
Nobuyoshi Nakada
3651f678a7 [ruby/rdoc] Support GFM table
9dc933df16
2021-03-16 15:47:27 +09:00
Nobuyoshi Nakada
3198e7abd7
Separate send into public_send and __send__ 2020-10-27 16:12:45 +09:00
hyrious
02951a45f0 [ruby/rdoc] Create link to unary operator methods correctly
54500cf12a
2020-07-22 02:35:12 +09:00
aycabta
f52a4690f8 [ruby/rdoc] Process crossref before tidylink
The crossref must be linked before tidylink because Klass.method[:sym] will be
processed as a tidylink first and will be broken.

0f47baf6d2
2020-05-24 23:47:24 +09:00
Nate Matykiewicz
c79f9ea606 [ruby/rdoc] Escape method names in HTML
The following is invalid HTML:
<a href="Array.html#method-i-3C-3C"><code><<</code></a></p>

Incorrect:
<code><<</code>

Correct:
<code>&lt;&lt;</code>

Fixes #761

b120d087f6
2020-05-24 23:47:24 +09:00
Nobuyoshi Nakada
2b7409a2f2
Specify explicit separator not to be affected by $; 2020-03-08 17:38:37 +09:00
Yusuke Endoh
bc1e2271af lib/rdoc/markup/parser.rb: remove a unused variable initialization 2019-08-19 10:07:05 +09:00
Hiroshi SHIBATA
79fe84edf5 Removed test_case files from lib directory. 2019-08-17 20:20:04 +09:00
Hiroshi SHIBATA
e87e10e5e7 Use test/unit instead of test-unit. Because test-unit is only provided standalone gem. 2019-08-16 06:07:11 +09:00