Skip to content

Commit

Permalink
Added hideMembersSymbol option
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Apr 7, 2022
1 parent 8e2f8c5 commit 2686d9b
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-typedoc/src/options.ts
Expand Up @@ -15,6 +15,7 @@ const DEFAULT_PLUGIN_OPTIONS: PluginOptions = {
hideInPageTOC: true,
hideBreadcrumbs: true,
hidePageTitle: true,
hideMembersSymbol: false,
entryDocument: 'index.md',
plugin: ['none'],
watch: false,
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-typedoc/src/types.ts
Expand Up @@ -14,6 +14,7 @@ export interface PluginOptions {
hideInPageTOC: boolean;
hideBreadcrumbs: boolean;
hidePageTitle: boolean;
hideMembersSymbol: boolean;
entryDocument: string;
includeExtension?: boolean;
indexSlug?: string;
Expand Down
Expand Up @@ -27,6 +27,7 @@ Object {
"frontmatter": undefined,
"hideBreadcrumbs": true,
"hideInPageTOC": true,
"hideMembersSymbol": false,
"hidePageTitle": true,
"id": "default",
"includeExtension": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/typedoc-plugin-markdown/README.md
Expand Up @@ -39,6 +39,8 @@ The following options can be used in addition to relevant [TypeDoc options](http
Do not render breadcrumbs in template header. Defaults to `false`.
- `--hideInPageTOC<boolean>`<br>
Do not render in-page table of contents items. Defaults to `false`.
- `--hideMembersSymbol<boolean>`<br>
Do not add special symbols for class members. Defaults to `false`.
- `--publicPath<string>`<br>
Specify the base path for all urls. If undefined urls will be relative. Defaults to `.`.
- `--namedAnchors<boolean>`<br>
Expand Down
7 changes: 7 additions & 0 deletions packages/typedoc-plugin-markdown/src/index.ts
Expand Up @@ -66,6 +66,13 @@ export function load(app: Application) {
name: 'indexTitle',
type: ParameterType.String,
});

app.options.addDeclaration({
help: '[Markdown Plugin] Do not add special symbols for class members.',
name: 'hideMembersSymbol',
type: ParameterType.Boolean,
defaultValue: false,
});
}

export { MarkdownTheme };
4 changes: 2 additions & 2 deletions packages/typedoc-plugin-markdown/src/render-utils.ts
Expand Up @@ -60,7 +60,7 @@ export function registerHelpers(theme: MarkdownTheme) {
breadcrumbsHelper(theme);
commentHelper(theme);
commentsHelper();
declarationTitleHelper();
declarationTitleHelper(theme);
escapeHelper();
hierarchyHelper();
ifIsReference();
Expand All @@ -77,7 +77,7 @@ export function registerHelpers(theme: MarkdownTheme) {
reflectionPathHelper();
reflectionTitleHelper(theme);
relativeUrlHelper(theme);
signatureTitleHelper();
signatureTitleHelper(theme);
tocHelper(theme);
typeHelper();
typeAndParentHelper();
Expand Down
Expand Up @@ -12,12 +12,13 @@ import {
stripComments,
stripLineBreaks,
} from '../../utils';
import { MarkdownTheme } from '../../theme';

export default function () {
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper(
'declarationTitle',
function (this: ParameterReflection | DeclarationReflection) {
const md = [memberSymbol(this)];
const md = theme.hideMembersSymbol ? [] : [memberSymbol(this)];

function getType(
reflection: ParameterReflection | DeclarationReflection,
Expand Down
Expand Up @@ -5,14 +5,15 @@ import {
SignatureReflection,
} from 'typedoc';
import { memberSymbol } from '../../utils';
import { MarkdownTheme } from '../../theme';

export default function () {
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper(
'signatureTitle',
function (this: SignatureReflection, accessor?: string, standalone = true) {
const md: string[] = [];

if (standalone) {
if (standalone && !theme.hideMembersSymbol) {
md.push(`${memberSymbol(this)} `);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/typedoc-plugin-markdown/src/theme.ts
Expand Up @@ -32,6 +32,7 @@ export class MarkdownTheme extends Theme {
hideBreadcrumbs!: boolean;
hideInPageTOC!: boolean;
hidePageTitle!: boolean;
hideMembersSymbol!: boolean;
includes!: string;
indexTitle!: string;
mediaDirectory!: string;
Expand All @@ -57,6 +58,7 @@ export class MarkdownTheme extends Theme {
this.hideBreadcrumbs = this.getOption('hideBreadcrumbs') as boolean;
this.hideInPageTOC = this.getOption('hideInPageTOC') as boolean;
this.hidePageTitle = this.getOption('hidePageTitle') as boolean;
this.hideMembersSymbol = this.getOption('hideMembersSymbol') as boolean;
this.includes = this.getOption('includes') as string;
this.indexTitle = this.getOption('indexTitle') as string;
this.mediaDirectory = this.getOption('media') as string;
Expand Down
Expand Up @@ -83,3 +83,18 @@ exports[`Members: (members) should compile module members' 1`] = `
"
"
`;

exports[`Members: (with hideMembersSymbol) should compile members without special symbols 1`] = `
"### signatureMember
**signatureMember**(): \`void\`
#### Returns
\`void\`
[partial: member.sources]
___
"
`;
21 changes: 21 additions & 0 deletions packages/typedoc-plugin-markdown/test/specs/members.spec.ts
Expand Up @@ -74,4 +74,25 @@ describe(`Members:`, () => {
).toMatchSnapshot();
});
});

describe(`(with hideMembersSymbol)`, () => {
beforeAll(async () => {
testApp = new TestApp(['members.ts']);
await testApp.bootstrap({
hideMembersSymbol: true
});
TestApp.stubPartials(['member', 'member.sources']);

memberPartial = TestApp.getPartial('member');
});

test(`should compile members without special symbols`, () => {
expect(
TestApp.compileTemplate(
memberPartial,
testApp.findReflection('signatureMember'),
),
).toMatchSnapshot();
});
});
});

0 comments on commit 2686d9b

Please sign in to comment.