Skip to content

Commit

Permalink
Try to generate yard doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Sep 10, 2023
1 parent e7a7dbd commit 4e3e597
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: doc

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
- name: Generate document
run: bundle exec rake doc
- name: Publish Documentation on GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc
3 changes: 3 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--plugin rustdoc
lib
tmp/doc/candle.json
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ gem 'minitest'
gem 'rake'
gem 'rake-compiler'

# https://github.com/lsegal/yard/issues/1321
gem 'yard', require: false
gem "yard", require: false
gem 'yard-rustdoc', require: false
31 changes: 29 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require 'rake/extensiontask'
task default: :test
Rake::TestTask.new do |t|
t.deps << :compile
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.libs << 'test'
t.test_files = FileList['test/test_*.rb']
end

spec = Bundler.load_gemspec('candle.gemspec')
Expand All @@ -30,3 +30,30 @@ desc 'benchmark'
task bench: :compile do
ruby 'test/bench.rb'
end

namespace :doc do
task default: %i[rustdoc yard]

desc 'Generate YARD documentation'
task :yard do
sh <<~CMD
yard doc \
--plugin rustdoc -- lib tmp/doc/candle.json
CMD
end

desc 'Generate Rust documentation as JSON'
task :rustdoc do
sh <<~CMD
cargo +nightly rustdoc \
--target-dir tmp/doc/target \
-p candle \
-- -Zunstable-options --output-format json \
--document-private-items
CMD

cp "tmp/doc/target/doc/candle.json", "tmp/doc/candle.json"
end
end

task doc: 'doc:default'
2 changes: 1 addition & 1 deletion test/bench.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
puts "Under construction"
puts 'Under construction'

0 comments on commit 4e3e597

Please sign in to comment.