Skip to content

Commit

Permalink
feat(core): added footer partial and footer.text mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Apr 29, 2024
1 parent d6ee5a2 commit 2e5959c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-teachers-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"typedoc-plugin-markdown": patch
---

- Added footer partial and footer.text mappings
9 changes: 4 additions & 5 deletions packages/typedoc-plugin-markdown/src/options/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,10 @@ export const indexFormat: Partial<DeclarationOption> = {
*
* Keys are categorised with the following namespace conventions:
*
* - `header.*` defines text in the page header (if displayed).
* - `breadcrumbs.*` defines breadcrumbs in page header (if displayed).
* - `title.*` defines text in main page titles.
* - `label.*` other text in page content, including content headings and table headers.
* - `kind.*` defines text mappings to TypeDoc's `ReflectionKind` definitions.
* - `header.*`, `breadcrumbs.*`,`footer.*`: Text in main page elements (if displayed).
* - `title.*`: Text in main page titles.
* - `label.*` Text in page content, including content headings and table headers.
* - `kind.*` Text mappings to TypeDoc's `ReflectionKind` definitions.
*
* Only keys that require translation need to be added to the object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export interface TextContentMappings {
'header.title': string;
'header.docs': string;
'breadcrumbs.home': string;
'footer.text': string;
'title.indexPage': string;
'title.modulePage': string;
'title.memberPage': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const TEXT_MAPPING_DEFAULTS = {
'header.title': '{projectName} {version}',
'header.docs': 'Docs',
'breadcrumbs.home': '{projectName} {version}',
'footer.text': '',
'title.indexPage': '{projectName} {version}',
'title.modulePage': '{name}',
'title.memberPage': '{kind}: {name}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ import { typeDeclarationTable } from './partials/member.typeDeclarationTable';
import { typeParametersList } from './partials/member.typeParametersList';
import { typeParametersTable } from './partials/member.typeParametersTable';
import { breadcrumbs } from './partials/page.breadcrumbs';
import { footer } from './partials/page.footer';
import { header } from './partials/page.header';
import { packagesIndex } from './partials/page.packagesIndex';
import { pageTitle } from './partials/page.pageTtitle';
import { pageTitle } from './partials/page.pageTitle';
import { arrayType } from './partials/type.array';
import { conditionalType } from './partials/type.conditional';
import { indexAccessType } from './partials/type.index-access';
Expand Down Expand Up @@ -434,6 +435,12 @@ There is no association list partial for properties as these are handled as a st
* @category Page Partials
*/
breadcrumbs: () => breadcrumbs.apply(context, []) as string,
/**
*
*
* @category Page Partials
*/
footer: () => footer.apply(context, []) as string,
/**
*
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { MarkdownThemeContext } from '@plugin/theme';

/**
* @category Page Partials
*/
export function footer(this: MarkdownThemeContext): string {
const text = this.getText('footer.text');
return text ? `***\n\n${text}` : ``;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export function project(this: MarkdownThemeContext) {
md.push(this.partials.body(model, { headingLevel: 2 }));
}

md.push(this.partials.footer());

md.push(this.hook('index.page.end').join('\n'));

return md.join('\n\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ export function readme(this: MarkdownThemeContext) {
md.push(this.partials.commentParts(model.readme as CommentDisplayPart[]));
}

md.push(this.partials.footer());

return md.join('\n\n');
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export function reflection(this: MarkdownThemeContext) {
md.push(this.partials.member(model, { headingLevel: 1 }));
}

md.push(this.partials.footer());

md.push(this.hook('page.end').join('\n'));

return md.join('\n\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
textContentMappings: {
'header.title': 'My API - {version}',
'header.docs': 'API',
'footer.text': 'Copyright Test',
'title.indexPage': ':tada: Custom Index Title',
'title.memberPage': '{name}',
'title.modulePage': '{kind} - {name}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ exports[`Text should get translations for index page: (Output File Strategy "mem
- [module-1](module-1/README.md)
- [module-2](module-2/README.md)
***
Copyright Test
"
`;

Expand All @@ -34,6 +38,10 @@ exports[`Text should get translations for member page: (Output File Strategy "me
| Event! | Type |
| :------ | :------ |
| \`someEvent\` | \`MouseEvent\` |
***
Copyright Test
"
`;

Expand All @@ -51,6 +59,10 @@ exports[`Text should get translations for module page: (Output File Strategy "me
### 多变的
- [SomeInterface](interfaces/SomeInterface.md)
***
Copyright Test
"
`;

Expand All @@ -68,6 +80,10 @@ exports[`Text should get translations for modules page: (Output File Strategy "m
### constA
> \`const\` **constA**: \`true\` = \`true\`
***
Copyright Test
"
`;

Expand Down

0 comments on commit 2e5959c

Please sign in to comment.