docusaurus-plugin-typedoc 1.0.0-next.2 → 1.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ const PLURALS = {
7
7
  [typedoc_1.ReflectionKind.Property]: 'Properties',
8
8
  [typedoc_1.ReflectionKind.Enum]: 'Enumerations',
9
9
  [typedoc_1.ReflectionKind.EnumMember]: 'Enumeration members',
10
+ [typedoc_1.ReflectionKind.Namespace]: 'Namespaces',
10
11
  [typedoc_1.ReflectionKind.TypeAlias]: 'Type aliases',
11
12
  };
12
13
  exports.CATEGORY_POSITION = {
package/dist/render.js CHANGED
@@ -41,10 +41,14 @@ async function render(project, outputDirectory) {
41
41
  const output = new typedoc_1.RendererEvent(typedoc_1.RendererEvent.BEGIN, outputDirectory, project);
42
42
  output.urls = this.theme.getUrls(project);
43
43
  this.trigger(output);
44
+ await Promise.all(this.preRenderAsyncJobs.map((job) => job(output)));
45
+ this.preRenderAsyncJobs = [];
44
46
  if (!output.isDefaultPrevented) {
45
- (_a = output === null || output === void 0 ? void 0 : output.urls) === null || _a === void 0 ? void 0 : _a.forEach((mapping) => {
46
- this.renderDocument(output.createPageEvent(mapping));
47
+ (_a = output.urls) === null || _a === void 0 ? void 0 : _a.forEach((mapping) => {
48
+ this.renderDocument(...output.createPageEvent(mapping));
47
49
  });
50
+ await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
51
+ this.postRenderAsyncJobs = [];
48
52
  this.trigger(typedoc_1.RendererEvent.END, output);
49
53
  }
50
54
  }
package/dist/theme.d.ts CHANGED
@@ -3,9 +3,7 @@ import { MarkdownTheme } from 'typedoc-plugin-markdown';
3
3
  import { SidebarOptions } from './types';
4
4
  export declare class DocusaurusTheme extends MarkdownTheme {
5
5
  sidebar: SidebarOptions;
6
- private _contextCache?;
7
6
  constructor(renderer: Renderer);
8
- getRenderContext(): any;
9
7
  onPageEnd(page: PageEvent<DeclarationReflection>): void;
10
8
  onRendererEnd(renderer: RendererEvent): void;
11
9
  loopAndWriteCategories(path: string): void;
package/dist/theme.js CHANGED
@@ -34,7 +34,6 @@ const fs = __importStar(require("fs"));
34
34
  const typedoc_1 = require("typedoc");
35
35
  const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
36
36
  const navigation_1 = require("./navigation");
37
- const theme_context_1 = require("./theme-context");
38
37
  class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
39
38
  constructor(renderer) {
40
39
  super(renderer);
@@ -55,10 +54,6 @@ class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
55
54
  [typedoc_1.RendererEvent.END]: this.onRendererEnd,
56
55
  });
57
56
  }
58
- getRenderContext() {
59
- this._contextCache || (this._contextCache = new theme_context_1.DocusaurusThemeRenderContext(this, this.application.options));
60
- return this._contextCache;
61
- }
62
57
  onPageEnd(page) {
63
58
  if (page.contents) {
64
59
  page.contents = page.contents.replace(/\\</g, '<');
@@ -68,6 +63,11 @@ class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
68
63
  if (this.sidebar.autoConfiguration) {
69
64
  this.writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed);
70
65
  this.loopAndWriteCategories(renderer.outputDirectory);
66
+ const globalsFile = this.getRenderContext().globalsFile;
67
+ const globalsPath = `${renderer.outputDirectory}/${this.getRenderContext().globalsFile}`;
68
+ if (fs.existsSync(globalsPath)) {
69
+ fs.renameSync(globalsPath, `${renderer.outputDirectory}/01-${globalsFile}`);
70
+ }
71
71
  }
72
72
  }
73
73
  loopAndWriteCategories(path) {
@@ -83,7 +83,8 @@ class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
83
83
  .map((entry) => entry[1])[0];
84
84
  const subdirectory = fs.readdirSync(fullPath);
85
85
  const containsDir = subdirectory.some((item) => fs.lstatSync(`${fullPath}/${item}`).isDirectory());
86
- if (mapping && !containsDir) {
86
+ if ((mapping && !containsDir) ||
87
+ (mapping === null || mapping === void 0 ? void 0 : mapping.kind) === typedoc_1.ReflectionKind.Namespace) {
87
88
  this.writeCategoryYaml(fullPath, (0, navigation_1.getKindPlural)(mapping.kind), navigation_1.CATEGORY_POSITION[mapping.kind], true);
88
89
  }
89
90
  this.loopAndWriteCategories(fullPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.0.0-next.2",
3
+ "version": "1.0.0-next.4",
4
4
  "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -16,8 +16,7 @@
16
16
  },
17
17
  "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
18
18
  "peerDependencies": {
19
- "typedoc": ">=0.23.0",
20
- "typedoc-plugin-markdown": ">=4.0.0-next.2"
19
+ "typedoc-plugin-markdown": ">=4.0.0-next.5"
21
20
  },
22
21
  "scripts": {
23
22
  "lint": "eslint ./src --ext .ts",
@@ -1,11 +0,0 @@
1
- import { DeclarationReflection, PageEvent, Reflection } from 'typedoc';
2
- import { MarkdownThemeRenderContext } from 'typedoc-plugin-markdown';
3
- export declare class DocusaurusThemeRenderContext extends MarkdownThemeRenderContext {
4
- baseFrontmatterVars: (page: PageEvent<Reflection>) => {
5
- sidebar_position?: number | undefined;
6
- sidebar_label?: string | undefined;
7
- title: string;
8
- };
9
- getSidebarLabel(page: PageEvent<DeclarationReflection>): string | null | undefined;
10
- getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
11
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocusaurusThemeRenderContext = void 0;
4
- const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
5
- class DocusaurusThemeRenderContext extends typedoc_plugin_markdown_1.MarkdownThemeRenderContext {
6
- constructor() {
7
- super(...arguments);
8
- this.baseFrontmatterVars = (page) => {
9
- const sidebarPosition = parseFloat(this.getSidebarPosition(page));
10
- const sidebarLabel = this.getSidebarLabel(page);
11
- return {
12
- ...this.getBaseFrontmatterVars(page),
13
- ...(this.options.getValue('sidebar').autoConfiguration
14
- ? {
15
- ...(sidebarLabel && { sidebar_label: sidebarLabel }),
16
- ...(sidebarPosition && {
17
- sidebar_position: sidebarPosition,
18
- }),
19
- }
20
- : {}),
21
- };
22
- };
23
- }
24
- getSidebarLabel(page) {
25
- if (page.url === this.options.getValue('entryDocument')) {
26
- return this.options.getValue('sidebar').indexLabel;
27
- }
28
- return null;
29
- }
30
- getSidebarPosition(page) {
31
- if (page.url === this.options.getValue('entryDocument')) {
32
- return page.url === page.project.url ? '0.5' : '0';
33
- }
34
- if (page.url === this.globalsFile) {
35
- return '0.5';
36
- }
37
- if (page.model.getFullName().split('.').length === 1) {
38
- return '0';
39
- }
40
- return null;
41
- }
42
- }
43
- exports.DocusaurusThemeRenderContext = DocusaurusThemeRenderContext;