Skip to content

Commit

Permalink
change file names
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJuanAndOnly99 committed Feb 8, 2024
1 parent 69aeded commit 8b8960c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 104 deletions.
13 changes: 8 additions & 5 deletions schema2Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ function generateMarkdown(schema) {

let markdownContent = `# ${schema.title}\n\n`;
markdownContent += `${schema.description}\n\n`;
markdownContent += `## Properties\n\n`;


function processProperty(propertyName, propertyDetails) {
if (propertyName === 'type') {
markdownContent += `### ${'Type'|| propertyName}\n\n`;
markdownContent += `## ${'Type'|| propertyName}\n\n`;
markdownContent += `\`${propertyDetails.const}\`\n\n`;
markdownContent += `## Properties\n\n`;
} else {
markdownContent += `### ${propertyDetails.title || propertyName}\n\n`;
markdownContent += `\`${propertyName}\`\n\n`;
Expand Down Expand Up @@ -79,7 +79,7 @@ function generateMarkdown(schema) {
markdownContent += `ref: ${schema.allOf[1].$ref}\n\n`;
}

markdownContent += `## Examples\n\n`;
markdownContent += `## examples\n\n`;
markdownContent += '```json\n';
markdownContent += JSON.stringify(schema.examples, null, 2);
markdownContent += '\n```';
Expand All @@ -97,10 +97,13 @@ function generateFrontMatter(title, description) {

function processSchemaFile(schemaFile) {
const schemaData = fs.readJSONSync(schemaFile);

const fileName = path.basename(schemaFile);

const markdownContent = generateMarkdown(schemaData);
const frontMatter = generateFrontMatter(schemaData.title, schemaData.description);
const frontMatter = generateFrontMatter(fileName.replace('.schema.json', '.md'), schemaData.description);

const outputFileName = `./docs/context/schemas/${schemaData.title.toLowerCase().replace(/\s+/g, '-')}-schema.md`;
const outputFileName = `./docs/context/schemas/${schemaData.title.replace(/\s+/g, '')}.md`;
fs.outputFileSync(outputFileName, `---\n${yaml.dump(frontMatter)}\n---\n\n${markdownContent}`);
}

Expand Down
99 changes: 0 additions & 99 deletions schema2Markdown2.js

This file was deleted.

0 comments on commit 8b8960c

Please sign in to comment.