From 3b475fd478dddb2fd5dbf914da12e28364e7a7f9 Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Thu, 13 Apr 2023 07:20:00 -0500 Subject: [PATCH] Made classes, interfaces, and enums list their members --- docs/.vitepress/theme/vars.css | 1 + .../resources/partials/member.declaration.hbs | 30 +++++++++++++++++++ profectus-theme/theme.ts | 27 ++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/theme/vars.css b/docs/.vitepress/theme/vars.css index 49493ebf..ca73741c 100644 --- a/docs/.vitepress/theme/vars.css +++ b/docs/.vitepress/theme/vars.css @@ -1,6 +1,7 @@ :root { --vp-c-bg: #2E3440; --vp-c-bg-alt: #3B4252; + --vp-c-bg-elv: #3B4252; --vp-code-block-bg: #434C5E; --vp-c-text-light-1: #D8DEE9; --vp-c-text-light-2: #E5E9F0; diff --git a/profectus-theme/resources/partials/member.declaration.hbs b/profectus-theme/resources/partials/member.declaration.hbs index 1ca0b747..aa9d4efb 100644 --- a/profectus-theme/resources/partials/member.declaration.hbs +++ b/profectus-theme/resources/partials/member.declaration.hbs @@ -68,4 +68,34 @@ {{/if}} +{{#when this this.kindString 'eq' 'Interface'}} + +{{#with this.children}} + +{{{typeDeclarationMembers}}} + +{{/with}} + +{{/when}} + +{{#when this this.kindString 'eq' 'Class'}} + +{{#with this.children}} + +{{{typeDeclarationMembers}}} + +{{/with}} + +{{/when}} + +{{#when this this.kindString 'eq' 'Enumeration'}} + +{{#with this.parent.children}} + +{{{typeDeclarationMembers}}} + +{{/with}} + +{{/when}} + {{> member.sources}} \ No newline at end of file diff --git a/profectus-theme/theme.ts b/profectus-theme/theme.ts index ef50a578..581f64c6 100644 --- a/profectus-theme/theme.ts +++ b/profectus-theme/theme.ts @@ -14,6 +14,7 @@ import { MarkdownTheme } from 'typedoc-plugin-markdown'; import registerTypeHelper from './type'; const TEMPLATE_PATH = path.join(__dirname, '..', 'profectus-theme', 'resources', 'templates'); +const PARTIALS_PATH = path.join(__dirname, '..', 'profectus-theme', 'resources', 'partials'); export class ProfectusTheme extends MarkdownTheme { constructor(renderer: Renderer) { @@ -23,7 +24,31 @@ export class ProfectusTheme extends MarkdownTheme { this.hideBreadcrumbs = true; this.hideInPageTOC = true; - // registerTypeHelper(); + const partialFiles = fs.readdirSync(PARTIALS_PATH); + partialFiles.forEach((partialFile) => { + const partialName = path.basename(partialFile, '.hbs'); + const partialContent = fs + .readFileSync(PARTIALS_PATH + '/' + partialFile) + .toString(); + Handlebars.registerPartial(partialName, partialContent); + }); + + Handlebars.registerHelper("when", (context, operand_1, operator, operand_2, options) => { + let operators = { // {{#when 'eq' }} + 'eq': (l,r) => l == r, // {{/when}} + 'noteq': (l,r) => l != r, + 'gt': (l,r) => (+l) > (+r), // {{#when var1 'eq' var2}} + 'gteq': (l,r) => ((+l) > (+r)) || (l == r), // eq + 'lt': (l,r) => (+l) < (+r), // {{else when var1 'gt' var2}} + 'lteq': (l,r) => ((+l) < (+r)) || (l == r), // gt + 'or': (l,r) => l || r, // {{else}} + 'and': (l,r) => l && r, // lt + '%': (l,r) => (l % r) === 0 // {{/when}} + } + let result = operators[operator](operand_1,operand_2); + if(result) return options.fn(context); + return options.inverse(context); + }); } getReflectionMemberTemplate() {