From 4e3e597c8ca5ce741aa7c20dbcbd44c784dffae9 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sun, 10 Sep 2023 19:09:02 +0900 Subject: [PATCH] Try to generate yard doc --- .github/workflows/doc.yml | 23 +++++++++++++++++++++++ .yardopts | 3 +++ Gemfile | 4 ++-- Rakefile | 31 +++++++++++++++++++++++++++++-- test/bench.rb | 2 +- 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/doc.yml create mode 100644 .yardopts diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 0000000..2e04384 --- /dev/null +++ b/.github/workflows/doc.yml @@ -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 diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..f3cdc77 --- /dev/null +++ b/.yardopts @@ -0,0 +1,3 @@ +--plugin rustdoc +lib +tmp/doc/candle.json \ No newline at end of file diff --git a/Gemfile b/Gemfile index b57e59b..1b4e73b 100644 --- a/Gemfile +++ b/Gemfile @@ -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 \ No newline at end of file diff --git a/Rakefile b/Rakefile index f32162c..1cd80db 100644 --- a/Rakefile +++ b/Rakefile @@ -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') @@ -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' \ No newline at end of file diff --git a/test/bench.rb b/test/bench.rb index e38e60b..c1681e0 100644 --- a/test/bench.rb +++ b/test/bench.rb @@ -1 +1 @@ -puts "Under construction" \ No newline at end of file +puts 'Under construction'