Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert default themes to JSX; merge into typedoc repo #1634

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"printWidth": 120
}
104 changes: 99 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"marked": "^2.1.1",
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"shiki": "^0.9.3",
"typedoc-default-themes": "^0.12.10"
},
Expand Down
4 changes: 4 additions & 0 deletions src/lib/models/reflections/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ export class ReflectionFlags extends Array<string> {
return this.hasFlag(ReflectionFlag.Readonly);
}

get isExported() {
return TODO as boolean;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was being called from templates but not declared anywhere. Do you know what the implementation should be?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed in 0.20, it's always true now.


setFlag(flag: ReflectionFlag, set: boolean) {
switch (flag) {
case ReflectionFlag.Private:
Expand Down
19 changes: 7 additions & 12 deletions src/lib/output/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Path from "path";

import { Event } from "../utils/events";
import { ProjectReflection } from "../models/reflections/project";
import { UrlMapping } from "./models/UrlMapping";
import { RenderTemplate, UrlMapping } from "./models/UrlMapping";
import { NavigationItem } from "./models/NavigationItem";
import { LegendItem } from "./plugins/LegendPlugin";

Expand Down Expand Up @@ -66,13 +66,13 @@ export class RendererEvent extends Event {
* @param mapping The mapping that defines the generated [[PageEvent]] state.
* @returns A newly created [[PageEvent]] instance.
*/
public createPageEvent(mapping: UrlMapping): PageEvent {
const event = new PageEvent(PageEvent.BEGIN);
public createPageEvent<Model>(mapping: UrlMapping<Model>): PageEvent {
const event = new PageEvent<Model>(PageEvent.BEGIN);
event.project = this.project;
event.settings = this.settings;
event.url = mapping.url;
event.model = mapping.model;
event.templateName = mapping.template;
event.template = mapping.template;
event.filename = Path.join(this.outputDirectory, mapping.url);
return event;
}
Expand All @@ -87,7 +87,7 @@ export class RendererEvent extends Event {
* @see [[Renderer.EVENT_BEGIN_PAGE]]
* @see [[Renderer.EVENT_END_PAGE]]
*/
export class PageEvent extends Event {
export class PageEvent<Model = any> extends Event {
/**
* The project the renderer is currently processing.
*/
Expand All @@ -111,17 +111,12 @@ export class PageEvent extends Event {
/**
* The model that should be rendered on this page.
*/
model: any;
model!: Model;

/**
* The template that should be used to render this page.
*/
template?: TemplateDelegate;

/**
* The name of the template that should be used to render this page.
*/
templateName!: string;
template!: RenderTemplate<Model>;

/**
* The primary navigation structure of this page.
Expand Down
42 changes: 0 additions & 42 deletions src/lib/output/helpers/if-cond.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/lib/output/helpers/if-signature.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/lib/output/helpers/wbr.ts

This file was deleted.

25 changes: 25 additions & 0 deletions src/lib/output/helpers/wbr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from 'react';

/**
* Insert word break tags ``<wbr>`` into the given string.
*
* Breaks the given string at ``_``, ``-`` and capital letters.
*
* @param str The string that should be split.
* @return The original string containing ``<wbr>`` tags where possible.
*/
export function wbr(str: string): (string | Element)[] {
// TODO surely there is a better way to do this, but I'm tired.
const ret: (string | Element)[] = [];
const re = /^[\s\S]*?(?:([^_-][_-])(?=[^_-])|([^A-Z])(?=[A-Z][^A-Z]))/g;
let match: RegExpExecArray | null;
let i = 0;
while((match = re.exec(str))) {
ret.push(match[0]);
ret.push(<wbr />);
i += match.index + match[0].length;
}
ret.push(str.slice(i));

return ret;
}
12 changes: 8 additions & 4 deletions src/lib/output/models/UrlMapping.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { ReactElement } from "react";

/**
*
*/
export class UrlMapping {
export class UrlMapping<Model = any> {
url: string;

model: any;
model: Model;

template: string;
template: RenderTemplate<Model>;

constructor(url: string, model: any, template: string) {
constructor(url: string, model: any, template: RenderTemplate<Model>) {
this.url = url;
this.model = model;
this.template = template;
}
}

export type RenderTemplate<T> = (data: T) => ReactElement | string;
Loading