Skip to content

Commit

Permalink
chore: Refactored and updated code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jan 22, 2024
1 parent d6fd802 commit c11c390
Show file tree
Hide file tree
Showing 150 changed files with 6,438 additions and 2,308 deletions.
6 changes: 6 additions & 0 deletions .changeset/dirty-walls-serve.md
@@ -0,0 +1,6 @@
---
"typedoc-plugin-markdown": patch
---

- Expose theme hooks similar to default theme.
- Expose TypedDoc media and include syntax.
8 changes: 8 additions & 0 deletions .changeset/happy-rats-help.md
@@ -0,0 +1,8 @@
---
"docusaurus-plugin-typedoc": patch
"typedoc-github-wiki-theme": patch
"typedoc-gitlab-wiki-theme": patch
"typedoc-vitepress-theme": patch
---

- Update core package dependency
9 changes: 7 additions & 2 deletions dev-packages/helpers/src/constants.ts
@@ -1,47 +1,52 @@
import { DocsConfig } from './models';

export const DECLARATIONS_PATH = `${process.cwd()}/src/options/declarations.ts`;

export const PRESETS_PATH = `${process.cwd()}/src/options/presets.ts`;

export const DOCS_CONFIG: Record<string, DocsConfig> = {
['typedoc-plugin-markdown']: {
declarationsPath: `${process.cwd()}/src/plugin/options/declarations.ts`,
optionsPath: 'options',
docsPath: '',
declarations: true,
presets: false,
},
['typedoc-plugin-frontmatter']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: 'utilities/frontmatter',
docsPath: '/utilities/frontmatter',
declarations: true,
presets: false,
},
['typedoc-plugin-remark']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: 'utilities/remark',
docsPath: '/utilities/remark',
declarations: true,
presets: false,
},
['typedoc-github-wiki-theme']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: 'themes/github-wiki',
docsPath: '/themes/github-wiki',
declarations: true,
presets: true,
},
['typedoc-gitlab-wiki-theme']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: 'themes/gitlab-wiki',
docsPath: '/themes/gitlab-wiki',
declarations: true,
presets: true,
},
['typedoc-vitepress-theme']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: 'themes/vitepress',
docsPath: '/themes/vitepress',
declarations: true,
presets: false,
},
['docusaurus-plugin-typedoc']: {
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
optionsPath: '/integrations/docusaurus/options',
docsPath: '/integrations/docusaurus',
declarations: false,
Expand Down
1 change: 1 addition & 0 deletions dev-packages/helpers/src/models.ts
@@ -1,4 +1,5 @@
export interface DocsConfig {
declarationsPath: string;
optionsPath: string;
docsPath: string;
declarations: boolean;
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/prebuild-options/cli.ts
Expand Up @@ -10,7 +10,7 @@ main();
async function main() {
const docsConfig: DocsConfig = DOCS_CONFIG[getPackageName()];
if (docsConfig.declarations) {
await generateModels();
await generateModels(docsConfig.declarationsPath);
}
await generateDocs(docsConfig);
consola.success(`[${getPackageName()}] Prebuild options complete`);
Expand Down
5 changes: 2 additions & 3 deletions dev-packages/prebuild-options/tasks/generate-docs.ts
@@ -1,4 +1,3 @@
import { DECLARATIONS_PATH } from '@dev-packages/helpers';
import { DocsConfig } from '@dev-packages/helpers/src/models';
import * as fs from 'fs';
import * as path from 'path';
Expand All @@ -21,8 +20,8 @@ export async function generateDocs(docsConfig: DocsConfig) {

// DECLARATIONS
if (docsConfig.declarations) {
const declarationsConfig: any = await import(DECLARATIONS_PATH);
const configFileTs = project.getSourceFile(DECLARATIONS_PATH);
const declarationsConfig: any = await import(docsConfig.declarationsPath);
const configFileTs = project.getSourceFile(docsConfig.declarationsPath);

const optionsVariableStatements =
configFileTs?.getVariableStatements() as VariableStatement[];
Expand Down
11 changes: 4 additions & 7 deletions dev-packages/prebuild-options/tasks/generate-models.ts
@@ -1,4 +1,3 @@
import { DECLARATIONS_PATH } from '@dev-packages/helpers';
import * as fs from 'fs';
import * as path from 'path';
import * as prettier from 'prettier';
Expand All @@ -8,8 +7,8 @@ import { DeclarationOption, ParameterType } from 'typedoc';
* Creates models for plugin options
*/

export async function generateModels() {
const optionsConfig = await import(DECLARATIONS_PATH);
export async function generateModels(declarationsPath: string) {
const optionsConfig = await import(declarationsPath);

const mixedTypes = (Object.entries(optionsConfig) as any).filter(
([name, option]) =>
Expand Down Expand Up @@ -59,10 +58,8 @@ export async function generateModels() {
`;

const optionsModelFile = path.join(
process.cwd(),
'src',
'options',
'models.ts',
path.dirname(declarationsPath),
'option-types.ts',
);

const formatted = await prettier.format(optionsOutput, {
Expand Down
1 change: 1 addition & 0 deletions docs/pages/_meta.json
Expand Up @@ -2,6 +2,7 @@
"index": "Introduction",
"quick-start": "",
"options": "",
"guides": "Guides",
"examples": "",
"-- RelatedPlugin": {
"type": "separator",
Expand Down
42 changes: 42 additions & 0 deletions docs/pages/guides/custom-theme.md
@@ -0,0 +1,42 @@
# Custom Theme

If required the theme can be further extended using recommended patterns of the HTML theme - please see TypeDoc's [custom theme](https://github.com/TypeStrong/typedoc/blob/master/internal-docs/custom-themes.md) docs.

This approach can be implemented in this example showing how the header and footer templates can be customized with a new theme using a customn plugin.

```ts filename="custom-plugin.ts"
import { Application, PageEvent, Reflection } from "typedoc";
import {
MarkdownTheme,
MarkdownThemeRenderContext,
} from "typedoc-plugin-markdown";

export function load(app: Application) {
app.renderer.defineTheme("custom-markdown-theme", CustomTheme);
}

class CustomMarkdownTheme extends MarkdownTheme {
override getRenderContext(pageEvent: PageEvent<Reflection>) {
return new CustomMarkdownTheme(pageEvent, this.application.options);
}
}

class CustomMarkdownTheme extends MarkdownThemeRenderContext {
override header = () => {
return "CUSTOM HEADER HERE";
};

override footer = () => {
return "CUSTOM FOOTER HERE";
};
}
```

To theme can then be added to the TypeDoc config as follows:

```json filename="typedoc.json"
{
"plugin": ["typedoc-plugin-markdown", "./dist/custom-plugin"],
"theme": "custom-markdown-theme"
}
```
3 changes: 3 additions & 0 deletions docs/pages/guides/custom-theme/_meta.json
@@ -0,0 +1,3 @@
{
"api": "API"
}
3 changes: 3 additions & 0 deletions docs/pages/guides/custom-theme/api.md
@@ -0,0 +1,3 @@
# API

Please note you have a theme context.

0 comments on commit c11c390

Please sign in to comment.