メインコンテンツまでスキップ
バージョン: v4.34

カスタムドキュメントの生成

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
}
}
]
};

構成​

プロパティ説明デフォルト値
generatordocs-jsonデータを引数として持つ関数。
stricttrueに設定すると、ドキュメントが不足している場合は常にステンシルが警告を出力します。false

カスタムドキュメントデータモデル

生成されたドキュメントJSONデータは、Stencilコアが検出したコンポーネントとtimestampや「compiler」などのメタ情報で構成されるメインのcomponents配列で構成されるJsonDocsタイプになります。

JsonDocs​

プロパティ説明
componentsコンポーネント情報で構成される JsonDocsComponent[]のタイプの配列
timestampタイムスタンプ付きの string
compilertypescriptVersion、compiler、versionを持つObject

JsonDocsComponent​

プロパティ説明
dirPath コンポーネントディレクトリパス
fileNameファイル名
filePathファイルパス
readmePathReadmeファイルのパス
usagesDirStencil 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.
encapsulationencapsulationタイプコンポーネント。可能な値はshadow, scoped, none
tag.tsxファイルに機銃されているコンポーネントタグ
readmeコンポーネントreadmeファイルの最初の行の内容
docsDescription 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の方法で)はここに集められます
overviewDescription written in top of @Component e.g. /** Documentation Example */
usageArray of usage examples, written in Markdown files in the usages/ directory adjacent to the current component.
propsArray of metadata objects for each usage of the @Prop decorator on the current component.
methodsArray of metadata objects for each usage of the @Method decorator on the current component.
eventsArray of metadata objects for each usage of the @Event decorator on the current component.
listenersArray of metadata objects for each usage of the @Listen decorator on the current component.
stylesArray of objects documenting annotated CSS variables used in the current component's CSS.
slotsArray of objects documenting slots which are tagged with @slot in the current component's JSDoc comment.
partsArray of objects derived from @part tags in the current component's JSDoc comment.
dependents現在のコンポーネントが使用されているコンポーネントの配列
dependencies現在のコンポーネントで使用されているコンポーネントの配列
dependencyGraph結合するコンポーネントのツリーについて説明します