Apidoc services completed

pull/3711/head
Bahadır Sofuoğlu 2023-03-07 16:37:45 +03:00
parent 1ddebd977c
commit e2747c5ae8
13 changed files with 394 additions and 246 deletions

View File

@ -167,6 +167,11 @@ if (project) {
description: '', description: '',
values: [] values: []
}; };
const methods = {
description: '',
values: []
};
const model_props_group = model.groups.find((g) => g.title === 'Properties'); const model_props_group = model.groups.find((g) => g.title === 'Properties');
model_props_group && model_props_group &&
@ -181,9 +186,55 @@ if (project) {
}); });
}); });
const model_methods_group = model.groups.find((g) => g.title === 'Methods');
model_methods_group &&
model_methods_group.children.forEach((method) => {
const signature = method.getAllSignatures()[0];
const isSlot = model.name.includes('Slots');
methods.values.push({
name: signature.name,
parameters: signature.parameters.map((param) => {
let type = param.type.toString();
if (param.type.declaration && isSlot) {
type = '';
if (param.type.declaration.children) {
param.type.declaration.children.forEach((child) => {
if (child.signatures) {
const childSinature = child.signatures[0];
const parameters = childSinature.parameters.reduce((acc, { name, type }, index) => (index === 0 ? `${name}: ${type.name}` : `${acc}, ${name}: ${type.name}`), '');
type += ` \t ${childSinature.name}(${parameters}): ${childSinature.type?.name}, // ${childSinature.comment?.summary[0]?.text}\n `;
} else {
const childType = child.type.elementType ? child.type.elementType.name : child.type.name;
type += ` \t ${child.name}: ${childType}, // ${child.comment?.summary[0]?.text}\n `;
}
});
}
type = `{\n ${type} }`;
}
return {
name: param.name,
optional: param.flags.isOptional,
type: type,
description: param.comment && param.comment.summary.map((s) => parseText(s.text || '')).join(' ')
};
}),
returnType: signature.type.toString(),
description: signature.comment && signature.comment.summary.map((s) => parseText(s.text || '')).join(' ')
});
});
doc[name]['model'][model.name] = { doc[name]['model'][model.name] = {
description: event_props_description, description: event_props_description,
props props,
methods
}; };
}); });

View File

@ -278,6 +278,7 @@ export interface AutoCompleteProps {
/** /**
* Defines valid slots in AutoComplete component. * Defines valid slots in AutoComplete component.
* @todo Next release we should complete types for all slots
*/ */
export interface AutoCompleteSlots { export interface AutoCompleteSlots {
/** /**

View File

@ -41,8 +41,9 @@ export interface ConfirmationOptions {
blockScroll?: boolean | undefined; blockScroll?: boolean | undefined;
/** /**
* Callback to execute when action is confirmed. * Callback to execute when action is confirmed.
* @todo Next release should be able to change
*/ */
accept?(): void; accept?: () => void;
/** /**
* Callback to execute when action is rejected. * Callback to execute when action is rejected.
*/ */
@ -50,7 +51,7 @@ export interface ConfirmationOptions {
/** /**
* Callback to execute when dialog is hidden. * Callback to execute when dialog is hidden.
*/ */
onHide?(): void; onHide?: () => void;
/** /**
* Label of the accept button. Defaults to PrimeVue Locale configuration. * Label of the accept button. Defaults to PrimeVue Locale configuration.
*/ */

View File

@ -2,7 +2,7 @@
* *
* [Live Demo](https://www.primevue.org/confirmdialog/) * [Live Demo](https://www.primevue.org/confirmdialog/)
* *
* @module confirmationservice * @module confirmationservice-useconfirm
* *
*/ */
import { Plugin } from 'vue'; import { Plugin } from 'vue';
@ -13,9 +13,7 @@ export default plugin;
/** /**
* Confirmation Service methods. * Confirmation Service methods.
* * @group Model
* @group Interfaces
*
*/ */
export interface ConfirmationServiceMethods { export interface ConfirmationServiceMethods {
/** /**

View File

@ -2,7 +2,7 @@
* *
* [Live Demo](https://www.primevue.org/dynamicdialog/) * [Live Demo](https://www.primevue.org/dynamicdialog/)
* *
* @module dialogservice * @module dialogservice-usedialog
* *
*/ */
import { Plugin } from 'vue'; import { Plugin } from 'vue';
@ -14,7 +14,7 @@ export default plugin;
/** /**
* Dynamic Dialog components methods. * Dynamic Dialog components methods.
* *
* @group Interfaces * @group Model
* *
*/ */
export interface DialogServiceMethods { export interface DialogServiceMethods {
@ -24,7 +24,7 @@ export interface DialogServiceMethods {
* @param {DynamicDialogOptions} options - DynamicDialog Object * @param {DynamicDialogOptions} options - DynamicDialog Object
* @return {@link DynamicDialogInstance} * @return {@link DynamicDialogInstance}
*/ */
open: (content: any, options?: DynamicDialogOptions) => DynamicDialogInstance; open(content: any, options?: DynamicDialogOptions): DynamicDialogInstance;
} }
declare module 'vue/types/vue' { declare module 'vue/types/vue' {

View File

@ -7,7 +7,7 @@
/** /**
* Confirmation Service methods. * Confirmation Service methods.
* *
* @group Interfaces * @group Model
* *
*/ */
export interface TerminalServiceOptions { export interface TerminalServiceOptions {

View File

@ -2,8 +2,8 @@
* *
* [Live Demo](https://www.primevue.org/toast/) * [Live Demo](https://www.primevue.org/toast/)
* *
* @module toastservice * @module toastservice-usetoast
* * @todo 'use' is not a valid name for a module. Next release will change.
*/ */
import { Plugin } from 'vue'; import { Plugin } from 'vue';
import { ToastMessageOptions } from '../toast'; import { ToastMessageOptions } from '../toast';
@ -14,7 +14,7 @@ export default plugin;
/** /**
* Toast Service methods. * Toast Service methods.
* *
* @group Interfaces * @group Model
* *
*/ */
export interface ToastServiceMethods { export interface ToastServiceMethods {

File diff suppressed because it is too large Load Diff

View File

@ -48,18 +48,29 @@ export default {
docName: docName docName: docName
}; };
const values = APIDocs[moduleName].interfaces.values; const values = APIDocs[moduleName]?.interfaces?.values;
const componentValues = APIDocs[moduleName]?.components; const componentValues = APIDocs[moduleName]?.components;
const modelValues = APIDocs[moduleName]?.model;
let props = null;
let emits = null;
let slots = null;
let events = null;
let options = null;
let interfaces = null;
if (values) {
props = values[`${docName}Props`];
emits = values[`${docName}Emits`];
slots = values[`${docName}Slots`];
events = this.findEvents(values);
options = this.findOptions(values, docName); // MenuItem && ConfirmationOptions
interfaces = this.findOtherInterfaces(values, docName);
}
const props = values[`${docName}Props`];
const emits = values[`${docName}Emits`];
const slots = values[`${docName}Slots`];
const methods = componentValues ? componentValues['default'].methods : null; const methods = componentValues ? componentValues['default'].methods : null;
const types = APIDocs[moduleName]['types']; const types = APIDocs[moduleName]['types'];
let events = this.findEvents(values);
const interfaces = this.findOtherInterfaces(values, docName);
const options = this.findOptions(values, docName); // Only for MenuItem const services = modelValues; // (TerminalService && ConfirmationService && ToastService)
if (props && props.props.length) { if (props && props.props.length) {
newDoc.children.push({ newDoc.children.push({
@ -101,7 +112,7 @@ export default {
}); });
} }
if (events && events.length) { if (events && events.length > 0) {
newDoc.children.push({ newDoc.children.push({
id: `api.${moduleName}.events`, id: `api.${moduleName}.events`,
label: 'Events', label: 'Events',
@ -144,6 +155,17 @@ export default {
}); });
} }
if (services) {
console.log(services);
newDoc.children.push({
id: `api.${moduleName}.services`,
label: 'Services',
component: DocApiTable,
data: this.setServicesData(moduleName, services),
description: Object.values(services)[0].description || null
});
}
newDocs.push(newDoc); newDocs.push(newDoc);
} }
@ -257,6 +279,27 @@ export default {
return data; return data;
}, },
setServicesData(moduleName, services) {
const data = [];
for (const key of Object.keys(services)) {
const value = services[key];
value?.methods.values.forEach((method) => {
data.push({
name: method.name,
parameters: {
name: method.parameters[0]?.name,
type: method.parameters[0]?.type
},
returnType: method.returnType,
description: method.description
});
});
}
return data;
},
findEvents(values) { findEvents(values) {
const events = []; const events = [];

View File

@ -95,7 +95,7 @@ export default {
isLinkType(value) { isLinkType(value) {
if (this.label === 'Slots') return false; if (this.label === 'Slots') return false;
return value.toLowerCase().includes(this.$route.hash.replace('#api.', '').split('.')[0].toLowerCase()); return value.toLowerCase().includes(this.id.split('.')[1]);
}, },
setLinkPath(value, type) { setLinkPath(value, type) {
const currentRoute = this.$router.currentRoute.value.name; const currentRoute = this.$router.currentRoute.value.name;

View File

@ -4,7 +4,7 @@
header="ConfirmDialog" header="ConfirmDialog"
description="ConfirmDialog uses a Dialog UI that is integrated with the Confirmation API." description="ConfirmDialog uses a Dialog UI that is integrated with the Confirmation API."
:componentDocs="docs" :componentDocs="docs"
:apiDocs="['ConfirmDialog', 'ConfirmationService', 'ConfirmationOptions']" :apiDocs="['ConfirmDialog', 'ConfirmationService-UseConfirm', 'ConfirmationOptions']"
/> />
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<DocComponent title="Vue Dialog Component" header="Dialog" description="Dialog is a container to display content in an overlay window" :componentDocs="docs" :apiDocs="['Dialog']" /> <DocComponent title="Vue Dialog Component" header="Dialog" description="Dialog is a container to display content in an overlay window" :componentDocs="docs" :apiDocs="['Dialog', 'DialogService-UseDialog']" />
</template> </template>
<script> <script>

View File

@ -1,5 +1,5 @@
<template> <template>
<DocComponent title="Vue Toast Component" header="Toast" description="Toast is used to display messages in an overlay." :componentDocs="docs" :apiDocs="['Toast', 'ToastService']" /> <DocComponent title="Vue Toast Component" header="Toast" description="Toast is used to display messages in an overlay." :componentDocs="docs" :apiDocs="['Toast', 'ToastService-UseToast']" />
</template> </template>
<script> <script>