@cparra/apexdocs 3.0.0-alpha.1 → 3.0.0-alpha.2
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.
- package/dist/cli/generate.js +13 -11
- package/dist/index.d.ts +10 -5
- package/examples/vitepress/apexdocs.config.ts +1 -1
- package/package.json +1 -1
- package/src/application/file-writer.ts +4 -4
- package/src/application/generators/markdown.ts +1 -1
- package/src/application/generators/openapi.ts +1 -1
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +1 -1
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +1 -1
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +3 -1
- package/src/core/markdown/adapters/reference-guide.ts +3 -1
- package/src/core/markdown/adapters/renderable-bundle.ts +1 -1
- package/src/core/markdown/adapters/renderable-to-page-data.ts +2 -2
- package/src/core/openapi/openapi-type-file.ts +1 -1
- package/src/core/shared/types.d.ts +10 -5
package/dist/cli/generate.js
CHANGED
|
@@ -611,7 +611,7 @@ const linkGenerator = (references, documentationRootDir, referenceName) => {
|
|
|
611
611
|
{
|
|
612
612
|
__type: "link",
|
|
613
613
|
title: reference.displayName,
|
|
614
|
-
url: path__namespace.join("/", documentationRootDir, reference.
|
|
614
|
+
url: path__namespace.join("/", documentationRootDir, reference.referencePath)
|
|
615
615
|
}
|
|
616
616
|
) : referenceName;
|
|
617
617
|
};
|
|
@@ -1198,7 +1198,7 @@ const convertToDocumentationBundle = (referenceGuideTemplate, { referencesByGrou
|
|
|
1198
1198
|
referenceGuide: {
|
|
1199
1199
|
frontmatter: null,
|
|
1200
1200
|
content: referencesToReferenceGuideContent(referencesByGroup, referenceGuideTemplate),
|
|
1201
|
-
|
|
1201
|
+
outputDocPath: "index.md"
|
|
1202
1202
|
},
|
|
1203
1203
|
docs: renderables.map(
|
|
1204
1204
|
(renderable) => renderableToPageData(Object.values(referencesByGroup).flat(), renderable)
|
|
@@ -1232,7 +1232,7 @@ function renderableToPageData(referenceGuideReference, renderable) {
|
|
|
1232
1232
|
name: renderable2.name,
|
|
1233
1233
|
type: renderable2.type
|
|
1234
1234
|
},
|
|
1235
|
-
|
|
1235
|
+
outputDocPath: reference.reference.outputDocPath,
|
|
1236
1236
|
frontmatter: null,
|
|
1237
1237
|
content: docContents,
|
|
1238
1238
|
group: (_a = renderable2.doc.group) != null ? _a : defaults.defaults.defaultGroupName
|
|
@@ -1450,10 +1450,12 @@ function parsedFilesToReferenceGuide(config, parsedFiles) {
|
|
|
1450
1450
|
}, {});
|
|
1451
1451
|
}
|
|
1452
1452
|
function parsedFileToDocPageReference(config, parsedFile) {
|
|
1453
|
+
const path = `${slugify(getTypeGroup(parsedFile.type, config))}/${parsedFile.type.name}.md`;
|
|
1453
1454
|
return {
|
|
1454
1455
|
source: parsedFile.source,
|
|
1455
1456
|
displayName: parsedFile.type.name,
|
|
1456
|
-
|
|
1457
|
+
outputDocPath: path,
|
|
1458
|
+
referencePath: path
|
|
1457
1459
|
};
|
|
1458
1460
|
}
|
|
1459
1461
|
function getTypeGroup(type, config) {
|
|
@@ -1645,15 +1647,15 @@ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
|
1645
1647
|
class FileWriter {
|
|
1646
1648
|
static write(files, outputDir, onWriteCallback) {
|
|
1647
1649
|
files.forEach((file) => {
|
|
1648
|
-
const {
|
|
1649
|
-
fs__namespace.mkdirSync(path__namespace.dirname(
|
|
1650
|
-
fs__namespace.writeFileSync(
|
|
1650
|
+
const { outputDocPath, content } = this.getTargetLocation(file, outputDir);
|
|
1651
|
+
fs__namespace.mkdirSync(path__namespace.dirname(outputDocPath), { recursive: true });
|
|
1652
|
+
fs__namespace.writeFileSync(outputDocPath, content, "utf8");
|
|
1651
1653
|
onWriteCallback(file);
|
|
1652
1654
|
});
|
|
1653
1655
|
}
|
|
1654
1656
|
static getTargetLocation(file, outputDir) {
|
|
1655
1657
|
return __spreadProps$6(__spreadValues$6({}, file), {
|
|
1656
|
-
|
|
1658
|
+
outputDocPath: path__namespace.join(outputDir, file.outputDocPath)
|
|
1657
1659
|
});
|
|
1658
1660
|
}
|
|
1659
1661
|
}
|
|
@@ -1769,7 +1771,7 @@ function writeFilesToSystem(files, outputDir) {
|
|
|
1769
1771
|
[files.referenceGuide, ...files.docs].filter((file) => !isSkip(file)),
|
|
1770
1772
|
outputDir,
|
|
1771
1773
|
(file) => {
|
|
1772
|
-
Logger.logSingle(`${file.
|
|
1774
|
+
Logger.logSingle(`${file.outputDocPath} processed.`, false, "green", false);
|
|
1773
1775
|
}
|
|
1774
1776
|
);
|
|
1775
1777
|
}
|
|
@@ -2654,7 +2656,7 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
2654
2656
|
function createOpenApiFile(fileName, openApiModel) {
|
|
2655
2657
|
const content = JSON.stringify(__spreadProps$1(__spreadValues$1({}, openApiModel), { namespace: void 0 }), null, 2);
|
|
2656
2658
|
return {
|
|
2657
|
-
|
|
2659
|
+
outputDocPath: "",
|
|
2658
2660
|
content,
|
|
2659
2661
|
frontmatter: null,
|
|
2660
2662
|
group: null
|
|
@@ -2727,7 +2729,7 @@ function openApi(fileBodies, config) {
|
|
|
2727
2729
|
Transpiler.generate(filteredTypes, processor);
|
|
2728
2730
|
const generatedFiles = processor.fileBuilder().files();
|
|
2729
2731
|
FileWriter.write(generatedFiles, config.targetDir, (file) => {
|
|
2730
|
-
Logger.logSingle(`${file.
|
|
2732
|
+
Logger.logSingle(`${file.outputDocPath} processed.`, false, "green", false);
|
|
2731
2733
|
});
|
|
2732
2734
|
ErrorLogger.logErrors(filteredTypes);
|
|
2733
2735
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,8 +33,13 @@ type DocPageReference = {
|
|
|
33
33
|
// The name under which the type should be displayed in the documentation.
|
|
34
34
|
// By default, this will match the source.name, but it can be configured by the user.
|
|
35
35
|
displayName: string;
|
|
36
|
-
// The location
|
|
37
|
-
|
|
36
|
+
// The location where the file will be written.
|
|
37
|
+
outputDocPath: string;
|
|
38
|
+
// The path to the file relative to the documentation root directory. This is used when linking to the file.
|
|
39
|
+
// Usually the value will be the same as outputDocPath. However, some site generators may have a different way of
|
|
40
|
+
// organizing the files, so this allows for the flexibility of having a path from linking that is different from
|
|
41
|
+
// the path where the file is written.
|
|
42
|
+
referencePath: string;
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
type Frontmatter = string | Record<string, unknown> | null;
|
|
@@ -42,13 +47,13 @@ type Frontmatter = string | Record<string, unknown> | null;
|
|
|
42
47
|
type ReferenceGuidePageData = {
|
|
43
48
|
frontmatter: Frontmatter;
|
|
44
49
|
content: string;
|
|
45
|
-
|
|
50
|
+
outputDocPath: string;
|
|
46
51
|
};
|
|
47
52
|
|
|
48
53
|
type DocPageData = {
|
|
49
54
|
source: SourceFileMetadata;
|
|
50
55
|
group: string | null;
|
|
51
|
-
|
|
56
|
+
outputDocPath: string;
|
|
52
57
|
frontmatter: Frontmatter;
|
|
53
58
|
content: string;
|
|
54
59
|
};
|
|
@@ -64,7 +69,7 @@ type Skip = {
|
|
|
64
69
|
|
|
65
70
|
type ConfigurableDocPageReference = Omit<DocPageReference, 'source'>;
|
|
66
71
|
|
|
67
|
-
type ConfigurableDocPageData = Omit<DocPageData, 'source' | '
|
|
72
|
+
type ConfigurableDocPageData = Omit<DocPageData, 'source' | 'outputDocPath'>;
|
|
68
73
|
|
|
69
74
|
/**
|
|
70
75
|
* Allows changing where the files are written to.
|
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@ import { PageData } from '../core/shared/types';
|
|
|
5
5
|
export class FileWriter {
|
|
6
6
|
static write(files: PageData[], outputDir: string, onWriteCallback: (file: PageData) => void) {
|
|
7
7
|
files.forEach((file) => {
|
|
8
|
-
const {
|
|
9
|
-
fs.mkdirSync(path.dirname(
|
|
10
|
-
fs.writeFileSync(
|
|
8
|
+
const { outputDocPath, content } = this.getTargetLocation(file, outputDir);
|
|
9
|
+
fs.mkdirSync(path.dirname(outputDocPath), { recursive: true });
|
|
10
|
+
fs.writeFileSync(outputDocPath, content, 'utf8');
|
|
11
11
|
onWriteCallback(file);
|
|
12
12
|
});
|
|
13
13
|
}
|
|
@@ -15,7 +15,7 @@ export class FileWriter {
|
|
|
15
15
|
private static getTargetLocation(file: PageData, outputDir: string): PageData {
|
|
16
16
|
return {
|
|
17
17
|
...file,
|
|
18
|
-
|
|
18
|
+
outputDocPath: path.join(outputDir, file.outputDocPath),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -48,7 +48,7 @@ function writeFilesToSystem(files: PostHookDocumentationBundle, outputDir: strin
|
|
|
48
48
|
.filter((file) => !isSkip(file)) as PageData[],
|
|
49
49
|
outputDir,
|
|
50
50
|
(file: PageData) => {
|
|
51
|
-
Logger.logSingle(`${file.
|
|
51
|
+
Logger.logSingle(`${file.outputDocPath} processed.`, false, 'green', false);
|
|
52
52
|
},
|
|
53
53
|
);
|
|
54
54
|
}
|
|
@@ -19,7 +19,7 @@ export default function openApi(fileBodies: UnparsedSourceFile[], config: UserDe
|
|
|
19
19
|
const generatedFiles = processor.fileBuilder().files();
|
|
20
20
|
|
|
21
21
|
FileWriter.write(generatedFiles, config.targetDir, (file: PageData) => {
|
|
22
|
-
Logger.logSingle(`${file.
|
|
22
|
+
Logger.logSingle(`${file.outputDocPath} processed.`, false, 'green', false);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// Error logging
|
|
@@ -12,7 +12,7 @@ describe('Generates interface documentation', () => {
|
|
|
12
12
|
|
|
13
13
|
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
14
14
|
expect(result).documentationBundleHasLength(1);
|
|
15
|
-
assertEither(result, (data) => expect(data.docs[0].
|
|
15
|
+
assertEither(result, (data) => expect(data.docs[0].outputDocPath).toContain('MyClass'));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('returns the type as class', async () => {
|
|
@@ -17,7 +17,7 @@ describe('Generates enum documentation', () => {
|
|
|
17
17
|
|
|
18
18
|
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
19
19
|
expect(result).documentationBundleHasLength(1);
|
|
20
|
-
assertEither(result, (data) => expect(data.docs[0].
|
|
20
|
+
assertEither(result, (data) => expect(data.docs[0].outputDocPath).toContain('MyEnum'));
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('returns the type as enum', async () => {
|
|
@@ -453,7 +453,9 @@ describe('Generates interface documentation', () => {
|
|
|
453
453
|
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
454
454
|
expect(result).documentationBundleHasLength(2);
|
|
455
455
|
assertEither(result, (data) =>
|
|
456
|
-
expect(data.docs.find((doc) => doc.
|
|
456
|
+
expect(data.docs.find((doc) => doc.outputDocPath.includes('AnotherInterface'))?.content).toContain(
|
|
457
|
+
'Inherited',
|
|
458
|
+
),
|
|
457
459
|
);
|
|
458
460
|
});
|
|
459
461
|
});
|
|
@@ -13,10 +13,12 @@ export function parsedFilesToReferenceGuide(
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function parsedFileToDocPageReference(config: MarkdownGeneratorConfig, parsedFile: ParsedFile): DocPageReference {
|
|
16
|
+
const path = `${slugify(getTypeGroup(parsedFile.type, config))}/${parsedFile.type.name}.md`;
|
|
16
17
|
return {
|
|
17
18
|
source: parsedFile.source,
|
|
18
19
|
displayName: parsedFile.type.name,
|
|
19
|
-
|
|
20
|
+
outputDocPath: path,
|
|
21
|
+
referencePath: path,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -14,7 +14,7 @@ export const convertToDocumentationBundle = (
|
|
|
14
14
|
referenceGuide: {
|
|
15
15
|
frontmatter: null,
|
|
16
16
|
content: referencesToReferenceGuideContent(referencesByGroup, referenceGuideTemplate),
|
|
17
|
-
|
|
17
|
+
outputDocPath: 'index.md',
|
|
18
18
|
},
|
|
19
19
|
docs: renderables.map((renderable: Renderable) =>
|
|
20
20
|
renderableToPageData(Object.values(referencesByGroup).flat(), renderable),
|
|
@@ -56,7 +56,7 @@ function renderableToPageData(referenceGuideReference: ReferenceGuideReference[]
|
|
|
56
56
|
name: renderable.name,
|
|
57
57
|
type: renderable.type,
|
|
58
58
|
},
|
|
59
|
-
|
|
59
|
+
outputDocPath: reference!.reference.outputDocPath,
|
|
60
60
|
frontmatter: null,
|
|
61
61
|
content: docContents,
|
|
62
62
|
group: renderable.doc.group ?? defaults.defaultGroupName,
|
|
@@ -4,7 +4,7 @@ import { OpenApiPageData } from '../shared/types';
|
|
|
4
4
|
export function createOpenApiFile(fileName: string, openApiModel: OpenApi): OpenApiPageData {
|
|
5
5
|
const content = JSON.stringify({ ...openApiModel, namespace: undefined }, null, 2);
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
outputDocPath: '',
|
|
8
8
|
content,
|
|
9
9
|
frontmatter: null,
|
|
10
10
|
group: null,
|
|
@@ -55,8 +55,13 @@ export type DocPageReference = {
|
|
|
55
55
|
// The name under which the type should be displayed in the documentation.
|
|
56
56
|
// By default, this will match the source.name, but it can be configured by the user.
|
|
57
57
|
displayName: string;
|
|
58
|
-
// The location
|
|
59
|
-
|
|
58
|
+
// The location where the file will be written.
|
|
59
|
+
outputDocPath: string;
|
|
60
|
+
// The path to the file relative to the documentation root directory. This is used when linking to the file.
|
|
61
|
+
// Usually the value will be the same as outputDocPath. However, some site generators may have a different way of
|
|
62
|
+
// organizing the files, so this allows for the flexibility of having a path from linking that is different from
|
|
63
|
+
// the path where the file is written.
|
|
64
|
+
referencePath: string;
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
type Frontmatter = string | Record<string, unknown> | null;
|
|
@@ -64,13 +69,13 @@ type Frontmatter = string | Record<string, unknown> | null;
|
|
|
64
69
|
export type ReferenceGuidePageData = {
|
|
65
70
|
frontmatter: Frontmatter;
|
|
66
71
|
content: string;
|
|
67
|
-
|
|
72
|
+
outputDocPath: string;
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
export type DocPageData = {
|
|
71
76
|
source: SourceFileMetadata;
|
|
72
77
|
group: string | null;
|
|
73
|
-
|
|
78
|
+
outputDocPath: string;
|
|
74
79
|
frontmatter: Frontmatter;
|
|
75
80
|
content: string;
|
|
76
81
|
};
|
|
@@ -100,7 +105,7 @@ export type PostHookDocumentationBundle = {
|
|
|
100
105
|
|
|
101
106
|
type ConfigurableDocPageReference = Omit<DocPageReference, 'source'>;
|
|
102
107
|
|
|
103
|
-
type ConfigurableDocPageData = Omit<DocPageData, 'source' | '
|
|
108
|
+
type ConfigurableDocPageData = Omit<DocPageData, 'source' | 'outputDocPath'>;
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
111
|
* Allows changing where the files are written to.
|