DocBox 出力例
DocBox 出力例
bxSites docbox が実際に生成するものの例です。以下のページ
はすべて、示したソースに対する実際の実行結果であり、手書きの説明では
ありません。
プロジェクトの models/ フォルダーに次のクラスがあるとします。
/**
* A single book on the shelf, immutable once created.
*
* @author Ortus Solutions
*/
class singleton accessors=true {
/**
* The book's title
*/
property name="title" type="string";
/**
* Where book records are read from
*/
property name="datasource" type="string" inject="coldbox:setting:bookDatasource";
/**
* Build a book.
*
* @title The book's title
* @author The book's author
*/
function init( required string title, string author = "Unknown" ) {
return this
}
/**
* Return a copy of this book with a new title.
*
* @newTitle The replacement title
*
* @return a copy carrying the new title
*/
Book function withTitle( required string newTitle ) {}
private function normalize() {}
}
...bxSites docbox は api/docbox/models/Book.md を次の frontmatter で
書き出します。
---
title: "Book"
summary: "A single book on the shelf, immutable once created."
tags: [api, docbox]
---
そして本文は次のとおりです。コードブロックではなく実際にレンダリングして います。これが生成されたページの本文そのもので、フィルターバーも動作 します。Private チップを押すか、検索ボックスに "title" と入力してみて ください。
Book
models.Book · Class
A single book on the shelf, immutable once created.
Annotations
@accessorstrue@singleton
Properties
| Property | Type | Default | Description |
|---|---|---|---|
title | string | — | The book's title |
datasource | string | — | Where book records are read from @inject coldbox:setting:bookDatasource |
注目すべき点
- プロパティ表が存在すること。 DocBox 自身の JSON ストラテジーは宣言
された
propertyブロックを落とします。bx-sites は DocBox が使ったのと 同じクラスメタデータから読み直すため、titleとdatasourceが説明つき で並び、datasourceの WireBoxinjectも残ります。 @returnのテキストも同じ理由で残ります。withTitleの下の Returns 行を見てください。- private メソッドも含まれます。 Javadoc ジェネレーターとは異なり、 DocBox が報告するのでドキュメント化され、不要なときは Private チップで 隠せます。
initはコンストラクターとして、メソッドより前の独立したセクション になります。
設定については DocBox APIリファレンス を、同じプロジェクトから ColdBox verb が生成するものについては ColdBox 出力例 を参照してください。