カスタムドキュメントの生成
Stencilは、ユーザーが生成されたdocs-jsonデータにアクセスできる docs-customというタイトルの出力ターゲットを公開します。 この機能を使用して、カスタムマークダウンを生成したり、ビルド中にjsonデータに対して他のロジックを実行したりできます。 他のドキュメント出力ターゲットと同様に、 strictモードがサポートされています。
この出力ターゲットを利用するには、ステンシル構成に以下を追加するだけです。
import { Config } from '@stencil/core';
export const config: Config = {
outputTargets: [
{
type: 'docs-custom',
generator: (docs: JsonDocs) => {
// Custom logic goes here
}
}
]
};
構成
| プロパティ | 説明 | デフォルト値 |
|---|---|---|
generator | docs-jsonデータを引数として持つ関数。 | |
strict | trueに設定すると、ドキュメントが不足している場合は常にステンシルが警告を出力します。 | false |
カスタムドキュメントデータモデル
生成されたドキュメントJSONデータは、Stencilコアが検出したコンポーネントとtimestampや「compiler」などのメタ情報で構成されるメインのcomponents配列で構成されるJsonDocsタイプになります。
JsonDocs
| プロパティ | 説明 |
|---|---|
components | コンポーネント情報で構成される JsonDocsComponent[]のタイプの配列 |
timestamp | タイムスタンプ付きの string |
compiler | typescriptVersion、compiler、versionを持つObject |
JsonDocsComponent
| プロパティ | 説明 |
|---|---|
dirPath コンポーネントディレクトリパス | |
fileName | ファイル名 |
filePath | ファイルパス |
readmePath | Readmeファイルのパス |
usagesDir | Stencil looks in a directory named usages/ in the same directory as your component to find usage examples. This holds the full path to that directory. |
encapsulation | encapsulationタイプコンポーネント。可能な値はshadow, scoped, none |
tag | .tsxファイルに機銃されているコンポーネントタグ |
readme | コンポーネントreadmeファイルの最初の行の内容 |
docs | Description written in top of @Component e.g. /** Documentation Example */. If no JSDoc is present, default to any manually written text in the component's markdown file. Empty otherwise. |
docsTags | .tsxファイルに書かれた注釈(JSDocの方法で)はここに集められます |
overview | Description written in top of @Component e.g. /** Documentation Example */ |
usage | Array of usage examples, written in Markdown files in the usages/ directory adjacent to the current component. |
props | Array of metadata objects for each usage of the @Prop decorator on the current component. |
methods | Array of metadata objects for each usage of the @Method decorator on the current component. |
events | Array of metadata objects for each usage of the @Event decorator on the current component. |
listeners | Array of metadata objects for each usage of the @Listen decorator on the current component. |
styles | Array of objects documenting annotated CSS variables used in the current component's CSS. |
slots | Array of objects documenting slots which are tagged with @slot in the current component's JSDoc comment. |
parts | Array of objects documenting CSS Parts which are derived from @part tags in the current component's JSDoc comment. |
dependents |