docusaurus-plugin-typedoc-api
Version:
Docusaurus plugin that provides source code API documentation powered by TypeDoc.
74 lines (70 loc) • 3.31 kB
JavaScript
'use strict';
const useMinimalLayout = require('../hooks/useMinimalLayout.js');
const useReflection = require('../hooks/useReflection.js');
const helpers = require('../utils/helpers.js');
const Comment = require('./Comment.js');
const DefaultValue = require('./DefaultValue.js');
const Icon = require('./Icon.js');
const MemberSources = require('./MemberSources.js');
const Parameter = require('./Parameter.js');
const Type = require('./Type.js');
const TypeParameters = require('./TypeParameters.js');
const TypeParametersGeneric = require('./TypeParametersGeneric.js');
const jsxRuntime = require('react/jsx-runtime');
// https://github.com/TypeStrong/typedoc-default-themes/blob/master/src/default/partials/member.declaration.hbs
function MemberDeclaration({
id
}) {
const reflection = useReflection.useRequiredReflection(id);
const minimal = useMinimalLayout.useMinimalLayout();
const showTypes = reflection.typeParameters && reflection.typeParameters.length > 0;
const showDeclaration = !minimal && Type.extractDeclarationFromType(reflection.type);
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
className: "tsd-panel-content",
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
className: "tsd-signature tsd-kind-icon",
children: [/*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
reflection: reflection
}), helpers.escapeMdx(reflection.name), /*#__PURE__*/jsxRuntime.jsx(TypeParametersGeneric.TypeParametersGeneric, {
params: reflection.typeParameters
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
className: "tsd-signature-symbol",
children: [reflection.flags?.isOptional && '?', ": "]
}), ' ', /*#__PURE__*/jsxRuntime.jsx(Type.Type, {
type: reflection.type
}), /*#__PURE__*/jsxRuntime.jsx(DefaultValue.DefaultValue, {
comment: reflection.comment,
type: reflection.type,
value: reflection.defaultValue
})]
})
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
className: "tsd-panel-content",
children: [/*#__PURE__*/jsxRuntime.jsx(MemberSources.MemberSources, {
reflection: reflection
}), /*#__PURE__*/jsxRuntime.jsx(Comment.Comment, {
comment: reflection.comment
}), Comment.hasComment(reflection.comment) && (showTypes || showDeclaration) && /*#__PURE__*/jsxRuntime.jsx("hr", {
className: "tsd-divider"
}), showTypes && /*#__PURE__*/jsxRuntime.jsxs("div", {
className: "tds-type-parameters",
children: [/*#__PURE__*/jsxRuntime.jsx("h4", {
className: "tsd-type-parameters-title",
children: "Type parameters"
}), /*#__PURE__*/jsxRuntime.jsx(TypeParameters.TypeParameters, {
params: reflection.typeParameters
})]
}), showDeclaration && /*#__PURE__*/jsxRuntime.jsxs("div", {
className: "tsd-type-declaration",
children: [/*#__PURE__*/jsxRuntime.jsx("h4", {
children: "Type declaration"
}), /*#__PURE__*/jsxRuntime.jsx(Parameter.Parameter, {
param: Type.extractDeclarationFromType(reflection.type)
})]
})]
})]
});
}
exports.MemberDeclaration = MemberDeclaration;
//# sourceMappingURL=MemberDeclaration.js.map