LoginSignup
1
1

More than 5 years have passed since last update.

prmdのrakeタスクのオプションの使い方

Last updated at Posted at 2017-12-29

概要

prmdにおけるドキュメント生成のrakeタスクを作成する際のオプションの付け方。

バージョン

prmd 0.13.0

prmdとは何か?

こちらの記事を参考にしてください。

prmd を利用して JSON Schema を簡単に管理しよう
JSON Schemaを上手く運用出来そうなprmdとその周りのお話

rakeタスク

READMEのサンプルに載っているrakeタスクは以下の通り

schema.rake
# Rakefile
require 'prmd/rake_tasks/combine'
require 'prmd/rake_tasks/verify'
require 'prmd/rake_tasks/doc'

namespace :schema do
  Prmd::RakeTasks::Combine.new do |t|
    t.options[:meta] = 'schema/meta.json'    # use meta.yml if you prefer YAML format
    t.paths << 'schema/schemata/api'
    t.output_file = 'schema/api.json'
  end

  Prmd::RakeTasks::Verify.new do |t|
    t.files << 'schema/api.json'
  end

  Prmd::RakeTasks::Doc.new do |t|
    t.files = { 'schema/api.json' => 'schema/api.md' }
  end
end

task default: ['schema:combine', 'schema:verify', 'schema:doc']

ドキュメント生成のオプションにあるtoc(table of contents)を利用したかったので、

{
  "doc": {
    "url_style": "default", // can also be "json"
    "disable_title_and_description": false, // remove the title and the description, useful when using your own custom header
    "toc": false // insert the table of content for json scheme documentation to the top of the file. (default disable)
  }
}

以下のように設定すると使える。


Prmd::RakeTasks::Doc.new do |t|
  t.files = { 'schema/api.json' => 'schema/api.md' }
+  t.options[:doc] = { toc: true } # ここ
end

出力例

ドキュメントの最初にエンドポイントの一覧が表示される。

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1