Skip to content

Commit 197ff17

Browse files
feat: creating generateNewestContractVersionDocs file
1 parent 3d3b41a commit 197ff17

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

src/generate-docs.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { generateSchemaDetails } from "./helpers/generateSchemaDetails.js";
66
import { writeIndexFile } from "./helpers/writeIndexFile.js";
77
import { writeSchemaFile } from "./helpers/writeSchemaFile.js";
88
import { ContractSchemaType, SchemaDetails } from "./types.js";
9+
import { generateNewestContractVersionDocs } from "./helpers/generateNewestContractVersionDocs.js";
910

1011
//Note: contract file name must include term 'Contract' to be parsed
1112
const getContractFileNames = async (
@@ -41,31 +42,6 @@ const getRecordOfNewestContractVersions = (
4142
return newestContractVersions;
4243
};
4344

44-
const writeNewestContractVersionDocs = async (
45-
newestContractVersions: Record<
46-
string,
47-
{ detailVersion: number; schema: ContractSchemaType }
48-
>,
49-
pathToDocumentationFolder: string
50-
) => {
51-
for (const detailType in newestContractVersions) {
52-
const detailVersion = newestContractVersions[detailType].detailVersion;
53-
const pathToContractDocumentationFolder = path.join(
54-
`${pathToDocumentationFolder}/${detailType}`
55-
);
56-
await writeIndexFile(
57-
pathToContractDocumentationFolder,
58-
detailType,
59-
detailVersion
60-
);
61-
62-
await writeSchemaFile(
63-
pathToContractDocumentationFolder,
64-
newestContractVersions[detailType].schema
65-
);
66-
}
67-
};
68-
6945
export const generateDocumentation = async (
7046
pathToContractsFolder: string,
7147
pathToDocumentationFolder: string
@@ -104,7 +80,7 @@ export const generateDocumentation = async (
10480
console.log(newestContractVersions);
10581
}
10682

107-
writeNewestContractVersionDocs(
83+
generateNewestContractVersionDocs(
10884
newestContractVersions,
10985
pathToDocumentationFolder
11086
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ContractSchemaType } from "src/types.js";
2+
import { writeIndexFile } from "./writeIndexFile.js";
3+
import { writeSchemaFile } from "./writeSchemaFile.js";
4+
import path from "path";
5+
6+
export const generateNewestContractVersionDocs = async (
7+
newestContractVersions: Record<
8+
string,
9+
{ detailVersion: number; schema: ContractSchemaType }
10+
>,
11+
pathToDocumentationFolder: string
12+
) => {
13+
for (const detailType in newestContractVersions) {
14+
const detailVersion = newestContractVersions[detailType].detailVersion;
15+
const pathToContractDocumentationFolder = path.join(
16+
`${pathToDocumentationFolder}/${detailType}`
17+
);
18+
await writeIndexFile(
19+
pathToContractDocumentationFolder,
20+
detailType,
21+
detailVersion
22+
);
23+
24+
await writeSchemaFile(
25+
pathToContractDocumentationFolder,
26+
newestContractVersions[detailType].schema
27+
);
28+
}
29+
};

0 commit comments

Comments
 (0)