yard-fence 0.1.0 → 0.3.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: 19c452cadbc7138751c282b00e156b13a181a6dde7de5ea94b9a11f2e4b2cd8b
4
- data.tar.gz: 82255194452e4fd285fc1c48b72daf6c6a4d3d3a0a628d237e7ec4e2c3a50bc1
3
+ metadata.gz: 5baded4374cd088861f834e9979c206e08dac16af4c52fdbf3d28ea1e7ce8c58
4
+ data.tar.gz: bf14fe77229b435e7361883d6dd6128bcff08f58ed8a7742fb88eb9223148a2d
5
5
  SHA512:
6
- metadata.gz: 81831151e5e12a8cab9fde1c590ba09c3b10a45e49fadb47565827f30aaca3eec7494d2005ff7a6d97a16a20d6cc74e93b8ad1fceb7b766d7e31a62bbf2f692f
7
- data.tar.gz: 8b46e712c8705da88215adc176afe5e3d908ace26d0ecc2e8303150091042420bbf60907a29e477d58caa061531df84fdc9c237609f10b0dd529c4be6622d179
6
+ metadata.gz: 0c10875a2282e3e6613bdc39bcf37b5aa3507489a5f94406ded819765e3a9feb3ab1581c8a9a3e9c4b11e22564bafb0c7f137db6f7f038248e4d59827080cbdf
7
+ data.tar.gz: fae576e37e8f9c840bb5e6c772cfdfa7e8eb5e3a065ae9c3deda8d23860595a6827f52f529ae7d12944be2321d4fe0a74753e752505b8b2574a4df49704f1803
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,40 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.3.0] - 2025-11-07
34
+
35
+ - TAG: [v0.3.0][0.3.0t]
36
+ - COVERAGE: 96.43% -- 81/84 lines in 4 files
37
+ - BRANCH COVERAGE: 93.75% -- 15/16 branches in 4 files
38
+ - 29.17% documented
39
+
40
+ ### Added
41
+
42
+ - yard/fence/hoist.rb: Hoisting the customized GFM kramdown parser
43
+
44
+ ## [0.2.0] - 2025-11-07
45
+
46
+ - TAG: [v0.2.0][0.2.0t]
47
+ - COVERAGE: 96.43% -- 81/84 lines in 4 files
48
+ - BRANCH COVERAGE: 93.75% -- 15/16 branches in 4 files
49
+ - 29.17% documented
50
+
51
+ ### Added
52
+
53
+ - Up to 96% lines / 93% branches test coverage
54
+
55
+ ### Fixed
56
+
57
+ - handling of optional dependencies
58
+ - kramdown
59
+ - kramdown-parser-gfm
60
+
33
61
  ## [0.1.0] - 2025-11-06
34
62
 
35
63
  - Initial release
64
+
65
+ [Unreleased]: https://github.com/galtzo-floss/yard-fence/compare/v0.3.0...HEAD
66
+ [0.3.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.2.0...v0.3.0
67
+ [0.3.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.3.0
68
+ [0.2.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.1.0...v0.2.0
69
+ [0.2.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.2.0
data/README.md CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  ## 🌻 Synopsis
50
50
 
51
- A brace converter for the markdown fences in your YARD docs.
51
+ A brace converter for the markdown fences in your YARD docs to prevent the `InvalidLink` warning.
52
52
 
53
53
  Just the important bits:
54
54
  - Preprocesses top-level README and other `.md`/`.txt` files into `tmp/` replacing ASCII braces inside fenced code blocks, inline code spans, and simple placeholders like `{issuer}` or `{{TOKEN}}` with visually identical fullwidth braces.
@@ -56,6 +56,22 @@ Just the important bits:
56
56
  - Prioritizes Kramdown's GFM parser so tables and fenced code blocks render correctly.
57
57
  - After YARD finishes generating HTML, restores fullwidth braces back to normal ASCII braces so code examples are copy‑pastable.
58
58
 
59
+ Create a `.yardopts` file like this:
60
+
61
+ ```text
62
+ --plugin fence
63
+ -e yard/fence/hoist.rb
64
+ --readme tmp/README.md
65
+ --markup markdown
66
+ --output docs
67
+ 'lib/**/*.rb'
68
+ -
69
+ 'tmp/*.md'
70
+ 'tmp/*.txt'
71
+ ```
72
+
73
+ See the configuration and usage sections for more details.
74
+
59
75
  ## 💡 Info you can shake a stick at
60
76
 
61
77
  | Tokens to Remember | [![Gem name][⛳️name-img]][⛳️gem-name] [![Gem namespace][⛳️namespace-img]][⛳️gem-namespace] |
@@ -175,7 +191,7 @@ Recommended .yardopts (noise‑free):
175
191
 
176
192
  ```text
177
193
  --plugin fence
178
- -e 'Yard::Fence.use_kramdown_gfm!'
194
+ -e yard/fence/hoist.rb
179
195
  --readme tmp/README.md
180
196
  --markup markdown
181
197
  --output docs
@@ -195,7 +211,7 @@ CLI example that would be similar to what is accomplished by the `.yardopts` fro
195
211
  ```bash
196
212
  yard doc \
197
213
  --plugin fence \
198
- -e 'Yard::Fence.use_kramdown_gfm!' \
214
+ -e yard/fence/hoist.rb \
199
215
  --readme tmp/README.md \
200
216
  lib/**/*.rb - tmp/*.md tmp/*.txt
201
217
  ```
@@ -557,7 +573,7 @@ Thanks for RTFM. ☺️
557
573
  [📌gitmoji]: https://gitmoji.dev
558
574
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
559
575
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
560
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-4.278-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
576
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.084-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
561
577
  [🔐security]: SECURITY.md
562
578
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
563
579
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -0,0 +1,9 @@
1
+ if defined?(Yard::Fence) && Yard::Fence.respond_to?(:use_kramdown_gfm!)
2
+ if Yard::Fence.use_kramdown_gfm!
3
+ puts "[yard/fence/hoist] Kramdown GFM provider registered"
4
+ else
5
+ warn "[yard/fence/hoist] Kramdown GFM provider registration failed"
6
+ end
7
+ else
8
+ warn("[yard/fence/hoist] Yard::Fence.use_kramdown_gfm! not available; skipping")
9
+ end
@@ -3,7 +3,7 @@
3
3
  module Yard
4
4
  module Fence
5
5
  module Version
6
- VERSION = "0.1.0"
6
+ VERSION = "0.3.0"
7
7
  end
8
8
  VERSION = Version::VERSION
9
9
  end
data/lib/yard/fence.rb CHANGED
@@ -43,7 +43,19 @@ require "version_gem"
43
43
 
44
44
  # includes gem files
45
45
  require_relative "fence/version"
46
- require_relative "fence/kramdown_gfm_document"
46
+ begin
47
+ require_relative "fence/kramdown_gfm_document"
48
+ # :nocov:
49
+ # Not covering, because kramdown support is tested, so this rescue is not hit in test runs.
50
+ rescue LoadError => error
51
+ # check the error message, and re-raise if not what is expected
52
+ if error.message.include?("kramdown")
53
+ warn("Yard::Fence: Kramdown GFM provider not loaded: #{error.class}: #{error.message}") if ENV.fetch("YARD_DEBUG", "false").casecmp?("true")
54
+ else
55
+ raise error
56
+ end
57
+ end
58
+ # :nocov:
47
59
 
48
60
  module Yard
49
61
  module Fence
@@ -57,7 +69,10 @@ module Yard
57
69
  SINGLE_BRACE_PLACEHOLDER_REGEX = /{([A-Za-z0-9_:\-]+)}/
58
70
 
59
71
  class Error < StandardError; end
72
+ # :nocov:
73
+ # This is a runtime sanity check to ensure our fullwidth braces differ from ASCII braces.
60
74
  raise Error, "ASCII braces are not the same as Unicode Fullwidth braces" if ASCII_BRACES == FULLWIDTH_BRACES
75
+ # :nocov:
61
76
 
62
77
  module_function
63
78
 
@@ -139,6 +154,12 @@ module Yard
139
154
  # require warnings when YARD is in the middle of loading itself. Call this
140
155
  # from a file loaded via .yardopts (e.g. `-e 'require "yard/fence/kramdown_gfm"; Yard::Fence.use_kramdown_gfm!'`).
141
156
  def use_kramdown_gfm!
157
+ # :nocov:
158
+ # Not covering, because kramdown support is tested, so this rescue is not hit in test runs.
159
+ unless defined?(Yard::Fence::KramdownGfmDocument)
160
+ raise Error, "Yard::Fence: Kramdown GFM provider not loaded. Add kramdown and kramdown-parser-gfm to your Gemfile."
161
+ end
162
+ # :nocov:
142
163
  providers = ::YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown]
143
164
  providers.unshift(KRAMDOWN_PROVIDER)
144
165
  providers.uniq! { |p| [p[:lib].to_s, p[:const].to_s] }
@@ -162,8 +183,10 @@ Yard::Fence::Version.class_eval do
162
183
  extend VersionGem::Basic
163
184
  end
164
185
 
165
- # After YARD completes, restore ASCII braces in generated HTML docs.
166
- # This guarantees the published docs (docs/*.html) show and copy normal { }.
167
- at_exit do
168
- Yard::Fence.postprocess_html_docs
186
+ unless ENV["YARD_FENCE_SKIP_AT_EXIT"] == "1"
187
+ # After YARD completes, restore ASCII braces in generated HTML docs.
188
+ # This guarantees the published docs (docs/*.html) show and copy normal { }.
189
+ at_exit do
190
+ Yard::Fence.postprocess_html_docs
191
+ end
169
192
  end
data/sig/kramdown.rbs CHANGED
@@ -1,6 +1,6 @@
1
+ # (RBS) Kramdown minimal signatures used by yard-fence
1
2
  module Kramdown
2
3
  class Document
3
4
  def initialize: (String source, ?::Hash[Symbol, untyped] options) -> void
4
5
  end
5
6
  end
6
-
data/sig/yard/fence.rbs CHANGED
@@ -1,10 +1,10 @@
1
1
  module Yard
2
2
  module Fence
3
- # Constants
3
+ # Constants (refined literal types where possible)
4
4
  VERSION: String
5
- ASCII_BRACES: String
6
- FULLWIDTH_BRACES: String
7
- KRAMDOWN_PROVIDER: Hash[Symbol, untyped]
5
+ ASCII_BRACES: "{}"
6
+ FULLWIDTH_BRACES: "{}"
7
+ KRAMDOWN_PROVIDER: { lib: Symbol, const: String }
8
8
  GLOB_PATTERN: String
9
9
  TRIPLE_TICK_FENCE: ::Regexp
10
10
  INLINE_TICK_FENCE: ::Regexp
@@ -15,16 +15,33 @@ module Yard
15
15
  class Error < ::StandardError
16
16
  end
17
17
 
18
- # Module functions
18
+ # Module functions (available both as singleton and instance via module_function)
19
19
  def self.fullwidth_braces: (String str) -> String
20
+ def fullwidth_braces: (String str) -> String
21
+
20
22
  def self.sanitize_inline_code: (String line) -> String
23
+ def sanitize_inline_code: (String line) -> String
24
+
21
25
  def self.sanitize_fenced_blocks: (String text) -> String
26
+ def sanitize_fenced_blocks: (String text) -> String
27
+
28
+ # Accept any object; if String returns String, otherwise returns original (untyped)
22
29
  def self.sanitize_text: (String text) -> String
23
30
  | (untyped text) -> untyped
31
+ def sanitize_text: (String text) -> String
32
+ | (untyped text) -> untyped
33
+
24
34
  def self.prepare_tmp_files: () -> void
35
+ def prepare_tmp_files: () -> void
36
+
25
37
  def self.restore_ascii_braces_in_html_file: (String html_filepath) -> void
38
+ def restore_ascii_braces_in_html_file: (String html_filepath) -> void
39
+
26
40
  def self.postprocess_html_docs: () -> void
41
+ def postprocess_html_docs: () -> void
42
+
27
43
  def self.use_kramdown_gfm!: () -> bool
44
+ def use_kramdown_gfm!: () -> bool
28
45
 
29
46
  module Version
30
47
  VERSION: String
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-fence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -306,6 +306,7 @@ files:
306
306
  - SECURITY.md
307
307
  - lib/yard-fence.rb
308
308
  - lib/yard/fence.rb
309
+ - lib/yard/fence/hoist.rb
309
310
  - lib/yard/fence/kramdown_gfm_document.rb
310
311
  - lib/yard/fence/version.rb
311
312
  - sig/kramdown.rbs
@@ -315,10 +316,10 @@ licenses:
315
316
  - MIT
316
317
  metadata:
317
318
  homepage_uri: https://yard-fence.galtzo.com/
318
- source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.1.0
319
- changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.1.0/CHANGELOG.md
319
+ source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.3.0
320
+ changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.3.0/CHANGELOG.md
320
321
  bug_tracker_uri: https://github.com/galtzo-floss/yard-fence/issues
321
- documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.1.0
322
+ documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.3.0
322
323
  funding_uri: https://github.com/sponsors/pboling
323
324
  wiki_uri: https://github.com/galtzo-floss/yard-fence/wiki
324
325
  news_uri: https://www.railsbling.com/tags/yard-fence
metadata.gz.sig CHANGED
Binary file