@tinymce/moxiedoc
Advanced tools
Comparing version 0.3.0-feature.20220823031435722.sha77c775d to 0.3.0-feature.20220823041821929.sha7174d83
@@ -60,3 +60,3 @@ "use strict"; | ||
exports.getFilePath = getFilePath; | ||
const namespaceLine = (namespace, structure) => { | ||
const namespaceNavLine = (namespace, structure) => { | ||
switch (structure) { | ||
@@ -69,3 +69,3 @@ case 'legacy': | ||
}; | ||
const pageFileLine = (pageFile, structure) => { | ||
const pageFileNavLine = (pageFile, structure) => { | ||
const fileName = (pageFile.path === 'tinymce' ? getRootPath(structure) : pageFile.path) + '.adoc'; | ||
@@ -80,2 +80,7 @@ switch (structure) { | ||
}; | ||
const pageFileLegacyIndexLine = (pageFile, structure) => { | ||
const fileName = (pageFile.path === 'tinymce' ? getRootPath(structure) : pageFile.path) + '.adoc'; | ||
const folder = getNamespaceFromFullName(pageFile.path); | ||
return generateNavXref('api/' + folder, fileName, getNameFromFullName(pageFile.title)); | ||
}; | ||
const getRootPath = (structure) => { | ||
@@ -135,6 +140,6 @@ switch (structure) { | ||
indexPage.pages.forEach((namespace) => { | ||
adoc += navLine(namespaceLine(namespace, structure), 2); | ||
adoc += navLine(namespaceNavLine(namespace, structure), 2); | ||
if (namespace.pages) { | ||
namespace.pages.forEach((pageFile) => { | ||
adoc += navLine(pageFileLine(pageFile, structure), 3); | ||
adoc += navLine(pageFileNavLine(pageFile, structure), 3); | ||
}); | ||
@@ -162,3 +167,3 @@ } | ||
exports.generateNavPages = generateNavPages; | ||
const indexToAdoc = (namespace, template, descriptions, structure) => { | ||
const legacyIndexToAdoc = (namespace, template, descriptions, structure) => { | ||
const keywords = [getApiFromFullName(namespace.title)]; | ||
@@ -174,8 +179,11 @@ const indexPageLines = [ | ||
indexPageLines.push('[.lead]\n'); | ||
indexPageLines.push(pageFileLine(pageFile, structure) + '\n\n'); | ||
indexPageLines.push(pageFileLegacyIndexLine(pageFile, structure) + '\n\n'); | ||
const description = descriptions[pageFile.path]; | ||
indexPageLines.push(description + '\n\n'); | ||
}); | ||
if (namespace.pages.length % 2 !== 0) { | ||
indexPageLines.push('a|\n'); | ||
} | ||
indexPageLines.push('|===\n'); | ||
} | ||
indexPageLines.push('|===\n'); | ||
const data = { | ||
@@ -195,3 +203,3 @@ fullName: namespace.title, | ||
filename: BASE_PATH + '/api/' + namespace.path + '/index.adoc', | ||
content: indexToAdoc(namespace, memberTemplate, descriptions, structure) | ||
content: legacyIndexToAdoc(namespace, memberTemplate, descriptions, structure) | ||
})); | ||
@@ -198,0 +206,0 @@ return newNavPages; |
{ | ||
"name": "@tinymce/moxiedoc", | ||
"version": "0.3.0-feature.20220823031435722.sha77c775d", | ||
"version": "0.3.0-feature.20220823041821929.sha7174d83", | ||
"description": "A tool for generating API documentation", | ||
@@ -5,0 +5,0 @@ "author": "Tiny Technologies, Inc", |
@@ -90,3 +90,3 @@ import * as fs from 'fs'; | ||
const namespaceLine = (namespace: NavFile, structure: ExportStructure): string => { | ||
const namespaceNavLine = (namespace: NavFile, structure: ExportStructure): string => { | ||
switch (structure) { | ||
@@ -101,3 +101,3 @@ case 'legacy': | ||
const pageFileLine = (pageFile: NavFile, structure: ExportStructure): string => { | ||
const pageFileNavLine = (pageFile: NavFile, structure: ExportStructure): string => { | ||
const fileName = (pageFile.path === 'tinymce' ? getRootPath(structure) : pageFile.path) + '.adoc'; | ||
@@ -114,2 +114,8 @@ switch (structure) { | ||
const pageFileLegacyIndexLine = (pageFile: NavFile, structure: ExportStructure): string => { | ||
const fileName = (pageFile.path === 'tinymce' ? getRootPath(structure) : pageFile.path) + '.adoc'; | ||
const folder = getNamespaceFromFullName(pageFile.path); | ||
return generateNavXref('api/' + folder, fileName, getNameFromFullName(pageFile.title)); | ||
}; | ||
const getRootPath = (structure: ExportStructure): string => { | ||
@@ -175,6 +181,6 @@ switch (structure) { | ||
indexPage.pages.forEach((namespace) => { | ||
adoc += navLine(namespaceLine(namespace, structure), 2); | ||
adoc += navLine(namespaceNavLine(namespace, structure), 2); | ||
if (namespace.pages) { | ||
namespace.pages.forEach((pageFile) => { | ||
adoc += navLine(pageFileLine(pageFile, structure), 3); | ||
adoc += navLine(pageFileNavLine(pageFile, structure), 3); | ||
}); | ||
@@ -204,3 +210,4 @@ } | ||
const indexToAdoc = (namespace: NavFile, template: HandlebarsTemplateDelegate, descriptions: Record<string, string>, structure: ExportStructure): string => { | ||
const legacyIndexToAdoc = | ||
(namespace: NavFile, template: HandlebarsTemplateDelegate, descriptions: Record<string, string>, structure: ExportStructure): string => { | ||
const keywords = [ getApiFromFullName(namespace.title) ]; | ||
@@ -219,8 +226,11 @@ const indexPageLines = [ | ||
indexPageLines.push('[.lead]\n'); | ||
indexPageLines.push(pageFileLine(pageFile, structure) + '\n\n'); | ||
indexPageLines.push(pageFileLegacyIndexLine(pageFile, structure) + '\n\n'); | ||
const description = descriptions[pageFile.path]; | ||
indexPageLines.push(description + '\n\n'); | ||
}); | ||
if (namespace.pages.length % 2 !== 0) { | ||
indexPageLines.push('a|\n'); | ||
} | ||
indexPageLines.push('|===\n'); | ||
} | ||
indexPageLines.push('|===\n'); | ||
const data = { | ||
@@ -243,3 +253,3 @@ fullName: namespace.title, | ||
filename: BASE_PATH + '/api/' + namespace.path + '/index.adoc', | ||
content: indexToAdoc(namespace, memberTemplate, descriptions, structure) | ||
content: legacyIndexToAdoc(namespace, memberTemplate, descriptions, structure) | ||
}) | ||
@@ -246,0 +256,0 @@ ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
367367
6943