Skip to content

Commit 91bb09e

Browse files
committed
Modernize code.
1 parent 2236dce commit 91bb09e

20 files changed

Lines changed: 95 additions & 71 deletions

File tree

.github/workflows/documentation-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
- uses: ruby/setup-ruby@v1
1818
with:
1919
ruby-version: ruby

.github/workflows/documentation.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2828

2929
- uses: ruby/setup-ruby@v1
3030
with:
@@ -39,7 +39,7 @@ jobs:
3939
run: bundle exec bake utopia:project:static --force no
4040

4141
- name: Upload documentation artifact
42-
uses: actions/upload-pages-artifact@v3
42+
uses: actions/upload-pages-artifact@v4
4343
with:
4444
path: docs
4545

.github/workflows/rubocop.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
- uses: ruby/setup-ruby@v1
1515
with:
1616
ruby-version: ruby

.github/workflows/test-coverage.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ jobs:
2323
- ruby
2424

2525
steps:
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2727
- uses: ruby/setup-ruby@v1
2828
with:
2929
ruby-version: ${{matrix.ruby}}
3030
bundler-cache: true
3131

3232
- name: Run tests
3333
timeout-minutes: 5
34-
run: bundle exec bake build test
34+
run: bundle exec bake test
3535

36-
- uses: actions/upload-artifact@v4
36+
- uses: actions/upload-artifact@v5
3737
with:
3838
include-hidden-files: true
3939
if-no-files-found: error
@@ -45,13 +45,13 @@ jobs:
4545
runs-on: ubuntu-latest
4646

4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4949
- uses: ruby/setup-ruby@v1
5050
with:
5151
ruby-version: ruby
5252
bundler-cache: true
5353

54-
- uses: actions/download-artifact@v4
54+
- uses: actions/download-artifact@v6
5555

5656
- name: Validate coverage
5757
timeout-minutes: 5

.github/workflows/test.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- "3.2"
2222
- "3.3"
2323
- "3.4"
24+
- "4.0"
2425

2526
experimental: [false]
2627

@@ -36,12 +37,12 @@ jobs:
3637
experimental: true
3738

3839
steps:
39-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@v6
4041
- uses: ruby/setup-ruby@v1
4142
with:
4243
ruby-version: ${{matrix.ruby}}
4344
bundler-cache: true
4445

4546
- name: Run tests
4647
timeout-minutes: 10
47-
run: bundle exec bake build test
48+
run: bundle exec bake test

.rubocop.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
plugins:
2+
- rubocop-md
23
- rubocop-socketry
34

45
AllCops:
56
DisabledByDefault: true
67

8+
# Socketry specific rules:
9+
710
Layout/ConsistentBlankLineIndentation:
811
Enabled: true
912

13+
Layout/BlockDelimiterSpacing:
14+
Enabled: true
15+
16+
Style/GlobalExceptionVariables:
17+
Enabled: true
18+
19+
# General Layout rules:
20+
1021
Layout/IndentationStyle:
1122
Enabled: true
1223
EnforcedStyle: tabs
@@ -33,6 +44,9 @@ Layout/BeginEndAlignment:
3344
Enabled: true
3445
EnforcedStyleAlignWith: start_of_line
3546

47+
Layout/RescueEnsureAlignment:
48+
Enabled: true
49+
3650
Layout/ElseAlignment:
3751
Enabled: true
3852

@@ -41,10 +55,15 @@ Layout/DefEndAlignment:
4155

4256
Layout/CaseIndentation:
4357
Enabled: true
58+
EnforcedStyle: end
4459

4560
Layout/CommentIndentation:
4661
Enabled: true
4762

63+
Layout/FirstHashElementIndentation:
64+
Enabled: true
65+
EnforcedStyle: consistent
66+
4867
Layout/EmptyLinesAroundClassBody:
4968
Enabled: true
5069

context/abstract-syntax-tree.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can use `walk` or `each` to iterate over nodes:
3939
<!-- end list -->
4040

4141
``` ruby
42-
require 'markly'
42+
require "markly"
4343

4444
document = Markly.parse("# The site\n\n [GitHub](https://www.github.com)")
4545

@@ -80,11 +80,10 @@ class MyHtmlRenderer < Markly::Renderer::HTML
8080
super
8181
@header_id = 1
8282
end
83-
83+
8484
def header(node)
8585
block do
86-
out("<h", node.header_level, " id=\"", @header_id, "\">",
87-
:children, "</h", node.header_level, ">")
86+
out("<h", node.header_level, " id=\"", @header_id, "\">", :children, "</h", node.header_level, ">")
8887
@header_id += 1
8988
end
9089
end

context/headings.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ document = Markly.parse(markdown)
3838
headings = Markly::Renderer::Headings.extract(document, min_level: 2, max_level: 3)
3939

4040
headings.each do |heading|
41-
puts "#{heading.level}: #{heading.text} (#{heading.anchor})"
41+
puts "#{heading.level}: #{heading.text} (#{heading.anchor})"
4242
end
4343

4444
# Output:
@@ -90,25 +90,25 @@ Subclass `Headings` to implement alternative ID generation strategies:
9090

9191
``` ruby
9292
class HierarchicalHeadings < Markly::Renderer::Headings
93-
def initialize
94-
super
95-
@parent_context = []
96-
end
97-
98-
def anchor_for(node)
99-
base = base_anchor_for(node)
100-
101-
# Custom logic: could incorporate parent heading context
102-
# to generate IDs like "kubernetes-deployment" instead of "deployment-2"
103-
104-
if @ids.key?(base)
105-
@ids[base] += 1
106-
"#{base}-#{@ids[base]}"
107-
else
108-
@ids[base] = 1
109-
base
110-
end
111-
end
93+
def initialize
94+
super
95+
@parent_context = []
96+
end
97+
98+
def anchor_for(node)
99+
base = base_anchor_for(node)
100+
101+
# Custom logic: could incorporate parent heading context
102+
# to generate IDs like "kubernetes-deployment" instead of "deployment-2"
103+
104+
if @ids.key?(base)
105+
@ids[base] += 1
106+
"#{base}-#{@ids[base]}"
107+
else
108+
@ids[base] = 1
109+
base
110+
end
111+
end
112112
end
113113

114114
renderer = Markly::Renderer::HTML.new(headings: HierarchicalHeadings.new)

gems.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
gem "decode"
2727

2828
gem "rubocop"
29+
gem "rubocop-md"
2930
gem "rubocop-socketry"
3031

3132
gem "bake"
@@ -37,3 +38,5 @@
3738
gem "kramdown"
3839
gem "redcarpet"
3940
end
41+
42+
gem "rubocop-md", "~> 2.0", group: :test

guides/abstract-syntax-tree/readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can use `walk` or `each` to iterate over nodes:
3939
<!-- end list -->
4040

4141
``` ruby
42-
require 'markly'
42+
require "markly"
4343

4444
document = Markly.parse("# The site\n\n [GitHub](https://www.github.com)")
4545

@@ -80,11 +80,10 @@ class MyHtmlRenderer < Markly::Renderer::HTML
8080
super
8181
@header_id = 1
8282
end
83-
83+
8484
def header(node)
8585
block do
86-
out("<h", node.header_level, " id=\"", @header_id, "\">",
87-
:children, "</h", node.header_level, ">")
86+
out("<h", node.header_level, " id=\"", @header_id, "\">", :children, "</h", node.header_level, ">")
8887
@header_id += 1
8988
end
9089
end

0 commit comments

Comments
 (0)