yard-fence 0.4.0 → 0.5.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: aaa318b924e8efbaddbb3666df3f71157678a5fbab11972f51550ecd48f4ddb2
4
- data.tar.gz: af4bb34d3b799695511f5b880aa1fffa7d9765dcb71a8c5c780bfbd53f5d9f35
3
+ metadata.gz: '0909353a8e193134a57cf571979c154be5c08adb0ce6c53855282996ea8d96de'
4
+ data.tar.gz: 69400f31490fb97d56aa19a79519c7f15c160b689b48ca6d0228df640410655b
5
5
  SHA512:
6
- metadata.gz: c59ecea9ee908fe804879b2197ab6047769d70a2256e69522afff4069ad73e95b48f370f0ab9a1827dc4f955e2e1f3ded8c7017da27869c0cb2b262e986f910c
7
- data.tar.gz: 4ed6d00979a897c5ced52a0c72ae108c2eb05a29be9e73b9e0dd5bbc1546e80c6f54a1d780460b4a41268e0dcac27cff10142e70fb7826755f8ba511a6715508
6
+ metadata.gz: e7e3af604e115d051dac3bb1763df43aeacdd693c947504ace79f8864f12e343ea54e065be3b3b13e55b4b29bc8d193fcb939c44fbcad3a6f0307df5c55dd06e
7
+ data.tar.gz: 28c385b149403931cf456ad76223a33b12df2272fa47bcde51cfff31344e43b699227a7a10902f27e910beced70db24fd674b0831e2652ef7dc487669139ca78
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,18 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.5.0] - 2025-11-07
34
+
35
+ - TAG: [v0.5.0][0.5.0t]
36
+ - COVERAGE: 100.00% -- 98/98 lines in 4 files
37
+ - BRANCH COVERAGE: 100.00% -- 22/22 branches in 4 files
38
+ - 34.62% documented
39
+
40
+ ### Added
41
+
42
+ - Support multi-line braces
43
+ - 100% lines / 100% branches test coverage
44
+
33
45
  ## [0.4.0] - 2025-11-07
34
46
 
35
47
  - TAG: [v0.4.0][0.4.0t]
@@ -82,7 +94,9 @@ Please file a bug if you notice a violation of semantic versioning.
82
94
 
83
95
  - Initial release
84
96
 
85
- [Unreleased]: https://github.com/galtzo-floss/yard-fence/compare/v0.4.0...HEAD
97
+ [Unreleased]: https://github.com/galtzo-floss/yard-fence/compare/v0.5.0...HEAD
98
+ [0.5.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.4.0...v0.5.0
99
+ [0.5.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.5.0
86
100
  [0.4.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.3.0...v0.4.0
87
101
  [0.4.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.4.0
88
102
  [0.3.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.2.0...v0.3.0
data/README.md CHANGED
@@ -586,7 +586,7 @@ Thanks for RTFM. ☺️
586
586
  [📌gitmoji]: https://gitmoji.dev
587
587
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
588
588
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
589
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.084-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
589
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.098-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
590
590
  [🔐security]: SECURITY.md
591
591
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
592
592
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -3,7 +3,7 @@
3
3
  module Yard
4
4
  module Fence
5
5
  module Version
6
- VERSION = "0.4.0"
6
+ VERSION = "0.5.0"
7
7
  end
8
8
  VERSION = Version::VERSION
9
9
  end
data/lib/yard/fence.rb CHANGED
@@ -61,12 +61,19 @@ module Yard
61
61
  module Fence
62
62
  ASCII_BRACES = "{}"
63
63
  FULLWIDTH_BRACES = "{}"
64
+ # IMPORTANT: YARD expects :const to be a String.
65
+ # YARD concatenates with a String prefix (e.g., "::" + const),
66
+ # so a Symbol here will break provider resolution. Some static analyzers
67
+ # suggest making this a Symbol to match types, but that is incorrect for YARD.
68
+ # Do NOT change this to a Symbol.
64
69
  KRAMDOWN_PROVIDER = {lib: :kramdown, const: "KramdownGfmDocument"}
65
70
  GLOB_PATTERN = "*.{md,MD,txt,TXT}"
66
71
  TRIPLE_TICK_FENCE = /^\s*```/
67
72
  INLINE_TICK_FENCE = /`([^`]+)`/
68
73
  DOUBLE_BRACE_PLACEHOLDER_REGEX = /{{([^{}]+)}}/
69
74
  SINGLE_BRACE_PLACEHOLDER_REGEX = /{([A-Za-z0-9_:\-]+)}/
75
+ # Lines that are part of a classic indented code block (CommonMark: 4 spaces)
76
+ INDENTED_CODE_LINE = /^ {4,}\S/
70
77
 
71
78
  class Error < StandardError; end
72
79
  # :nocov:
@@ -84,8 +91,11 @@ module Yard
84
91
 
85
92
  # Escape braces inside inline `code` spans only.
86
93
  def sanitize_inline_code(line)
87
- # Use $1 because the block parameter (_) is the matched substring, not a MatchData object.
88
- line.gsub(INLINE_TICK_FENCE) { |_| "`#{fullwidth_braces($1)}`" }
94
+ # Use Regexp.last_match to safely access capture; to_s guards against nil
95
+ line.gsub(INLINE_TICK_FENCE) do |_|
96
+ inner = Regexp.last_match(1).to_s
97
+ "`#{fullwidth_braces(inner)}`"
98
+ end
89
99
  end
90
100
 
91
101
  # Walk the text, toggling a simple in_fence state on ``` lines.
@@ -93,13 +103,31 @@ module Yard
93
103
  # and disarm simple prose placeholders like {issuer} or {{something}}.
94
104
  def sanitize_fenced_blocks(text)
95
105
  in_fence = false
106
+ in_indented_block = false
96
107
 
97
108
  text.each_line.map do |line|
98
109
  if line.match?(TRIPLE_TICK_FENCE)
110
+ # Toggle fenced block state; leaving indented block if switching into explicit fence
99
111
  in_fence = !in_fence
112
+ in_indented_block = false if in_fence
100
113
  line
101
114
  elsif in_fence
102
115
  fullwidth_braces(line)
116
+ elsif in_indented_block
117
+ # Continue indented block until a blank line or non-indented line breaks it
118
+ if line.strip.empty? || !line.match?(INDENTED_CODE_LINE)
119
+ in_indented_block = false
120
+ # Process this line as normal prose outside block
121
+ ln = sanitize_inline_code(line)
122
+ ln = ln.gsub(DOUBLE_BRACE_PLACEHOLDER_REGEX) { |m| fullwidth_braces(m) }
123
+ ln.gsub(SINGLE_BRACE_PLACEHOLDER_REGEX) { |m| fullwidth_braces(m) }
124
+ else
125
+ fullwidth_braces(line)
126
+ end
127
+ elsif line.match?(INDENTED_CODE_LINE)
128
+ # Enter indented code block on first qualifying line
129
+ in_indented_block = true
130
+ fullwidth_braces(line)
103
131
  else
104
132
  ln = sanitize_inline_code(line)
105
133
  # IMPORTANT: handle double-brace placeholders first so we don't partially
@@ -162,6 +190,10 @@ module Yard
162
190
  end
163
191
  # :nocov:
164
192
  providers = ::YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown]
193
+ # NOTE: Intentionally using String for :const in KRAMDOWN_PROVIDER.
194
+ # YARD performs string concatenation with this value (e.g., "::" + const).
195
+ # Changing it to a Symbol to satisfy static type hints breaks runtime behavior.
196
+ # Suppress type fuzz complaints: expected Hash{Symbol->Symbol}, actual includes String by design.
165
197
  providers.unshift(KRAMDOWN_PROVIDER)
166
198
  providers.uniq! { |p| [p[:lib].to_s, p[:const].to_s] }
167
199
  true
@@ -169,14 +201,16 @@ module Yard
169
201
  warn("Yard::Fence.use_kramdown_gfm!: failed to load YARD helper: #{e.class}: #{e.message}")
170
202
  false
171
203
  end
204
+
205
+ def at_load_hook
206
+ Yard::Fence.prepare_tmp_files
207
+ rescue => e
208
+ warn("Yard::Fence: failed to prepare tmp/yard-fence files: #{e.class}: #{e.message}")
209
+ end
172
210
  end
173
211
 
174
212
  # Execute at load-time so files exist before YARD scans tmp/yard-fence/*.md
175
- begin
176
- Yard::Fence.prepare_tmp_files
177
- rescue => e
178
- warn("Yard::Fence: failed to prepare tmp/yard-fence files: #{e.class}: #{e.message}")
179
- end
213
+ Yard::Fence.at_load_hook
180
214
  end
181
215
 
182
216
  # Extend the Version with VersionGem::Basic to provide semantic version helpers.
@@ -184,6 +218,8 @@ Yard::Fence::Version.class_eval do
184
218
  extend VersionGem::Basic
185
219
  end
186
220
 
221
+ # :nocov:
222
+ # Not checking coverage of the at_exit hook, because it would require a forked process.
187
223
  unless ENV["YARD_FENCE_SKIP_AT_EXIT"] == "1"
188
224
  # After YARD completes, restore ASCII braces in generated HTML docs.
189
225
  # This guarantees the published docs (docs/*.html) show and copy normal { }.
@@ -191,3 +227,4 @@ unless ENV["YARD_FENCE_SKIP_AT_EXIT"] == "1"
191
227
  Yard::Fence.postprocess_html_docs
192
228
  end
193
229
  end
230
+ # :nocov:
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -316,10 +316,10 @@ licenses:
316
316
  - MIT
317
317
  metadata:
318
318
  homepage_uri: https://yard-fence.galtzo.com/
319
- source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.4.0
320
- changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.4.0/CHANGELOG.md
319
+ source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.5.0
320
+ changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.5.0/CHANGELOG.md
321
321
  bug_tracker_uri: https://github.com/galtzo-floss/yard-fence/issues
322
- documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.4.0
322
+ documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.5.0
323
323
  funding_uri: https://github.com/sponsors/pboling
324
324
  wiki_uri: https://github.com/galtzo-floss/yard-fence/wiki
325
325
  news_uri: https://www.railsbling.com/tags/yard-fence
metadata.gz.sig CHANGED
Binary file