Skip to content

Commit 08fa000

Browse files
committed
Extract yard
1 parent 8f9f58c commit 08fa000

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

.github/workflows/yard.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ jobs:
2525
name: github-pages
2626
url: ${{ steps.deployment.outputs.page_url }}
2727
runs-on: ubuntu-latest
28+
container:
29+
image: ghcr.io/datadog/images-rb/engines/ruby:3.2
30+
env:
31+
BUNDLE_GEMFILE: tools/yard.gemfile
2832
steps:
2933
- name: Checkout
3034
uses: actions/checkout@v4
31-
- uses: ruby/setup-ruby@v1
32-
with:
33-
ruby-version: '3.2'
34-
bundler-cache: true
35+
- run: ls -al
36+
- name: Bundle
37+
run: bundle install
3538
- name: Generate YARD documentation
36-
run: bundle exec rake docs
39+
run: bundle exec rake docs --rakefile=tasks/yard.rake
3740
- name: Setup Pages
3841
uses: actions/configure-pages@v3
3942
- name: Upload artifact

Gemfile

-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ elsif RUBY_VERSION >= '3.0.0' # No longer bundled by default since Ruby 3.0
5151
gem 'webrick', '>= 1.7.0'
5252
end
5353

54-
gem 'yard', '~> 0.9' # NOTE: YardDoc is generated with ruby 3.2 in GitHub Actions
55-
5654
if RUBY_VERSION >= '2.6.0'
5755
# 1.50 is the last version to support Ruby 2.6
5856
gem 'rubocop', '~> 1.50.0', require: false

Rakefile

-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ require 'rubocop/rake_task' if Gem.loaded_specs.key? 'rubocop'
44
require 'standard/rake' if Gem.loaded_specs.key? 'standard'
55
require 'rspec/core/rake_task'
66
require 'rake/extensiontask'
7-
require 'yard'
87
require 'os'
98
if Gem.loaded_specs.key? 'ruby_memcheck'
109
require 'ruby_memcheck'
@@ -350,17 +349,6 @@ if defined?(RuboCop::RakeTask)
350349
end
351350
end
352351

353-
YARD::Rake::YardocTask.new(:docs) do |t|
354-
# Options defined in `.yardopts` are read first, then merged with
355-
# options defined here.
356-
#
357-
# It's recommended to define options in `.yardopts` instead of here,
358-
# as `.yardopts` can be read by external YARD tools, like the
359-
# hot-reload YARD server `yard server --reload`.
360-
361-
t.options += ['--title', "datadog #{Datadog::VERSION::STRING} documentation"]
362-
end
363-
364352
# Jobs are parallelized if running in CI.
365353
desc 'CI task; it runs all tests for current version of Ruby'
366354
task ci: 'test:all'

tasks/yard.rake

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
if Gem.loaded_specs["yard"]
3+
require 'yard'
4+
else
5+
warn "'yard' gem not loaded: skipping tasks..." if Rake.verbose == true
6+
return
7+
end
8+
9+
YARD::Rake::YardocTask.new(:docs) do |t|
10+
# Options defined in `.yardopts` are read first, then merged with
11+
# options defined here.
12+
#
13+
# It's recommended to define options in `.yardopts` instead of here,
14+
# as `.yardopts` can be read by external YARD tools, like the
15+
# hot-reload YARD server `yard server --reload`.
16+
17+
t.options += ['--title', "datadog #{Datadog::VERSION::STRING} documentation"]
18+
end

tools/yard.gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec path: '..'
4+
5+
gem 'rake'
6+
gem 'yard'
7+
gem 'redcarpet'

0 commit comments

Comments
 (0)