Skip to content

Commit

Permalink
feat(plugin-pages): use new option format, fix issue with pages order…
Browse files Browse the repository at this point in the history
…ing, rework theme plugins
  • Loading branch information
GerkinDev committed Mar 1, 2022
1 parent 878baf8 commit 0afdf9d
Show file tree
Hide file tree
Showing 21 changed files with 176 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`Real behavior should render correctly 1`] = `
<link rel=\\"stylesheet\\" href=\\"../assets/style.css\\" />
<link rel=\\"stylesheet\\" href=\\"../assets/highlight.css\\" />
<script async src=\\"../assets/search.js\\" id=\\"search-script\\"></script>
<link rel=\\"stylesheet\\" href=\\"../assets/pages.css\\" />
</head>
<body>
Expand Down Expand Up @@ -111,10 +112,10 @@ exports[`Real behavior should render correctly 1`] = `
<nav class=\\"tsd-navigation primary\\">
<ul>
<li class=\\"\\"><a href=\\"../modules.html\\">Exports</a></li>
<li class=\\" undefined\\"><a>Qux</a></li>
<li class=\\" undefined\\"><a href=\\"../pages/qux/baaz.html\\">Baaz</a></li>
<li class=\\" undefined\\"><a href=\\"../pages/foo/index.html\\">Foo</a></li>
<li class=\\" undefined\\"><a href=\\"../pages/foo/bar.html\\">Bar</a></li>
<li class=\\" pages-entry pages-entry-page pages-entry-depth-0\\"><a href=\\"../pages/foo/index.html\\">Foo</a></li>
<li class=\\" pages-entry pages-entry-page pages-entry-depth-1\\"><a href=\\"../pages/foo/bar.html\\">Bar</a></li>
<li class=\\" pages-entry pages-entry-menu pages-entry-depth-0\\"><a>Qux</a></li>
<li class=\\" pages-entry pages-entry-page pages-entry-depth-1\\"><a href=\\"../pages/qux/baaz.html\\">Baaz</a></li>
</ul>
</nav>
<nav class=\\"tsd-navigation secondary menu-sticky\\">
Expand Down
57 changes: 57 additions & 0 deletions packages/typedoc-plugin-pages/src/options/build-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { LogLevel, ParameterHint, ParameterType } from 'typedoc';

import { OptionGroup } from '@knodes/typedoc-pluginutils';

import type { PagesPlugin } from '../plugin';
import { EInvalidPageLinkHandling, IPluginOptions } from './plugin-options';


export const buildOptions = ( plugin: PagesPlugin ) => OptionGroup.factory<IPluginOptions>( plugin )
.add( 'enablePageLinks', {
help: 'Whether or not @page and @pagelink tags should be parsed.',
type: ParameterType.Boolean,
defaultValue: true,
} )
.add( 'enableSearch', {
help: 'Whether or not the pages should be added to the search index.',
type: ParameterType.Boolean,
defaultValue: true,
} )
.add( 'searchBoost', {
help: 'The score multiplier for pages in search.',
type: ParameterType.Number,
defaultValue: 10,
} )
.add( 'invalidPageLinkHandling', {
help: 'The kind of error to throw in case of an invalid page link.',
type: ParameterType.Map,
map: EInvalidPageLinkHandling,
defaultValue: EInvalidPageLinkHandling.FAIL,
} )
.add( 'pages', {
help: 'Actual pages definitions.',
type: ParameterType.Mixed,
}, v => {
v = v ?? [];
// TODO: Better checks
return v as any;
} )
.add( 'output', {
help: 'Output directory where your pages will be rendered. This must be a relative path.',
type: ParameterType.Path,
hint: ParameterHint.Directory,
defaultValue: 'pages',
}, v => plugin.relativeToRoot( v ) )
.add( 'source', {
help: 'Root directory where all page source files live.',
type: ParameterType.Path,
hint: ParameterHint.Directory,
defaultValue: 'pages',
} )
.add( 'logLevel', {
help: 'The plugin log level.',
type: ParameterType.Map,
map: LogLevel,
defaultValue: plugin.application.logger.level,
} )
.build();
2 changes: 1 addition & 1 deletion packages/typedoc-plugin-pages/src/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './build-options';
export * from './pages';
export * from './plugin-options';
export * from './read-plugin-options';
48 changes: 24 additions & 24 deletions packages/typedoc-plugin-pages/src/options/plugin-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,68 @@ import { LogLevel } from 'typedoc';

import { IRootPageNode } from './pages';

export enum EInvalidPageLinkHandling{
FAIL,
LOG_ERROR,
LOG_WARN,
NONE
}
/**
* Plugin options
*/
export interface IPluginOptions {
/**
* Whether or not @page and @pagelink tags should be parsed
* Whether or not @page and @pagelink tags should be parsed.
*
* Defaults to true.
* @default true
*/
enablePageLinks?: boolean;

/**
* Whether or not the pages should be added to the search index
* Whether or not the pages should be added to the search index.
*
* This defaults to true.
* @default true
*/
enableSearch?: boolean;

searchBoost?: number;

/**
* Whether or not invalid page links should fail the TypeDoc build
* The score multiplier for pages in search.
*
* This defaults to false.
* @default 10
*/
failBuildOnInvalidPageLink?: boolean;
searchBoost?: number;

/**
* Page group definitions
* The kind of error to throw in case of an invalid page link.
*
* This is where you define the groups your pages live in.
* @default EInvalidPageLinkHandling.FAIL
*/
pages?: IRootPageNode[];
invalidPageLinkHandling?: EInvalidPageLinkHandling;

/**
* Writes a list of any broken page links to the console
*
* This defaults to false.
* Actual pages definitions.
*/
listInvalidPageLinks?: boolean;
pages?: IRootPageNode[];

/**
* Output directory where your pages will be rendered.
*
* This defaults to "pages".
* @default "pages".
*/
output?: string;

/**
* Title for the standard TypeDoc reflection items in the navigation sidebar
* Root directory where all page source files live.
*
* This defaults to "API".
* @default "pages"
*/
reflectionNavigationTitle?: string;
source?: string;

/**
* Root directory where all page source files live
* The plugin log level.
*
* By default this will point to the directory that TypeDoc is run from.
* @default application.logger.level
*/
source?: string;

logLevel?: LogLevel;
}

This file was deleted.

58 changes: 0 additions & 58 deletions packages/typedoc-plugin-pages/src/options/read-plugin-options.ts

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions packages/typedoc-plugin-pages/src/page-tree/index.ts

This file was deleted.

Loading

0 comments on commit 0afdf9d

Please sign in to comment.