Skip to content

Commit faaf50b

Browse files
authored
Apexdocs improvements (#158)
1 parent ddc2aaf commit faaf50b

File tree

16 files changed

+875
-554
lines changed

16 files changed

+875
-554
lines changed

.idea/git_toolbox_blame.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apexdocs.config.ts

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,55 @@
11
import {readFileSync, writeFileSync} from "fs";
2-
import {OutputDir, TargetFile} from "@cparra/apexdocs/lib/settings";
2+
import {defineMarkdownConfig, skip} from "@cparra/apexdocs";
33

4-
function onBeforeFileWrite(file: TargetFile): TargetFile {
5-
const outputDir: OutputDir = {
6-
baseDir: file.dir.baseDir,
7-
fileDir: file.name
8-
};
4+
export default defineMarkdownConfig({
5+
sourceDir: 'expression-src',
6+
targetDir: 'docs/src/app/docs/api',
7+
scope: ['global'],
8+
namespace: 'expression',
9+
documentationRootDir: '/docs/api',
10+
transformReference: (reference) => {
11+
return {
12+
outputDocPath: reference.outputDocPath.replace('.md', '/page.md'),
13+
referencePath: reference.referencePath.replace('.md', ''),
14+
};
15+
},
16+
transformReferenceGuide: () => {
17+
return skip();
18+
},
19+
transformDocPage: (docPage) => {
20+
return {
21+
frontmatter: {
22+
nextjs: {
23+
metadata: {
24+
title: docPage.source.name,
25+
description: `Api documentation for the ${docPage.source.name} ${docPage.source.type}}`,
26+
}
27+
}
28+
},
29+
};
30+
},
31+
transformDocs: (docs) => {
32+
const navFileContents = readFileSync("docs/src/lib/navigation.json", "utf8");
33+
const navItems = JSON.parse(navFileContents);
34+
// Find an object whose title is "Api"
35+
let apiNavObject = navItems.find((navObject: any) => navObject.title === "Api");
36+
apiNavObject = apiNavObject ?? {title: "Api", links: []};
937

10-
return {
11-
name: 'page',
12-
extension: '.md',
13-
dir: outputDir
14-
}
15-
}
38+
apiNavObject.links = docs.map((doc) => {
39+
return {
40+
title: doc.source.name, href: `/docs/api/${doc.outputDocPath.replace('page.md', '').replace(/\/$/, '')}`
41+
};
42+
});
1643

17-
function onAfterProcess(files: TargetFile[]) {
18-
const navFileContents = readFileSync("docs/src/lib/navigation.json", "utf8");
19-
const navItems = JSON.parse(navFileContents);
20-
// Find an object whose title is "Api"
21-
let apiNavObject = navItems.find((navObject: any) => navObject.title === "Api");
22-
apiNavObject = apiNavObject ?? {title: "Api", links: []};
44+
// replace the Api object with the new one (or add it if it didn't exist)
45+
const newNavItems = navItems.filter((navObject: any) => navObject.title !== "Api");
46+
newNavItems.push(apiNavObject);
2347

24-
apiNavObject.links = files.filter((file) => file.dir.fileDir !== 'index').map((file) => {
25-
return {title: file.dir.fileDir, href: `/docs/api/${file.dir.fileDir}`};
26-
});
48+
// Write the new navigation.json file
49+
const newNavFileContents = JSON.stringify(newNavItems, null, 2);
50+
console.log("Writing new navigation.json file");
51+
writeFileSync("docs/src/lib/navigation.json", newNavFileContents);
2752

28-
// replace the Api object with the new one (or add it if it didn't exist)
29-
const newNavItems = navItems.filter((navObject: any) => navObject.title !== "Api");
30-
newNavItems.push(apiNavObject);
31-
32-
// Write the new navigation.json file
33-
const newNavFileContents = JSON.stringify(newNavItems, null, 2);
34-
console.log("Writing new navigation.json file");
35-
writeFileSync("docs/src/lib/navigation.json", newNavFileContents);
36-
}
37-
38-
export default {
39-
onBeforeFileWrite,
40-
onAfterProcess
41-
};
53+
return docs;
54+
},
55+
});

docs/src/app/docs/api/expression.Configuration/page.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)