Skip to content

Commit

Permalink
Fix various issues with djockey’s API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
irskep committed Sep 2, 2024
1 parent e82bcb4 commit afc38f8
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 308 deletions.
Binary file modified bun.lockb
Binary file not shown.
669 changes: 396 additions & 273 deletions docs/src/typescript_link_mapping.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"shiki": "^1.14.1"
},
"devDependencies": {
"@djockey/linkmapper-typedoc": "^0.0.5",
"@djockey/linkmapper-typedoc": "^0.0.7",
"@jest/globals": "^29.7.0",
"@types/argparse": "^2.0.16",
"@types/d3": "^7.4.3",
Expand Down
2 changes: 1 addition & 1 deletion src/engine/djotFiltersPlus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const applyFilterToFragment = function (root: AstNode, filter: Filter): void {
}
};

export type { Action, FilterPart, Filter };
export type { Action, FilterPart, Filter, Transform };
export { applyFilter, applyFilterToFragment };

// Extra exports
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ export type {
DjockeyRenderer,
DjockeyPlugin,
DjockeyPluginModule,
DjockeyPluginNodeReservation,
DjockeyLinkMappingDoc,
DjockeyLinkMapping,
LinkMappingConfig,
} from "./types.js";

export type { DocSet } from "./engine/docset.js";
export type { DocTree, DocTreeSection } from "./engine/doctree.js";

export { applyFilter } from "./engine/djotFiltersPlus.js";
export {
applyFilter,
Filter,
FilterPart,
Action,
Transform,
} from "./engine/djotFiltersPlus.js";
export { LogCollector } from "./utils/logUtils.js";
2 changes: 1 addition & 1 deletion src/plugins/linkRewritingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class LinkRewritingPlugin implements DjockeyPlugin {
// Silently ignore duplicate entries of the same thing
this._mappedLinkDestinations[dest] !== url
) {
args.logCollector.warning(`Duplicate mapped link: ${dest}`);
args.logCollector.info(`Duplicate mapped link: ${dest}`);
} else {
this._mappedLinkDestinations[dest] = url;
this._defaultLinkLabels[dest] = mapping.defaultLabel;
Expand Down
37 changes: 20 additions & 17 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { AstNode, Doc, Inline } from "@djot/djot";
import { Environment } from "nunjucks";
import { LogCollector } from "./utils/logUtils.js";

export type LinkMappingConfig = { path: string; url_root: string };
export interface LinkMappingConfig {
path: string;
url_root: string;
}

export type DjockeyConfig = {
export interface DjockeyConfig {
input_dir: string;
output_dir: Record<DjockeyOutputFormat, string>;
url_root?: string;
Expand Down Expand Up @@ -41,16 +44,16 @@ export type DjockeyConfig = {
theme_dark: string;
};
};
};
}

export type DjockeyConfigResolved = DjockeyConfig & {
export interface DjockeyConfigResolved extends DjockeyConfig {
rootPath: string;
fileList: string[];
url_root: string;
link_mappings: LinkMappingConfig[];
};
}

export type DjockeyDoc = {
export interface DjockeyDoc {
docs: { content: Doc } & Record<string, Doc>;
title: string;
titleAST: Inline[];
Expand All @@ -68,7 +71,7 @@ export type DjockeyDoc = {

// For use by plugins
data: Record<string, unknown>;
};
}

// These correspond to pandoc formats. Keep these two lines in sync.
export type DjockeyInputFormat = "djot" | "gfm";
Expand Down Expand Up @@ -106,7 +109,7 @@ export type DjockeyRenderer = {
}) => string;
};

export type DjockeyPlugin = {
export interface DjockeyPlugin {
name: string;

getNodeReservations?: (
Expand Down Expand Up @@ -138,26 +141,26 @@ export type DjockeyPlugin = {
config: DjockeyConfigResolved;
logCollector: LogCollector;
}) => void;
};
}

export type DjockeyPluginNodeReservation = {
export interface DjockeyPluginNodeReservation {
match: (node: AstNode) => Boolean;
};
}

export type DjockeyPluginModule = {
export interface DjockeyPluginModule {
makePlugin: (config: DjockeyConfig) => DjockeyPlugin;
};
}

/* LINK MAPPINGS */

export type DjockeyLinkMapping = {
export interface DjockeyLinkMapping {
linkDestination: string;
relativeURL: string;
defaultLabel: string;
};
}

export type DjockeyLinkMappingDoc = {
export interface DjockeyLinkMappingDoc {
version: number;
namespaces: string[];
linkMappings: DjockeyLinkMapping[];
};
}
18 changes: 9 additions & 9 deletions src/utils/logUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function severityToLevel(severity: LogLine["severity"]): number {
}

export class LogCollector {
public lines = new Array<LogLine>();
private lines = new Array<LogLine>();

public loader: ReturnType<typeof print.spin>;
private loader: ReturnType<typeof print.spin>;

constructor(public label: string, shouldStart = true) {
this.loader = print.spin(label);
Expand All @@ -32,17 +32,17 @@ export class LogCollector {
}
}

succeed(severity: LogLine["severity"]) {
public succeed(severity: LogLine["severity"]) {
this.loader.succeed();
this.dump(severity);
}

fail(severity: LogLine["severity"]) {
public fail(severity: LogLine["severity"]) {
this.loader.fail();
this.dump(severity);
}

dump(severity: LogLine["severity"]) {
public dump(severity: LogLine["severity"]) {
for (const line of this.lines) {
if (severityToLevel(line.severity) <= severityToLevel(severity)) {
switch (line.severity) {
Expand All @@ -64,19 +64,19 @@ export class LogCollector {
this.lines = [];
}

debug(text: string) {
public debug(text: string) {
this.lines.push({ severity: "debug", text });
}

info(text: string) {
public info(text: string) {
this.lines.push({ severity: "info", text });
}

warning(text: string) {
public warning(text: string) {
this.lines.push({ severity: "warning", text });
}

error(text: string) {
public error(text: string) {
this.lines.push({ severity: "error", text });
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,17 @@ __metadata:
languageName: node
linkType: hard

"@djockey/linkmapper-typedoc@npm:^0.0.5":
version: 0.0.5
resolution: "@djockey/linkmapper-typedoc@npm:0.0.5"
"@djockey/linkmapper-typedoc@npm:^0.0.7":
version: 0.0.7
resolution: "@djockey/linkmapper-typedoc@npm:0.0.7"
dependencies:
argparse: ^2.0.1
typedoc: ^0.26.6
peerDependencies:
typescript: ^5.0.0
bin:
linkmapper-typedoc: index.js
checksum: cb415e257f25ad6c34b147c0780ae358a04f626fa3f3be503ca066a4bd771e73891c13f7014b02e01ec95dec7f63e270ef862aaf63c1731c6eeca4fff63842f8
checksum: 494bcd5240c5827ac3d8a69a698abc6069c149ee9dfb71454552924989acc5692c14505eb11cedbd38705b23132ade02c282c3483823760fd0cc9fb0da098d65
languageName: node
linkType: hard

Expand Down Expand Up @@ -2460,7 +2460,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "djockey@workspace:."
dependencies:
"@djockey/linkmapper-typedoc": ^0.0.5
"@djockey/linkmapper-typedoc": ^0.0.7
"@djot/djot": ^0.3.1
"@jest/globals": ^29.7.0
"@types/argparse": ^2.0.16
Expand Down

0 comments on commit afc38f8

Please sign in to comment.