Skip to content

Commit

Permalink
fix(core): further typedoc beta fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed May 29, 2024
1 parent a927da9 commit 9571a40
Show file tree
Hide file tree
Showing 63 changed files with 1,363 additions and 466 deletions.
5 changes: 5 additions & 0 deletions devtools/packages/fixtures/typedoc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ module.exports = {
navigation: {
includeGroups: true,
},
locales: {
en: {
theme_defined_in: 'Source',
},
},
};
3 changes: 3 additions & 0 deletions devtools/packages/prebuild-options/tasks/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ function getDefaultValue(option) {
if (option.type === ParameterType.Mixed) {
return JSON.stringify(option.defaultValue);
}
if (option.type === ParameterType.Object) {
return JSON.stringify(option.defaultValue);
}
return `"${option.defaultValue}"`;
}

Expand Down
35 changes: 31 additions & 4 deletions devtools/packages/prebuild-options/tasks/generate-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ async function writeOptionsTypes(
option.type === ParameterType.Mixed && option.defaultValue,
);

const optionsOutput = `
// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY.
const optionsOutput: string[] = [
`// THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY.
`,
];
optionsOutput.push(`
/**
* Describes the options declared by the plugin.
*
Expand Down Expand Up @@ -117,14 +120,25 @@ ${name}: ${getType(name, option, true)};`,
`;
})
.join('\n')}
`;
`);

if (docsConfig.translatablePath) {
const { translatable } = await import(docsConfig.translatablePath);
optionsOutput.push(
`
/**
* @category Options
*/
export interface TranslatableStrings ${getTranslations(translatable)}`,
);
}

const optionsModelFile = path.join(
path.dirname(docsConfig.declarationsPath as string),
'option-types.ts',
);

const formatted = await prettier.format(optionsOutput, {
const formatted = await prettier.format(optionsOutput.join('\n\n'), {
parser: 'typescript',
singleQuote: true,
trailingComma: 'all',
Expand Down Expand Up @@ -208,6 +222,19 @@ function getType(
.map((value) => `"${value}"`)
.join(' | ')}`;
}
if (option.type === ParameterType.Object) {
const outType = `{${Object.keys(option.defaultValue as any)
.map((key) => `'${key}': ${getObjectType(name)};`)
.join('')}}`;
return isInterface ? outType : `ManuallyValidatedOption<${outType}>`;
}
return 'any';
}

function getObjectType(name: string) {
if (name === 'reflectionFormats') {
return "'list'|'table'|'htmlTable'";
}
return 'any';
}

Expand Down
43 changes: 30 additions & 13 deletions docs/pages/api-docs/Class.MarkdownPageEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,81 @@ export function load(app: MarkdownApplication) {

### project

> **project**: [`ProjectReflection`](https://typedoc.org/api/classes/Models.ProjectReflection.html)
```ts
project: ProjectReflection;
```

The project the renderer is currently processing.
The [`ProjectReflection`](https://typedoc.org/api/classes/Models.ProjectReflection.html) instance the renderer is currently processing.

***

### model

> `readonly` **model**: `Model`
```ts
readonly model: Model;
```

The model that should be rendered on this page.
The model that that is being rendered on this page.
Either a [`DeclarationReflection`](https://typedoc.org/api/classes/Models.DeclarationReflection.html) or [`ProjectReflection`](https://typedoc.org/api/classes/Models.ProjectReflection.html).

***

### url

> **url**: `string`
```ts
url: string;
```

The url this page will be located at.
The url `string` of the page.

***

### filename

> **filename**: `string`
```ts
filename: string;
```

The filename the page will be written to.
The complete `string` filename where the file will be written..

***

### contents?

> `optional` **contents**: `string`
```ts
optional contents: string;
```

The final markdown content of this page.
The final markdown `string` content of the page.

Should be rendered by layout templates and can be modified by plugins.

***

### frontmatter?

> `optional` **frontmatter**: `Record`\<`string`, `any`\>
```ts
optional frontmatter: Record<string, any>;
```

The frontmatter of this page represented as a key value object. This property can be utilised by other plugins.

## Events

### BEGIN

> `static` `readonly` **BEGIN**: `"beginPage"` = `'beginPage'`
```ts
static readonly BEGIN: "beginPage" = 'beginPage';
```

Triggered before a document will be rendered.

***

### END

> `static` `readonly` **END**: `"endPage"` = `'endPage'`
```ts
static readonly END: "endPage" = 'endPage';
```

Triggered after a document has been rendered, just before it is written to disc.
24 changes: 18 additions & 6 deletions docs/pages/api-docs/Class.MarkdownRendererEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,58 @@ app.renderer.on(MarkdownRendererEvent.BEGIN, (event) => {

### project

> `readonly` **project**: [`ProjectReflection`](https://typedoc.org/api/classes/Models.ProjectReflection.html)
```ts
readonly project: ProjectReflection;
```

The project the renderer is currently processing.

***

### outputDirectory

> `readonly` **outputDirectory**: `string`
```ts
readonly outputDirectory: string;
```

The path of the directory the documentation should be written to.

***

### urls?

> `optional` **urls**: [`UrlMapping`](/api-docs/Interface.UrlMapping.md)\<[`Reflection`](https://typedoc.org/api/classes/Models.Reflection.html)\>[]
```ts
optional urls: UrlMapping<Reflection>[];
```

A list of all pages that should be generated.

***

### navigation?

> `optional` **navigation**: [`NavigationItem`](/api-docs/Interface.NavigationItem.md)[]
```ts
optional navigation: NavigationItem[];
```

The navigation structure of the project that can be utilised by plugins.

## Events

### BEGIN

> `static` `readonly` **BEGIN**: `"beginRender"` = `'beginRender'`
```ts
static readonly BEGIN: "beginRender" = 'beginRender';
```

Triggered before the renderer starts rendering a project.

***

### END

> `static` `readonly` **END**: `"endRender"` = `'endRender'`
```ts
static readonly END: "endRender" = 'endRender';
```

Triggered after the renderer has written all documents.
36 changes: 33 additions & 3 deletions docs/pages/api-docs/Class.MarkdownTheme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,37 @@ class MyMarkdownTheme extends MarkdownTheme {

- [`Theme`](https://typedoc.org/api/classes/Theme.html)

## Constructors

### new MarkdownTheme()

```ts
new MarkdownTheme(renderer): MarkdownTheme
```

Create a new BaseTheme instance.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `renderer` | [`Renderer`](https://typedoc.org/api/classes/Renderer.html) | The renderer this theme is attached to. |

#### Returns

[`MarkdownTheme`](/api-docs/Class.MarkdownTheme.md)

#### Inherited from

`Theme.constructor`

## Methods

### getRenderContext()

> **getRenderContext**(`page`): [`MarkdownThemeContext`](/api-docs/Class.MarkdownThemeContext.md)
```ts
getRenderContext(page): MarkdownThemeContext
```

Creates a new instance of the current theme context.

Expand All @@ -48,7 +74,9 @@ This method can be overridden to provide an alternative theme context.

### getUrls()

> **getUrls**(`project`): [`UrlMapping`](/api-docs/Interface.UrlMapping.md)\<[`Reflection`](https://typedoc.org/api/classes/Models.Reflection.html)\>[]
```ts
getUrls(project): UrlMapping<Reflection>[]
```

Maps the models of the given project to the desired output files.

Expand All @@ -72,7 +100,9 @@ This method can be overriden to provide an alternative url structure.

### getNavigation()

> **getNavigation**(`project`): [`NavigationItem`](/api-docs/Interface.NavigationItem.md)[]
```ts
getNavigation(project): NavigationItem[]
```

Map the models of the given project to a navigation structure.

Expand Down
Loading

0 comments on commit 9571a40

Please sign in to comment.