diff --git a/src/app/lib/markdoc.ts b/src/app/lib/markdoc.ts index 1f40bbd..fb840b6 100644 --- a/src/app/lib/markdoc.ts +++ b/src/app/lib/markdoc.ts @@ -8,20 +8,23 @@ import { Doc, DocSection } from './../types/types'; const DOCS_PATH = path.join(process.cwd(), 'src/docs'); -function getCopyPath(version: string, doc: Doc): string { +function getCopyPath( + version: string, + doc: Doc, + docPath: string +): string { if (doc.copy === undefined) { return ''; } - return path.join( - DOCS_PATH, - version, - doc.folder, - doc.copy - ); + return path.join(DOCS_PATH, version, docPath, doc.copy); } -function getExamplePath(version: string, doc: Doc): string { +function getExamplePath( + version: string, + doc: Doc, + docPath: string +): string { if (doc.example === undefined) { return ''; } @@ -29,7 +32,7 @@ function getExamplePath(version: string, doc: Doc): string { return path.join( DOCS_PATH, version, - doc.folder, + docPath, doc.example ); } @@ -80,32 +83,48 @@ function parseMarkdown(sourcePath: string): ReactNode { return children; } -function getCopyChild(version: string, doc: Doc) { - const copyPath = getCopyPath(version, doc); +function getCopyChild( + version: string, + doc: Doc, + docPath: string +) { + const copyPath = getCopyPath(version, doc, docPath); return parseMarkdown(copyPath); } -function getExampleChild(version: string, doc: Doc) { - const examplePath = getExamplePath(version, doc); +function getExampleChild( + version: string, + doc: Doc, + docPath: string +) { + const examplePath = getExamplePath(version, doc, docPath); return parseMarkdown(examplePath); } export function loadSections( version: string, docs: Doc[], - sections: DocSection[] = [] + sections: DocSection[] = [], + docPath: string = '' ): DocSection[] { for (const doc of docs) { + const sourcePath = path.join(docPath, doc.folder); + if (doc.copy && doc.example) { sections.push({ title: doc.title, - copy: getCopyChild(version, doc), - example: getExampleChild(version, doc), + copy: getCopyChild(version, doc, sourcePath), + example: getExampleChild(version, doc, sourcePath), }); } if (doc.children && doc.children.length > 0) { - loadSections(version, doc.children, sections); + loadSections( + version, + doc.children, + sections, + sourcePath + ); } } diff --git a/src/docs/version_002/data_format/example.md b/src/docs/version_002/data_format/example.md index 5f45945..838f891 100644 --- a/src/docs/version_002/data_format/example.md +++ b/src/docs/version_002/data_format/example.md @@ -42,7 +42,7 @@ }, { "type": "TimeSpan", - "fieldId": 4810, + "fieldId": 4810, // TimeSpan Field "value": { "quantity": 11, "increment": "Seconds", diff --git a/src/docs/version_002/docsStructure.ts b/src/docs/version_002/docsStructure.ts index 9ad132d..c3ab3a3 100644 --- a/src/docs/version_002/docsStructure.ts +++ b/src/docs/version_002/docsStructure.ts @@ -38,20 +38,19 @@ export const versionTwo: DocsStructure = { children: [ { title: 'Records', - folder: 'resources/records', + folder: 'records', copy: 'copy.md', example: 'example.md', children: [ { title: 'Field Values', - folder: 'resources/records/field_values', + folder: 'field_values', copy: 'copy.md', example: 'example.md', }, { title: 'Get Records by App', - folder: - 'resources/records/get_records_by_app', + folder: 'get_records_by_app', copy: 'copy.md', example: 'example.md', }, diff --git a/src/docs/version_002/error_handling/copy.md b/src/docs/version_002/error_handling/copy.md new file mode 100644 index 0000000..e69de29 diff --git a/src/docs/version_002/error_handling/example.md b/src/docs/version_002/error_handling/example.md new file mode 100644 index 0000000..e69de29