rdoc-markdown 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8e35102f73fbebb99a831ca7e2210b41c065177ae7c637e86cffb61094560b7
4
- data.tar.gz: 44d35c36100b1488c2d5c5c689239b0d4ce6ae5f151fcc0ba3dec64f17cb97ac
3
+ metadata.gz: 35702d5815f56256651a8994111e772ee761a19a0df97052816431c15247b73b
4
+ data.tar.gz: 3720a080b24825ea96ea487d5b264dcbe2cf2f4c5e8ea25be677e9c54a0b0f4e
5
5
  SHA512:
6
- metadata.gz: c54de4099d5966da00719ef1fd7fafe9a9a15823d4e55e6b38489d32bacb366a9ee9b2ea1a8a85500bb8da29bd466bc00853cde0ad65c4f984e052652c35b52a
7
- data.tar.gz: c08fbcf88edcd97e665def817f22d56113885a37b77ad471f26dfd72e6485912641018c3ab46261e0d019a58d24f007a2c8a480e166c8533432bf9a642500e8a
6
+ metadata.gz: de2608fb5a61247ef9fd33153a8ab75bbfb21b9e3200078a1d59237340a0511cbee0866e90dce2d4a6d73408aed16bd2bb53e09f3e78118c083dd388b411c366
7
+ data.tar.gz: d5c8e5de4664c1300b8997c13948b296bd2ed39768396f5a5928cfea176f91130b51359f8ee982e24f2ef2a5284b10f53c2c4dbb6249d0e3726f9225a0e1212c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.0
6
+
7
+ ### Added
8
+ - Add `markdown_unknown_tags` RDoc option to configure reverse_markdown unknown tag handling
9
+
10
+ ### Changed
11
+ - Fail before generation when RDoc supplies a non-string output directory
12
+ - Markdown template will only include visible classes/module/methods, same as rdoc does with HTML templates
13
+
5
14
  ## 0.7.0
6
15
 
7
16
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdoc-markdown (0.7.0)
4
+ rdoc-markdown (0.8.0)
5
5
  csv
6
6
  erb
7
7
  rdoc
data/README.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # RDoc-Markdown
2
2
  RDoc plugin to generate markdown documentation and search index file (CSV).
3
3
 
4
+ > [!CAUTION]
5
+ > This gem relies on multiple hacks to generate "plausible" markdown documentation. This is **NOT PRODUCTION READY**, use at your own risk.
6
+ >
7
+ > rdoc maintainers are actively working on markdown support, things will improve with time...
8
+
4
9
  ## Motivation
5
- Markdown has become the de-facto documentation standard. I heavily rely on Obsidian to render my storage of markdown notes. But markdown is used not just for scribbles, supported is far and wide. We can render markdown file on any device, probably even on thermometer with a screen. But also everyone knows enough markdown to be dangerous (or productive).
10
+ Markdown has become the de-facto documentation standard. We can render markdown file on any device, possibly on thermometer with a screen. And everyone knows markdown...
6
11
 
7
- It's a pitty that rdoc and yard can't output a proper markdown file. I would like to change that.
12
+ It's a pitty that rdoc can't output a proper markdown file. Somebody has to try and build it.
8
13
 
9
14
  ## Installation
10
15
 
@@ -16,7 +21,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
21
 
17
22
  $ gem install rdoc-markdown
18
23
  ## Examples
19
- Find examples in [/examples](/example/) folder. You can regenerate examples by running `./bin/generate.sh`, it will produce examples based on file in `test/data/*` folder.
24
+ Find examples in [/example](/example/) folder. You can regenerate examples by running `./bin/generate.sh`; it produces the sample docs from `test/data/example.rb` and a pinned `jekyll-seo-tag` example from `vendor/jekyll-seo-tag`.
20
25
 
21
26
 
22
27
  ## Usage
@@ -28,6 +33,22 @@ Run following command in directory with ruby source code:
28
33
 
29
34
  This will produce a tree of markdown documents and search index in `/doc` folder. Every class in library will have it's own markdown file.
30
35
 
36
+ ### Unknown HTML tags
37
+ rdoc-markdown uses `reverse_markdown` to convert RDoc's HTML fragments to Markdown. You can configure how unknown HTML tags are handled with:
38
+
39
+ ```sh
40
+ rdoc --format=markdown --markdown-unknown-tags=raise
41
+ ```
42
+
43
+ Accepted values are `pass_through`, `drop`, `bypass`, and `raise`. The default is `pass_through`, which matches `reverse_markdown`'s default behavior.
44
+
45
+ The same setting can be stored in RDoc's `.rdoc_options` file:
46
+
47
+ ```yaml
48
+ ---
49
+ markdown_unknown_tags: :raise
50
+ ```
51
+
31
52
  ## Note on index.csv file
32
53
  This gem emits index of all markdown files in a index.csv file.
33
54
 
@@ -70,6 +91,7 @@ This task validates:
70
91
 
71
92
  - generated sample docs,
72
93
  - checked-in `example/` docs,
94
+ - generated `jekyll-seo-tag` docs,
73
95
  - vendored minitest docs,
74
96
  - vendored rails docs (Active Support, Active Record, Action Pack, Railties slices).
75
97
 
@@ -113,15 +135,17 @@ Use rake tasks to generate markdown output for vendored projects:
113
135
 
114
136
  ```
115
137
  rake vendor:setup
138
+ rake vendor:docs:jekyll_seo_tag
116
139
  rake vendor:docs:minitest
117
140
  rake vendor:docs:rails
118
- # or generate both
141
+ # or generate all
119
142
  rake vendor:docs
120
143
  ```
121
144
 
122
145
  Output is written to:
123
146
 
124
147
  - `vendor/docs/minitest`
148
+ - `vendor/docs/jekyll-seo-tag`
125
149
  - `vendor/docs/rails`
126
150
 
127
151
  ## Release
data/Rakefile CHANGED
@@ -5,6 +5,11 @@ require "rdoc/rdoc"
5
5
  require "rdoc/markdown"
6
6
  require_relative "test/support/markdown_validator"
7
7
 
8
+ JEKYLL_SEO_TAG_NAME = "jekyll-seo-tag"
9
+ JEKYLL_SEO_TAG_REF = "v2.8.0"
10
+ JEKYLL_SEO_TAG_TITLE = "#{JEKYLL_SEO_TAG_NAME} #{JEKYLL_SEO_TAG_REF.delete_prefix("v")}"
11
+ JEKYLL_SEO_TAG_VENDOR_PATH = "vendor/#{JEKYLL_SEO_TAG_NAME}"
12
+
8
13
  Rake::TestTask.new do |t|
9
14
  t.verbose = true
10
15
  t.warning = false
@@ -29,12 +34,7 @@ namespace :markdown do
29
34
  FileUtils.mkdir_p(validation_root)
30
35
 
31
36
  sample_output = File.join(validation_root, "sample")
32
- generate_markdown_docs(
33
- title: "sample",
34
- root: File.expand_path("test/data", __dir__),
35
- output: sample_output,
36
- files: [File.expand_path("test/data/example.rb", __dir__)]
37
- )
37
+ generate_sample_docs(output: sample_output)
38
38
 
39
39
  sample_count = MarkdownValidator.new(sample_output).validate!
40
40
  puts "Validated #{sample_count} markdown files in #{sample_output}"
@@ -59,6 +59,14 @@ namespace :markdown do
59
59
  puts "Validated #{minitest_count} markdown files in #{minitest_output}"
60
60
  puts "Skipped #{minitest_validator.unresolved_links} unresolved local links in vendored minitest docs"
61
61
 
62
+ Rake::Task["vendor:setup:jekyll_seo_tag"].invoke
63
+ jekyll_seo_tag_output = File.join(validation_root, JEKYLL_SEO_TAG_NAME)
64
+ generate_jekyll_seo_tag_docs(output: jekyll_seo_tag_output)
65
+ jekyll_seo_tag_validator = MarkdownValidator.new(jekyll_seo_tag_output, strict_links: strict_vendor_links)
66
+ jekyll_seo_tag_count = jekyll_seo_tag_validator.validate!
67
+ puts "Validated #{jekyll_seo_tag_count} markdown files in #{jekyll_seo_tag_output}"
68
+ puts "Skipped #{jekyll_seo_tag_validator.unresolved_links} unresolved local links in vendored jekyll-seo-tag docs"
69
+
62
70
  Rake::Task["vendor:setup:rails"].invoke
63
71
  rails_root = File.expand_path("vendor/rails", __dir__)
64
72
  rails_output = File.join(validation_root, "rails")
@@ -107,6 +115,56 @@ def generate_markdown_docs(title:, root:, output:, files:)
107
115
  RDoc::RDoc.new.document(options)
108
116
  end
109
117
 
118
+ def generate_sample_docs(output:)
119
+ generate_markdown_docs(
120
+ title: "sample",
121
+ root: File.expand_path("test/data", __dir__),
122
+ output: output,
123
+ files: [File.expand_path("test/data/example.rb", __dir__)]
124
+ )
125
+ end
126
+
127
+ def jekyll_seo_tag_root
128
+ File.expand_path(JEKYLL_SEO_TAG_VENDOR_PATH, __dir__)
129
+ end
130
+
131
+ def generate_jekyll_seo_tag_docs(output:)
132
+ root = jekyll_seo_tag_root
133
+ unless Dir.exist?(root)
134
+ raise "Missing #{JEKYLL_SEO_TAG_VENDOR_PATH}. Run `rake vendor:setup:jekyll_seo_tag` first."
135
+ end
136
+
137
+ generate_markdown_docs(
138
+ title: JEKYLL_SEO_TAG_TITLE,
139
+ root: root,
140
+ output: output,
141
+ files: Dir[File.join(root, "lib/**/*.rb")].uniq
142
+ )
143
+ end
144
+
145
+ namespace :examples do
146
+ desc "Generate checked-in example markdown docs"
147
+ task :generate do
148
+ Rake::Task["vendor:setup:jekyll_seo_tag"].invoke
149
+
150
+ sample_output = File.expand_path("example", __dir__)
151
+ staging_root = File.expand_path("tmp/examples-generate", __dir__)
152
+ staged_sample_output = File.join(staging_root, "example")
153
+
154
+ FileUtils.rm_rf(staging_root)
155
+ generate_sample_docs(output: staged_sample_output)
156
+ generate_jekyll_seo_tag_docs(output: File.join(staged_sample_output, JEKYLL_SEO_TAG_NAME))
157
+
158
+ FileUtils.rm_rf(sample_output)
159
+ FileUtils.mv(staged_sample_output, sample_output)
160
+
161
+ puts "Generated sample markdown docs in #{sample_output}"
162
+ puts "Generated #{JEKYLL_SEO_TAG_NAME} markdown docs in #{File.join(sample_output, JEKYLL_SEO_TAG_NAME)}"
163
+ ensure
164
+ FileUtils.rm_rf(staging_root) if staging_root
165
+ end
166
+ end
167
+
110
168
  def minitest_docs_files(root)
111
169
  files = Dir[File.join(root, "lib/**/*.rb")]
112
170
  files.concat(Dir[File.join(root, "*.rdoc")])
@@ -138,6 +196,19 @@ namespace :vendor do
138
196
  minitest_ref = "v6.0.1"
139
197
  rails_ref = ENV.fetch("RAILS_REF", "main")
140
198
 
199
+ desc "Clone/update vendor/jekyll-seo-tag and checkout docs-aligned tag"
200
+ task :jekyll_seo_tag do
201
+ ensure_git_checkout(
202
+ path: JEKYLL_SEO_TAG_VENDOR_PATH,
203
+ url: "https://github.com/jekyll/jekyll-seo-tag.git",
204
+ ref: JEKYLL_SEO_TAG_REF
205
+ )
206
+ Dir.chdir(JEKYLL_SEO_TAG_VENDOR_PATH) do
207
+ sh "git fetch --tags --force"
208
+ sh "git checkout #{JEKYLL_SEO_TAG_REF}"
209
+ end
210
+ end
211
+
141
212
  desc "Clone/update vendor/minitest and checkout docs-aligned tag"
142
213
  task :minitest do
143
214
  ensure_git_checkout(path: "vendor/minitest", url: "https://github.com/minitest/minitest.git", ref: minitest_ref)
@@ -151,9 +222,16 @@ namespace :vendor do
151
222
  end
152
223
 
153
224
  desc "Prepare all vendored repositories"
154
- task setup: ["vendor:setup:minitest", "vendor:setup:rails"]
225
+ task setup: ["vendor:setup:jekyll_seo_tag", "vendor:setup:minitest", "vendor:setup:rails"]
155
226
 
156
227
  namespace :docs do
228
+ desc "Generate markdown docs for vendored jekyll-seo-tag"
229
+ task :jekyll_seo_tag do
230
+ output = File.expand_path("vendor/docs/#{JEKYLL_SEO_TAG_NAME}", __dir__)
231
+ generate_jekyll_seo_tag_docs(output: output)
232
+ puts "Generated #{JEKYLL_SEO_TAG_NAME} markdown docs in #{output}"
233
+ end
234
+
157
235
  desc "Generate markdown docs for vendored minitest"
158
236
  task :minitest do
159
237
  root = File.expand_path("vendor/minitest", __dir__)
@@ -180,7 +258,7 @@ namespace :vendor do
180
258
  end
181
259
 
182
260
  desc "Generate markdown docs for all vendored repositories"
183
- task all: [:minitest, :rails]
261
+ task all: [:jekyll_seo_tag, :minitest, :rails]
184
262
  end
185
263
 
186
264
  desc "Generate markdown docs for all vendored repositories"
data/example/Bird.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Class Bird
2
- <a id="class-Bird"></a>
2
+ <a id="class-bird"></a>
3
3
 
4
4
  The base class for all birds.
5
5
 
data/example/Duck.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Class Duck
2
- <a id="class-Duck"></a>
2
+ <a id="class-duck"></a>
3
3
 
4
4
  A duck is a [`Waterfowl`](Waterfowl.md) [`Bird`](Bird.md).
5
5
 
data/example/Object.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Class Object
2
- <a id="class-Object"></a>
2
+ <a id="class-object"></a>
3
3
 
4
4
  ### Constants
5
5
 
data/example/Waterfowl.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Module Waterfowl
2
- <a id="module-Waterfowl"></a>
2
+ <a id="module-waterfowl"></a>
3
3
 
4
4
  A mixin for waterfowl creatures.
5
5
 
@@ -0,0 +1,40 @@
1
+ # Class Jekyll::SeoTag::AuthorDrop
2
+ <a id="class-jekyll-seotag-authordrop"></a>
3
+
4
+ A drop representing the current page’s author
5
+
6
+ Author name will be pulled from:
7
+
8
+ 1. The page’s `author` key
9
+
10
+ 2. The first author in the page’s `authors` key
11
+
12
+ 3. The `author` key in the site config
13
+
14
+ If the result from the name search is a string, we’ll also check for additional author metadata in `site.data.authors`
15
+
16
+ ### Public Class Methods
17
+
18
+ #### `new(page: nil, site: nil)`
19
+ <a id="method-c-new"></a>
20
+
21
+ Initialize a new [`AuthorDrop`](AuthorDrop.md)
22
+
23
+ page - The page hash (e.g., Page#to\_liquid) site - The Jekyll::Drops::SiteDrop
24
+
25
+ ### Public Instance Methods
26
+
27
+ #### `name()`
28
+ <a id="method-i-name"></a>
29
+
30
+ [`AuthorDrop#to_s`](AuthorDrop.md#method-i-to_s) should return name, allowing the author drop to safely replace `page.author`, if necessary, and remain backwards compatible
31
+
32
+ #### `to_s()`
33
+ <a id="method-i-to_s"></a>
34
+
35
+ Alias for: [`name`](#method-i-name)
36
+
37
+ #### `twitter()`
38
+ <a id="method-i-twitter"></a>
39
+
40
+ Not documented.
@@ -0,0 +1,133 @@
1
+ # Class Jekyll::SeoTag::Drop
2
+ <a id="class-jekyll-seotag-drop"></a>
3
+
4
+ ### Constants
5
+
6
+ #### `FORMAT_STRING_METHODS`
7
+ <a id="FORMAT_STRING_METHODS"></a>
8
+
9
+ Not documented.
10
+
11
+ #### `HOMEPAGE_OR_ABOUT_REGEX`
12
+ <a id="HOMEPAGE_OR_ABOUT_REGEX"></a>
13
+
14
+ Not documented.
15
+
16
+ #### `TITLE_SEPARATOR`
17
+ <a id="TITLE_SEPARATOR"></a>
18
+
19
+ Not documented.
20
+
21
+ ### Public Class Methods
22
+
23
+ #### `new(text, context)`
24
+ <a id="method-c-new"></a>
25
+
26
+ Not documented.
27
+
28
+ ### Public Instance Methods
29
+
30
+ #### `author()`
31
+ <a id="method-i-author"></a>
32
+
33
+ A drop representing the page author
34
+
35
+ #### `canonical_url()`
36
+ <a id="method-i-canonical_url"></a>
37
+
38
+ Not documented.
39
+
40
+ #### `date_modified()`
41
+ <a id="method-i-date_modified"></a>
42
+
43
+ Not documented.
44
+
45
+ #### `date_published()`
46
+ <a id="method-i-date_published"></a>
47
+
48
+ Not documented.
49
+
50
+ #### `description()`
51
+ <a id="method-i-description"></a>
52
+
53
+ Not documented.
54
+
55
+ #### `image()`
56
+ <a id="method-i-image"></a>
57
+
58
+ Returns a [`Drop`](Drop.md) representing the page’s image Returns nil if the image has no path, to preserve backwards compatability
59
+
60
+ #### `json_ld()`
61
+ <a id="method-i-json_ld"></a>
62
+
63
+ A drop representing the JSON-LD output
64
+
65
+ #### `links()`
66
+ <a id="method-i-links"></a>
67
+
68
+ Not documented.
69
+
70
+ #### `logo()`
71
+ <a id="method-i-logo"></a>
72
+
73
+ Not documented.
74
+
75
+ #### `name()`
76
+ <a id="method-i-name"></a>
77
+
78
+ rubocop:enable Metrics/CyclomaticComplexity
79
+
80
+ #### `page_lang()`
81
+ <a id="method-i-page_lang"></a>
82
+
83
+ Not documented.
84
+
85
+ #### `page_locale()`
86
+ <a id="method-i-page_locale"></a>
87
+
88
+ Not documented.
89
+
90
+ #### `page_title()`
91
+ <a id="method-i-page_title"></a>
92
+
93
+ Page title without site title or description appended
94
+
95
+ #### `site_description()`
96
+ <a id="method-i-site_description"></a>
97
+
98
+ Not documented.
99
+
100
+ #### `site_tagline()`
101
+ <a id="method-i-site_tagline"></a>
102
+
103
+ Not documented.
104
+
105
+ #### `site_tagline_or_description()`
106
+ <a id="method-i-site_tagline_or_description"></a>
107
+
108
+ Not documented.
109
+
110
+ #### `site_title()`
111
+ <a id="method-i-site_title"></a>
112
+
113
+ Not documented.
114
+
115
+ #### `title()`
116
+ <a id="method-i-title"></a>
117
+
118
+ Page title with site title or description appended rubocop:disable Metrics/CyclomaticComplexity
119
+
120
+ #### `title?()`
121
+ <a id="method-i-title-3F"></a>
122
+
123
+ Should the ‘\<title\>` tag be generated for this page?
124
+
125
+ #### `type()`
126
+ <a id="method-i-type"></a>
127
+
128
+ Not documented.
129
+
130
+ #### `version()`
131
+ <a id="method-i-version"></a>
132
+
133
+ Not documented.
@@ -0,0 +1,9 @@
1
+ # Class Jekyll::SeoTag::Filters
2
+ <a id="class-jekyll-seotag-filters"></a>
3
+
4
+ ### Public Class Methods
5
+
6
+ #### `new(context)`
7
+ <a id="method-c-new"></a>
8
+
9
+ Not documented.
@@ -0,0 +1,33 @@
1
+ # Class Jekyll::SeoTag::ImageDrop
2
+ <a id="class-jekyll-seotag-imagedrop"></a>
3
+
4
+ A drop representing the page image The image path will be pulled from:
5
+
6
+ 1. The `image` key if it’s a string
7
+
8
+ 2. The `image.path` key if it’s a hash
9
+
10
+ 3. The `image.facebook` key
11
+
12
+ 4. The `image.twitter` key
13
+
14
+ ### Public Class Methods
15
+
16
+ #### `new(page: nil, context: nil)`
17
+ <a id="method-c-new"></a>
18
+
19
+ Initialize a new [`ImageDrop`](ImageDrop.md)
20
+
21
+ page - The page hash (e.g., Page#to\_liquid) context - the Liquid::Context
22
+
23
+ ### Public Instance Methods
24
+
25
+ #### `path()`
26
+ <a id="method-i-path"></a>
27
+
28
+ Called path for backwards compatability, this is really the escaped, absolute URL representing the page’s image Returns nil if no image path can be determined
29
+
30
+ #### `to_s()`
31
+ <a id="method-i-to_s"></a>
32
+
33
+ Alias for: [`path`](#method-i-path)
@@ -0,0 +1,18 @@
1
+ # Module Jekyll::SeoTag::JSONLD
2
+ <a id="module-jekyll-seotag-jsonld"></a>
3
+
4
+ This module is deprecated, but is included in the Gem to avoid a breaking change and should be removed at the next major version bump
5
+
6
+ ### Constants
7
+
8
+ #### `METHODS_KEYS`
9
+ <a id="METHODS_KEYS"></a>
10
+
11
+ Not documented.
12
+
13
+ ### Public Instance Methods
14
+
15
+ #### `json_ld()`
16
+ <a id="method-i-json_ld"></a>
17
+
18
+ Self should be a [`Jekyll::SeoTag::Drop`](Drop.md) instance (when extending the module)
@@ -0,0 +1,41 @@
1
+ # Class Jekyll::SeoTag::JSONLDDrop
2
+ <a id="class-jekyll-seotag-jsonlddrop"></a>
3
+
4
+ ### Public Class Methods
5
+
6
+ #### `new(page_drop)`
7
+ <a id="method-c-new"></a>
8
+
9
+ page\_drop should be an instance of [`Jekyll::SeoTag::Drop`](Drop.md)
10
+
11
+ ### Public Instance Methods
12
+
13
+ #### `author()`
14
+ <a id="method-i-author"></a>
15
+
16
+ Not documented.
17
+
18
+ #### `fallback_data()`
19
+ <a id="method-i-fallback_data"></a>
20
+
21
+ Not documented.
22
+
23
+ #### `image()`
24
+ <a id="method-i-image"></a>
25
+
26
+ Not documented.
27
+
28
+ #### `mainEntityOfPage()`
29
+ <a id="method-i-mainEntityOfPage"></a>
30
+
31
+ Alias for: [`main_entity`](#method-i-main_entity)
32
+
33
+ #### `publisher()`
34
+ <a id="method-i-publisher"></a>
35
+
36
+ Not documented.
37
+
38
+ #### `to_json(state = nil)`
39
+ <a id="method-i-to_json"></a>
40
+
41
+ Returns a JSON-encoded object containing the JSON-LD data. Keys are sorted.
@@ -0,0 +1,5 @@
1
+ # Module Jekyll::SeoTag::UrlHelper
2
+ <a id="module-jekyll-seotag-urlhelper"></a>
3
+
4
+ Mixin to share common URL-related methods between class
5
+
@@ -0,0 +1,54 @@
1
+ # Class Jekyll::SeoTag
2
+ <a id="class-jekyll-seotag"></a>
3
+
4
+ ### Constants
5
+
6
+ #### `MINIFY_REGEX`
7
+ <a id="MINIFY_REGEX"></a>
8
+
9
+ Matches all whitespace that follows either
10
+
11
+ ```
12
+ 1. A '}', which closes a Liquid tag
13
+ 2. A '{', which opens a JSON block
14
+ 3. A '>' followed by a newline, which closes an XML tag or
15
+ 4. A ',' followed by a newline, which ends a JSON line
16
+ ```
17
+
18
+ We will strip all of this whitespace to minify the template We will not strip any whitespace if the next character is a ‘-’
19
+
20
+ ```
21
+ so that we do not interfere with the HTML comment at the
22
+ very begining
23
+ ```
24
+
25
+ #### `VERSION`
26
+ <a id="VERSION"></a>
27
+
28
+ Not documented.
29
+
30
+ ### Attributes
31
+
32
+ #### `context` [RW]
33
+ <a id="attribute-i-context"></a>
34
+
35
+ Not documented.
36
+
37
+ ### Public Class Methods
38
+
39
+ #### `new(_tag_name, text, _tokens)`
40
+ <a id="method-c-new"></a>
41
+
42
+ Not documented.
43
+
44
+ #### `template()`
45
+ <a id="method-c-template"></a>
46
+
47
+ Not documented.
48
+
49
+ ### Public Instance Methods
50
+
51
+ #### `render(context)`
52
+ <a id="method-i-render"></a>
53
+
54
+ Not documented.
@@ -0,0 +1,3 @@
1
+ # Module Jekyll
2
+ <a id="module-jekyll"></a>
3
+
@@ -0,0 +1,3 @@
1
+ # Class Liquid::Tag
2
+ <a id="class-liquid-tag"></a>
3
+
@@ -0,0 +1,5 @@
1
+ # Module Liquid
2
+ <a id="module-liquid"></a>
3
+
4
+ Prevent bundler errors
5
+
@@ -0,0 +1,60 @@
1
+ name,type,path
2
+ Jekyll,Module,Jekyll.md
3
+ Jekyll::SeoTag,Class,Jekyll/SeoTag.md
4
+ Jekyll::SeoTag.new,Method,Jekyll/SeoTag.md#method-c-new
5
+ Jekyll::SeoTag.render,Method,Jekyll/SeoTag.md#method-i-render
6
+ Jekyll::SeoTag.template,Method,Jekyll/SeoTag.md#method-c-template
7
+ Jekyll::SeoTag.MINIFY_REGEX,Constant,Jekyll/SeoTag.md#MINIFY_REGEX
8
+ Jekyll::SeoTag.VERSION,Constant,Jekyll/SeoTag.md#VERSION
9
+ Jekyll::SeoTag.context,Attribute,Jekyll/SeoTag.md#attribute-i-context
10
+ Jekyll::SeoTag::AuthorDrop,Class,Jekyll/SeoTag/AuthorDrop.md
11
+ Jekyll::SeoTag::AuthorDrop.new,Method,Jekyll/SeoTag/AuthorDrop.md#method-c-new
12
+ Jekyll::SeoTag::AuthorDrop.name,Method,Jekyll/SeoTag/AuthorDrop.md#method-i-name
13
+ Jekyll::SeoTag::AuthorDrop.to_s,Method,Jekyll/SeoTag/AuthorDrop.md#method-i-to_s
14
+ Jekyll::SeoTag::AuthorDrop.twitter,Method,Jekyll/SeoTag/AuthorDrop.md#method-i-twitter
15
+ Jekyll::SeoTag::Drop,Class,Jekyll/SeoTag/Drop.md
16
+ Jekyll::SeoTag::Drop.new,Method,Jekyll/SeoTag/Drop.md#method-c-new
17
+ Jekyll::SeoTag::Drop.version,Method,Jekyll/SeoTag/Drop.md#method-i-version
18
+ Jekyll::SeoTag::Drop.title?,Method,Jekyll/SeoTag/Drop.md#method-i-title-3F
19
+ Jekyll::SeoTag::Drop.site_title,Method,Jekyll/SeoTag/Drop.md#method-i-site_title
20
+ Jekyll::SeoTag::Drop.site_tagline,Method,Jekyll/SeoTag/Drop.md#method-i-site_tagline
21
+ Jekyll::SeoTag::Drop.site_description,Method,Jekyll/SeoTag/Drop.md#method-i-site_description
22
+ Jekyll::SeoTag::Drop.page_title,Method,Jekyll/SeoTag/Drop.md#method-i-page_title
23
+ Jekyll::SeoTag::Drop.site_tagline_or_description,Method,Jekyll/SeoTag/Drop.md#method-i-site_tagline_or_description
24
+ Jekyll::SeoTag::Drop.title,Method,Jekyll/SeoTag/Drop.md#method-i-title
25
+ Jekyll::SeoTag::Drop.name,Method,Jekyll/SeoTag/Drop.md#method-i-name
26
+ Jekyll::SeoTag::Drop.description,Method,Jekyll/SeoTag/Drop.md#method-i-description
27
+ Jekyll::SeoTag::Drop.author,Method,Jekyll/SeoTag/Drop.md#method-i-author
28
+ Jekyll::SeoTag::Drop.json_ld,Method,Jekyll/SeoTag/Drop.md#method-i-json_ld
29
+ Jekyll::SeoTag::Drop.image,Method,Jekyll/SeoTag/Drop.md#method-i-image
30
+ Jekyll::SeoTag::Drop.date_modified,Method,Jekyll/SeoTag/Drop.md#method-i-date_modified
31
+ Jekyll::SeoTag::Drop.date_published,Method,Jekyll/SeoTag/Drop.md#method-i-date_published
32
+ Jekyll::SeoTag::Drop.type,Method,Jekyll/SeoTag/Drop.md#method-i-type
33
+ Jekyll::SeoTag::Drop.links,Method,Jekyll/SeoTag/Drop.md#method-i-links
34
+ Jekyll::SeoTag::Drop.logo,Method,Jekyll/SeoTag/Drop.md#method-i-logo
35
+ Jekyll::SeoTag::Drop.page_lang,Method,Jekyll/SeoTag/Drop.md#method-i-page_lang
36
+ Jekyll::SeoTag::Drop.page_locale,Method,Jekyll/SeoTag/Drop.md#method-i-page_locale
37
+ Jekyll::SeoTag::Drop.canonical_url,Method,Jekyll/SeoTag/Drop.md#method-i-canonical_url
38
+ Jekyll::SeoTag::Drop.FORMAT_STRING_METHODS,Constant,Jekyll/SeoTag/Drop.md#FORMAT_STRING_METHODS
39
+ Jekyll::SeoTag::Drop.HOMEPAGE_OR_ABOUT_REGEX,Constant,Jekyll/SeoTag/Drop.md#HOMEPAGE_OR_ABOUT_REGEX
40
+ Jekyll::SeoTag::Drop.TITLE_SEPARATOR,Constant,Jekyll/SeoTag/Drop.md#TITLE_SEPARATOR
41
+ Jekyll::SeoTag::Filters,Class,Jekyll/SeoTag/Filters.md
42
+ Jekyll::SeoTag::Filters.new,Method,Jekyll/SeoTag/Filters.md#method-c-new
43
+ Jekyll::SeoTag::ImageDrop,Class,Jekyll/SeoTag/ImageDrop.md
44
+ Jekyll::SeoTag::ImageDrop.new,Method,Jekyll/SeoTag/ImageDrop.md#method-c-new
45
+ Jekyll::SeoTag::ImageDrop.path,Method,Jekyll/SeoTag/ImageDrop.md#method-i-path
46
+ Jekyll::SeoTag::ImageDrop.to_s,Method,Jekyll/SeoTag/ImageDrop.md#method-i-to_s
47
+ Jekyll::SeoTag::JSONLD,Module,Jekyll/SeoTag/JSONLD.md
48
+ Jekyll::SeoTag::JSONLD.json_ld,Method,Jekyll/SeoTag/JSONLD.md#method-i-json_ld
49
+ Jekyll::SeoTag::JSONLD.METHODS_KEYS,Constant,Jekyll/SeoTag/JSONLD.md#METHODS_KEYS
50
+ Jekyll::SeoTag::JSONLDDrop,Class,Jekyll/SeoTag/JSONLDDrop.md
51
+ Jekyll::SeoTag::JSONLDDrop.new,Method,Jekyll/SeoTag/JSONLDDrop.md#method-c-new
52
+ Jekyll::SeoTag::JSONLDDrop.fallback_data,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-fallback_data
53
+ Jekyll::SeoTag::JSONLDDrop.author,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-author
54
+ Jekyll::SeoTag::JSONLDDrop.image,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-image
55
+ Jekyll::SeoTag::JSONLDDrop.publisher,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-publisher
56
+ Jekyll::SeoTag::JSONLDDrop.mainEntityOfPage,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-mainEntityOfPage
57
+ Jekyll::SeoTag::JSONLDDrop.to_json,Method,Jekyll/SeoTag/JSONLDDrop.md#method-i-to_json
58
+ Jekyll::SeoTag::UrlHelper,Module,Jekyll/SeoTag/UrlHelper.md
59
+ Liquid,Module,Liquid.md
60
+ Liquid::Tag,Class,Liquid/Tag.md
@@ -6,6 +6,7 @@ require "erb"
6
6
  require "reverse_markdown"
7
7
  require "csv"
8
8
  require "cgi"
9
+ require "optparse"
9
10
 
10
11
  # Generates Markdown output and a CSV search index from an RDoc store.
11
12
  class RDoc::Generator::Markdown
@@ -14,6 +15,67 @@ class RDoc::Generator::Markdown
14
15
  # Directory containing ERB templates.
15
16
  TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "templates"))
16
17
 
18
+ # Supported reverse_markdown unknown-tag modes.
19
+ MARKDOWN_UNKNOWN_TAGS = %i[pass_through drop bypass raise].freeze
20
+
21
+ # Adds rdoc-markdown generator configuration to RDoc's option object.
22
+ module OptionsExtension
23
+ # Initializes markdown generator options alongside RDoc's built-in options.
24
+ #
25
+ # @return [void]
26
+ def init_ivars
27
+ super
28
+ @markdown_unknown_tags = :pass_through
29
+ end
30
+
31
+ # Loads markdown generator options from serialized RDoc options.
32
+ #
33
+ # @param map [Psych::Coder] Serialized RDoc options.
34
+ #
35
+ # @return [void]
36
+ def init_with(map)
37
+ super
38
+ @markdown_unknown_tags = map["markdown_unknown_tags"] if map.map.key?("markdown_unknown_tags")
39
+ end
40
+
41
+ # Applies markdown generator options from a loaded .rdoc_options hash.
42
+ #
43
+ # @param map [Hash] Loaded RDoc options.
44
+ #
45
+ # @return [void]
46
+ def override(map)
47
+ super
48
+ @markdown_unknown_tags = map.fetch("markdown_unknown_tags") if map.key?("markdown_unknown_tags")
49
+ end
50
+ end
51
+
52
+ # Registers markdown generator-specific RDoc options.
53
+ #
54
+ # @param rdoc_options [RDoc::Options] RDoc options object.
55
+ #
56
+ # @return [void]
57
+ def self.setup_options(rdoc_options)
58
+ rdoc_options.option_parser.on(
59
+ "--markdown-unknown-tags=MODE",
60
+ "How to handle unknown HTML tags: #{MARKDOWN_UNKNOWN_TAGS.join(", ")}."
61
+ ) do |value|
62
+ rdoc_options.markdown_unknown_tags = value.to_sym
63
+ end
64
+ end
65
+
66
+ # Validates the configured reverse_markdown unknown-tag mode.
67
+ #
68
+ # @param value [Symbol] Unknown-tag mode.
69
+ #
70
+ # @return [Symbol] Validated unknown-tag mode.
71
+ def self.validate_markdown_unknown_tags(value)
72
+ return value if MARKDOWN_UNKNOWN_TAGS.include?(value)
73
+
74
+ expected = MARKDOWN_UNKNOWN_TAGS.map { |mode| ":#{mode}" }.join(", ")
75
+ raise OptionParser::InvalidArgument,
76
+ "invalid markdown_unknown_tags: #{value.inspect} (expected one of: #{expected})"
77
+ end
78
+
17
79
  # Source store for generated content.
18
80
  #
19
81
  # @return [RDoc::Store]
@@ -50,6 +112,7 @@ class RDoc::Generator::Markdown
50
112
  def initialize(store, rdoc_options)
51
113
  @store = store
52
114
  @options = rdoc_options
115
+ @markdown_unknown_tags = self.class.validate_markdown_unknown_tags(rdoc_options.markdown_unknown_tags)
53
116
 
54
117
  @base_dir = Pathname.pwd
55
118
  end
@@ -252,7 +315,7 @@ class RDoc::Generator::Markdown
252
315
 
253
316
  html = normalize_rdoc_pre_blocks(input)
254
317
 
255
- md = ReverseMarkdown.convert(html, github_flavored: true)
318
+ md = ReverseMarkdown.convert(html, github_flavored: true, unknown_tags: @markdown_unknown_tags).dup
256
319
 
257
320
  # Flatten headings whose visible text is wrapped in a self-link.
258
321
  md.gsub!(/^(#+)\s\[([^\]]+)\]\((?:#[^)]+)\)$/) { "#{Regexp.last_match(1)} #{Regexp.last_match(2)}" }
@@ -636,7 +699,7 @@ class RDoc::Generator::Markdown
636
699
  def build_class_docs(classes)
637
700
  docs_by_name = {}
638
701
 
639
- classes.each do |klass|
702
+ classes.select(&:display?).each do |klass|
640
703
  display_name = normalized_full_name(klass.full_name)
641
704
  output_path = turn_to_path(display_name)
642
705
  legacy_path = turn_to_path(klass.full_name)
@@ -666,9 +729,11 @@ class RDoc::Generator::Markdown
666
729
 
667
730
  docs_by_name.values
668
731
  .select do |doc|
732
+ klass = doc.fetch(:klass)
733
+
669
734
  doc.fetch(:score).positive? ||
670
- !synthetic_full_name?(doc.fetch(:klass).full_name)
671
- end
735
+ (!class_has_raw_members?(klass) && !synthetic_full_name?(klass.full_name))
736
+ end
672
737
  .sort_by { |doc| doc.fetch(:display_name) }
673
738
  end
674
739
 
@@ -695,17 +760,35 @@ class RDoc::Generator::Markdown
695
760
  normalized
696
761
  end
697
762
 
698
- # Scores how much visible content a class or module has.
763
+ # Scores how much owned content a class or module has.
699
764
  #
700
765
  # @param klass [RDoc::Context] Class or module object.
701
766
  #
702
767
  # @return [Integer] Content score used to choose duplicate docs.
703
768
  def class_content_score(klass)
704
- score = klass.method_list.size + klass.constants.size + klass.attributes.size
769
+ score = class_member_count(klass)
705
770
  score += 1 unless klass.description.empty?
706
771
  score
707
772
  end
708
773
 
774
+ # Counts methods, constants, and attributes owned by a class or module.
775
+ #
776
+ # @param klass [RDoc::Context] Class or module object.
777
+ #
778
+ # @return [Integer] Number of owned members.
779
+ def class_member_count(klass)
780
+ klass.method_list.count(&:display?) + klass.constants.count(&:display?) + klass.attributes.count(&:display?)
781
+ end
782
+
783
+ # Checks whether a class or module owns any members before display filtering.
784
+ #
785
+ # @param klass [RDoc::Context] Class or module object.
786
+ #
787
+ # @return [Boolean] True when any owned member exists before display filtering.
788
+ def class_has_raw_members?(klass)
789
+ klass.method_list.any? || klass.constants.any? || klass.attributes.any?
790
+ end
791
+
709
792
  # Checks whether a name appears to contain duplicated root namespaces.
710
793
  #
711
794
  # @param full_name [String] Full RDoc object name.
@@ -722,6 +805,9 @@ class RDoc::Generator::Markdown
722
805
  # @return [void]
723
806
  def setup
724
807
  @output_dir = @options.op_dir
808
+ unless @output_dir.instance_of?(String)
809
+ raise TypeError, "RDoc markdown output directory must be a String"
810
+ end
725
811
 
726
812
  @class_docs = build_class_docs(@store.all_classes_and_modules.sort)
727
813
  @class_docs_by_object_id = @class_docs.to_h { |doc| [doc.fetch(:klass).object_id, doc] }
@@ -738,3 +824,13 @@ class RDoc::Generator::Markdown
738
824
  @root_path_segment = Pathname.new(@options.root || ".").basename
739
825
  end
740
826
  end
827
+
828
+ # RDoc configuration extended with markdown generator options.
829
+ class RDoc::Options
830
+ prepend RDoc::Generator::Markdown::OptionsExtension
831
+
832
+ # Controls how reverse_markdown handles unknown HTML tags.
833
+ #
834
+ # @return [Symbol]
835
+ attr_accessor :markdown_unknown_tags
836
+ end
@@ -5,6 +5,6 @@ module Rdoc
5
5
  # Version namespace for rdoc-markdown.
6
6
  module Markdown
7
7
  # Current gem version.
8
- VERSION = "0.7.0"
8
+ VERSION = "0.8.0"
9
9
  end
10
10
  end
@@ -41,6 +41,7 @@
41
41
  <%- end -%>
42
42
  <% klass.methods_by_type(section).each do |type, visibilities| -%>
43
43
  <% visibilities.each do |visibility, methods| -%>
44
+ <% methods = methods.select(&:display?) -%>
44
45
  <% next if methods.empty? -%>
45
46
 
46
47
  ### <%= visibility.capitalize %> <%= type.capitalize %> Methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
@@ -190,6 +190,18 @@ files:
190
190
  - example/Object.md
191
191
  - example/Waterfowl.md
192
192
  - example/index.csv
193
+ - example/jekyll-seo-tag/Jekyll.md
194
+ - example/jekyll-seo-tag/Jekyll/SeoTag.md
195
+ - example/jekyll-seo-tag/Jekyll/SeoTag/AuthorDrop.md
196
+ - example/jekyll-seo-tag/Jekyll/SeoTag/Drop.md
197
+ - example/jekyll-seo-tag/Jekyll/SeoTag/Filters.md
198
+ - example/jekyll-seo-tag/Jekyll/SeoTag/ImageDrop.md
199
+ - example/jekyll-seo-tag/Jekyll/SeoTag/JSONLD.md
200
+ - example/jekyll-seo-tag/Jekyll/SeoTag/JSONLDDrop.md
201
+ - example/jekyll-seo-tag/Jekyll/SeoTag/UrlHelper.md
202
+ - example/jekyll-seo-tag/Liquid.md
203
+ - example/jekyll-seo-tag/Liquid/Tag.md
204
+ - example/jekyll-seo-tag/index.csv
193
205
  - gemfiles/rdoc_head.gemfile
194
206
  - lib/markdown.rb
195
207
  - lib/rdoc/discover.rb